forked from morse-simulator/morse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
233 lines (199 loc) · 7.2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
cmake_minimum_required(VERSION 2.6)
set(PACKAGE_NAME morse)
set(PACKAGE_VERSION "0.6.99")
option(BUILD_CORE_SUPPORT "Build and install morse core" ON)
option(BUILD_DOC_SUPPORT "Build and install morse documentation (Requiere Sphinx)" OFF)
option(BUILD_POCOLIBS_SUPPORT "Build pocolibs framework support" OFF)
option(BUILD_YARP2_SUPPORT "Build yarp framework support" OFF)
option(BUILD_ROS_SUPPORT "Build ROS middleware support" OFF)
option(BUILD_MOOS_SUPPORT "Build MOOS middleware support" OFF)
option(BUILD_HLA_SUPPORT "Build HLA middleware support. Also used for distributed HLA simulation." OFF)
option(PYMORSE_SUPPORT "Build and install the Python bindings for MORSE." OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config/)
find_package(PkgConfig REQUIRED)
find_package(Python32Interp REQUIRED)
if (NOT PYTHON3INTERP_FOUND)
MESSAGE(FATAL_ERROR "Can't find python 3.2 on your system")
endif(NOT PYTHON3INTERP_FOUND)
find_package(Python32Libs REQUIRED)
EXECUTE_PROCESS(COMMAND
${PYTHON3_EXECUTABLE} -c "import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_lib(1,0,\"\"))"
OUTPUT_VARIABLE PYTHON_INSTALL
ERROR_VARIABLE PYTHON_STDERR
RESULT_VARIABLE PYTHON_ERR
)
if(NOT PYTHON_INSTDIR)
SET(PYTHON_INSTDIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL})
endif(NOT PYTHON_INSTDIR)
if(WIN32)
STRING(REGEX REPLACE "\\\\" "/" PYTHON_INSTDIR ${PYTHON_INSTDIR})
endif(WIN32)
MESSAGE(STATUS "will install python files in ${PYTHON_INSTDIR}")
# Compute revision
ADD_CUSTOM_TARGET(revisiontag ALL)
ADD_CUSTOM_COMMAND(TARGET revisiontag COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/config/version.cmake)
if (BUILD_CORE_SUPPORT)
INSTALL(FILES ${CMAKE_BINARY_DIR}/version.py DESTINATION ${PYTHON_INSTDIR}/morse/)
endif(BUILD_CORE_SUPPORT)
if (BUILD_YARP2_SUPPORT)
EXECUTE_PROCESS(COMMAND
${PYTHON3_EXECUTABLE} -c "import yarp;"
RESULT_VARIABLE YARP_PY_ERR
)
if (YARP_PY_ERR)
MESSAGE(FATAL_ERROR "BUILD_YARP_SUPPORT is required, but '${PYTHON3_EXECUTABLE}' can't find yarp python binding")
endif (YARP_PY_ERR)
endif(BUILD_YARP2_SUPPORT)
# check to make sure pymoos is installed
if (BUILD_MOOS_SUPPORT)
EXECUTE_PROCESS(COMMAND
${PYTHON3_EXECUTABLE} -c "import pymoos.MOOSCommClient;"
RESULT_VARIABLE MOOS_PY_ERR
)
if (MOOS_PY_ERR)
#message(${MOOS_PY_ERR})
#MESSAGE(FATAL_ERROR "BUILD_MOOS_SUPPORT is required, but '${PYTHON3_EXECUTABLE}' can't find MOOS python binding")
endif (MOOS_PY_ERR)
endif(BUILD_MOOS_SUPPORT)
IF (BUILD_POCOLIBS_SUPPORT)
pkg_check_modules(POCOLIBS REQUIRED pocolibs)
find_package(SWIG REQUIRED 2.0.4)
endif(BUILD_POCOLIBS_SUPPORT)
if (BUILD_HLA_SUPPORT)
EXECUTE_PROCESS(COMMAND
${PYTHON3_EXECUTABLE} -c "import hla;"
RESULT_VARIABLE HLA_PY_ERR
)
if (HLA_PY_ERR)
MESSAGE(FATAL_ERROR "BUILD_HLA_SUPPORT is required, but '${PYTHON3_EXECUTABLE}' can't find 'hla' python binding")
endif (HLA_PY_ERR)
endif(BUILD_HLA_SUPPORT)
ADD_SUBDIRECTORY(src)
IF(BUILD_CORE_SUPPORT)
INSTALL (DIRECTORY data examples addons
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/morse
REGEX .*blend.$ EXCLUDE
REGEX .*py.$ EXCLUDE
REGEX .*clients.* EXCLUDE
)
IF(WIN32)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/bin/morse.in
${CMAKE_CURRENT_BINARY_DIR}/bin/morserun.py
)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/bin/multinode_server.in
${CMAKE_CURRENT_BINARY_DIR}/bin/multinode_server.py
)
INSTALL(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/bin/morserun.py
${CMAKE_CURRENT_BINARY_DIR}/bin/multinode_server.py
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
ELSE(WIN32)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/bin/morse.in
${CMAKE_CURRENT_BINARY_DIR}/bin/morse
)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/bin/morseexec.in
${CMAKE_CURRENT_BINARY_DIR}/bin/morseexec
)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/bin/multinode_server.in
${CMAKE_CURRENT_BINARY_DIR}/bin/multinode_server
)
INSTALL(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/bin/morse
${CMAKE_CURRENT_BINARY_DIR}/bin/morseexec
${CMAKE_CURRENT_BINARY_DIR}/bin/multinode_server
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
ENDIF(WIN32)
ENDIF()
ADD_SUBDIRECTORY(bindings)
###### Testing ######
enable_testing()
ADD_SUBDIRECTORY(testing)
IF (BUILD_DOC_SUPPORT)
### Doc target ###
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/doc/conf.py.in
${CMAKE_CURRENT_BINARY_DIR}/doc/conf.py
)
FIND_PROGRAM(SPHINX_BUILD NAMES sphinx-build)
IF (NOT SPHINX_BUILD)
MESSAGE(FATAL_ERROR "Can't find sphinx-build : will not build the documentation")
ELSE()
SET (SPHINX_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/html)
SET (SPHINX_LATEX_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/tex)
SET (SPHINX_MAN_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/man)
SET (SPHINX_BUILD_ENV env PYTHONPATH=$$PYTHONPATH:${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}/src ${SPHINX_BUILD})
ADD_CUSTOM_TARGET(
doc ALL
COMMAND ${SPHINX_BUILD_ENV} -b html
-c ${CMAKE_CURRENT_BINARY_DIR}/doc
${CMAKE_CURRENT_SOURCE_DIR}/doc/morse
${SPHINX_OUTPUT}
)
ADD_DEPENDENCIES(doc revisiontag)
FIND_PROGRAM(GZIP NAMES gzip)
IF (NOT GZIP)
MESSAGE(STATUS "Can't find gzip : will not build man pages")
ELSE()
ADD_CUSTOM_TARGET(man ALL COMMAND ${SPHINX_BUILD_ENV} -b man
-c ${CMAKE_CURRENT_BINARY_DIR}/doc
${CMAKE_CURRENT_SOURCE_DIR}/doc/man
${SPHINX_MAN_OUTPUT} &&
${GZIP} -f ${SPHINX_MAN_OUTPUT}/*.1)
INSTALL(FILES ${SPHINX_MAN_OUTPUT}/morse.1.gz ${SPHINX_MAN_OUTPUT}/morseexec.1.gz ${SPHINX_MAN_OUTPUT}/multinode_server.1.gz
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
)
ENDIF()
INSTALL(DIRECTORY ${SPHINX_OUTPUT}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/morse
REGEX .doctrees.* EXCLUDE
REGEX _sources.* EXCLUDE
REGEX .*.inv EXCLUDE
REGEX .buildinfo EXCLUDE
)
ADD_CUSTOM_TARGET(
latex_doc
COMMAND ${SPHINX_BUILD_ENV} -b latex
-c ${CMAKE_CURRENT_BINARY_DIR}/doc/
${CMAKE_CURRENT_SOURCE_DIR}/doc/morse
${SPHINX_LATEX_OUTPUT}
)
ENDIF()
ENDIF()
### CPack ###
EXECUTE_PROCESS(COMMAND
which dpkg
OUTPUT_VARIABLE SYSTEST_DPKG)
EXECUTE_PROCESS(COMMAND
which rpm
OUTPUT_VARIABLE SYSTEST_RPM)
IF (SYSTEST_DPKG)
SET(CPACK_GENERATOR "DEB")
ELSEIF (SYSTEST_RPM)
SET(CPACK_GENERATOR "RPM")
ELSE ()
SET(CPACK_GENERATOR "TGZ")
ENDIF()
# TODO find a better way to check debian or redhat ?
SET(CPACK_PACKAGE_CONTACT "morse-users <morse-users@laas.fr>")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MORSE the Open Robots Simulator")
SET(CPACK_PACKAGE_NAME "openrobots-morse")
SET(CPACK_PACKAGE_VENDOR "CNRS/LAAS")
SET(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "python3.2-dev")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://morse.openrobots.org")
INCLUDE(CPack)
### Uninstall ###
configure_file("${CMAKE_HOME_DIRECTORY}/config/cmake_uninstall.cmake.in" "cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "cmake_uninstall.cmake")