forked from morse-simulator/morse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
183 lines (154 loc) · 5.42 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
cmake_minimum_required(VERSION 2.6)
set(PACKAGE_NAME morse)
set(PACKAGE_VERSION 0.4.99)
option(BUILD_CORE_SUPPORT "Build and install morse core" ON)
option(BUILD_DOC_SUPPORT "Build and install morse documentation (Requiere Sphinx)" ON)
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)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config/)
find_package(PkgConfig REQUIRED)
find_package(Python32Interp REQUIRED)
find_package(Python32Libs REQUIRED)
EXECUTE_PROCESS(COMMAND
${PYTHON3_EXECUTABLE} -c "import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_lib(0,0,\"\"))"
OUTPUT_VARIABLE PYTHON_INSTALL
ERROR_VARIABLE PYTHON_STDERR
RESULT_VARIABLE PYTHON_ERR
)
SET(PYTHON_INSTDIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL})
MESSAGE(STATUS "will install python files in ${PYTHON_INSTDIR}")
if (NOT PYTHON3INTERP_FOUND)
MESSAGE(FATAL_ERROR "Can't find python 3.2 on your system")
endif(NOT PYTHON3INTERP_FOUND)
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)
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)
enable_testing()
ADD_SUBDIRECTORY(testing)
IF(BUILD_CORE_SUPPORT)
INSTALL (DIRECTORY data examples
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
REGEX .*blend.$ EXCLUDE
REGEX .*py.$ EXCLUDE
REGEX .*clients.* EXCLUDE
)
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
)
INSTALL(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/bin/morse
${CMAKE_CURRENT_BINARY_DIR}/bin/morseexec
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
ENDIF()
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(STATUS "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)
ADD_CUSTOM_COMMAND(
OUTPUT ${SPHINX_OUTPUT}
COMMAND ${SPHINX_BUILD} -b html
-c ${CMAKE_CURRENT_BINARY_DIR}/doc
${CMAKE_CURRENT_SOURCE_DIR}/doc/morse
${SPHINX_OUTPUT}
)
ADD_CUSTOM_TARGET(doc ALL DEPENDS ${SPHINX_OUTPUT})
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(
force_doc
COMMAND ${SPHINX_BUILD} -b html
-c ${CMAKE_CURRENT_BINARY_DIR}/doc/
${CMAKE_CURRENT_SOURCE_DIR}/doc/morse
${SPHINX_OUTPUT}
)
ADD_CUSTOM_TARGET(
latex_doc
COMMAND ${SPHINX_BUILD} -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 <[email protected]>")
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-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")