CMakeLists.txt 5.69 KB
Newer Older
Nicolas Docquier's avatar
Nicolas Docquier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#
# author: Nicolas Docquier (on basis of Nicolas Van der Noot example)
# November 2014
#
# CMake for a simple pour C robotran project 
#

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                       PROJECT MAIN CONFIGURATIONS
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


# CMake minimum version
cmake_minimum_required(VERSION 2.8.7)

# project name
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
17
project (projectRobotran)
Nicolas Docquier's avatar
Nicolas Docquier committed
18

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
19
20
21
22
# project configuration
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

Nicolas Docquier's avatar
Nicolas Docquier committed
23
# Variable for storing the path to Robotran common files (should be adapted depending on the location of those source)
24
set(ROBOTRAN_DIR_COMMON "${PROJECT_SOURCE_DIR}/../../../MBsysC/")
Nicolas Docquier's avatar
Nicolas Docquier committed
25
26
27
28
29
30
31
32
33
34
set(ROBOTRAN_DIR_COPY "${PROJECT_SOURCE_DIR}/../mbsysCopy/")
# change the following line with 'set(ROBOTRAN_SOURCE_DIR ${ROBOTRAN_DIR_COPY})'' to use the Standalone version
set(ROBOTRAN_SOURCE_DIR ${ROBOTRAN_DIR_COMMON}) 

# message to display the project name
message(STATUS "Processing ${PROJECT_NAME}")

# for Unix: display all the warnings, except the ones related to /* -- */ and for the unused variables
if (UNIX)
  set(CMAKE_C_FLAGS "-g -Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-comment")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
35
  # remove some compilation warnings (This line should be removed once the loading, equil and modal modules are stabilized)
Nicolas Docquier's avatar
Nicolas Docquier committed
36
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-uninitialized -Wno-unused-result -Wno-maybe-uninitialized")  
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
37
endif ( )
Nicolas Docquier's avatar
Nicolas Docquier committed
38
39

# add additional CMakeLists.txt files
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
40
41
42
43
44
set(CMAKE_AUX ${ROBOTRAN_SOURCE_DIR}/cmake_aux)
set(CMAKE_AUX_BIN ${PROJECT_BINARY_DIR}/cmake_aux)
add_subdirectory (${CMAKE_AUX}/flags/ ${CMAKE_AUX_BIN}/flags/)
add_subdirectory (${CMAKE_AUX}/listing/ ${CMAKE_AUX_BIN}/listing/)
add_subdirectory (${CMAKE_AUX}/libraries/ ${CMAKE_AUX_BIN}/libraries/)
Nicolas Docquier's avatar
Nicolas Docquier committed
45
46
47
48
49
50


# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                         FLAGS RELATED FUNCTIONS
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

51
52
53
# uncomment to include the real-time libraries by default
#set_flag(FLAG_REAL_TIME ON)

Nicolas Docquier's avatar
Nicolas Docquier committed
54
55
56
57
58
flags_check()
release_debug()
definitions()


Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
59
60
61
62
63
64
65
66
67
68
69
70

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                           USER ABSOLUTE PATHS
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# configure a header file to pass some of the CMake settings to the source code
configure_file (
  "${ROBOTRAN_SOURCE_DIR}/conf/cmake_config.h.in"
  "${PROJECT_BINARY_DIR}/conf/cmake_config.h"
)
# 'cmake_config.h.in' is in the 'conf' folder
include_directories (${PROJECT_BINARY_DIR}/conf)
Nicolas Docquier's avatar
Nicolas Docquier committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85



# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                           LIST FILES
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

 
# list source files to compile
init_src()

increment_src("${PROJECT_SOURCE_DIR}/src")
increment_src("${PROJECT_SOURCE_DIR}/../userfctR")
increment_src("${PROJECT_SOURCE_DIR}/../symbolicR")

86
increment_void_symbolic(symbolicR)
87

Nicolas Docquier's avatar
Nicolas Docquier committed
88
89
90
91
92
93
94

# list include directories (to find headers)
init_include()

increment_include("${PROJECT_SOURCE_DIR}/..")
increment_include("${ROBOTRAN_SOURCE_DIR}")

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124


# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                           EXTERNAL LIBRARIES
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

## --- WIN32 or WIN64 DETECTION --- ##

if( CMAKE_SIZEOF_VOID_P EQUAL 8 )   # 64bit windows
	SET(WIN_LIB_DIRECTORY win64_include_lib)
  else( CMAKE_SIZEOF_VOID_P EQUAL 8 )  # 32bit windows
	SET(WIN_LIB_DIRECTORY win32_include_lib)
endif( )

## ---- WINDOWS DLL FILES ---- ##

# copy all the dll (except 'jvm.dll') used for Windows
# these dll files are copied in the Executable directory (Debug or Release)
if (WIN32)
	file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${CMAKE_BINARY_DIR}/Debug)
	file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${CMAKE_BINARY_DIR}/Release)
endif ( )

set(CMAKE_MODULE_PATH ${ROBOTRAN_SOURCE_DIR}/conf)

# GSL
gsl_lib(project)



Nicolas Docquier's avatar
Nicolas Docquier committed
125
126
127
128
129
130
131
132
133
134
135
136
137
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                         CONFIGURE EXECUTABLE
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# include these directories
include_directories (${INCLUDE_DIR})

# name of the executable
set (Executable exe_${PROJECT_NAME})

# generate the executable
add_executable (${Executable} ${SOURCE_FILES})

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
138

139

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
140
141
142
if (FLAG_VISU)
	include_directories(${JNI_INCLUDE_PATH})
endif (FLAG_VISU)
143

Nicolas Docquier's avatar
Nicolas Docquier committed
144
145
# math external library (for Unix): linkage
if (UNIX)
146
	target_link_libraries (${Executable} m)
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
147
endif ( )
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
148

149
150
151
#Libxml2 and GSL external libraries: linkage
target_link_libraries (${Executable} ${LIBXML2_LIBRARIES} ${GSL_LIBRARIES})

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
152
153
# SDL external library: linkage
if (FLAG_PLOT)
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
154
155
	target_link_libraries (${Executable} ${SDL2_LIBRARIES} ${SDL2TTF_LIBRARIES})
endif ( )
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
156
157
158
159

# Java external library: linkage
if (FLAG_VISU)
	target_link_libraries (${Executable} ${JNI_LIBRARIES})
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
160
endif ( )
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174

if (FLAG_SEPARATE_BUILD) # find MBSysC dynamic libraries
	find_package(LibRobotranC REQUIRED)
	target_link_libraries(${Executable} "${LIB_MBSYSC_MODULES}")
	target_link_libraries(${Executable} "${LIB_MBSYSC_LOAD}")
	target_link_libraries(${Executable} "${LIB_MBSYSC_UTILITIES}")
else ( )
	add_subdirectory("${ROBOTRAN_SOURCE_DIR}/mbs_common" "${CMAKE_CURRENT_BINARY_DIR}/mbs_common")
	target_link_libraries(${Executable} MBsysC_loadXML)
	target_link_libraries(${Executable} MBsysC_module)
	if(NOT FLAG_SHARED_LIB)
		target_link_libraries(${Executable} MBsysC_struct MBsysC_numerics MBsysC_utilities MBsysC_realtime)
	endif(NOT FLAG_SHARED_LIB)
endif ( )