File: CMakeLists.txt

package info (click to toggle)
morse-simulator 1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 186,952 kB
  • ctags: 3,992
  • sloc: ansic: 108,311; python: 25,692; cpp: 786; makefile: 120; xml: 34; sh: 7
file content (277 lines) | stat: -rw-r--r-- 10,129 bytes parent folder | download | duplicates (3)
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
cmake_minimum_required(VERSION 2.6)

set(PACKAGE_NAME morse)
set(PACKAGE_VERSION "1.4")

project(${PACKAGE_NAME})

# only available from cmake-2.8.4
if(COMMAND cmake_policy)
	if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 8 AND ${CMAKE_PATCH_VERSION} GREATER 3)
		cmake_policy(SET CMP0017 OLD)
	endif()
endif()


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" ON)
option(BUILD_YARP_SUPPORT "Build yarp framework support" ON)
option(BUILD_ROS_SUPPORT "Build ROS middleware support" ON)
option(BUILD_MOOS_SUPPORT "Build MOOS middleware support" ON)
option(BUILD_MAVLINK_SUPPORT "Build Mavlink middleware support" ON)
option(BUILD_HLA_SUPPORT "Build HLA middleware support. Also used for distributed HLA simulation." ON)
option(PYMORSE_SUPPORT "Build and install the Python bindings for MORSE." ON)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config/)
find_package(PkgConfig REQUIRED)

set(PythonInterp_FIND_VERSION 3.3)
find_package(PythonInterp REQUIRED)

set(PythonLibs_FIND_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
set(PythonLibs_FIND_VERSION_EXACT "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_package(PythonLibs REQUIRED)

set(ALL_C_PYTHON_MODULES "" CACHE STRING "" FORCE)

# Add python include and library directories
include_directories(${PYTHON_INCLUDE_DIRS})

EXECUTE_PROCESS(COMMAND
					${PYTHON_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)

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
   )
CONFIGURE_FILE(
   ${CMAKE_CURRENT_SOURCE_DIR}/bin/morse_sync.in
   ${CMAKE_CURRENT_BINARY_DIR}/bin/morse_sync.py
   )
INSTALL(PROGRAMS
	   ${CMAKE_CURRENT_BINARY_DIR}/bin/morse_sync.py
       ${CMAKE_CURRENT_BINARY_DIR}/bin/morserun.py
       ${CMAKE_CURRENT_SOURCE_DIR}/bin/morse_inspector
       ${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
	)
CONFIGURE_FILE(
	${CMAKE_CURRENT_SOURCE_DIR}/bin/morse_sync.in
	${CMAKE_CURRENT_BINARY_DIR}/bin/morse_sync
	)
INSTALL(PROGRAMS
		${CMAKE_CURRENT_BINARY_DIR}/bin/morse
		${CMAKE_CURRENT_BINARY_DIR}/bin/morseexec
		${CMAKE_CURRENT_BINARY_DIR}/bin/morse_sync
		${CMAKE_CURRENT_SOURCE_DIR}/bin/morse_inspector
		${CMAKE_CURRENT_BINARY_DIR}/bin/multinode_server
		DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
	    )
ENDIF(WIN32)
ENDIF()

ADD_SUBDIRECTORY(bindings)

###### Testing ######
include( CTest )
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 (CMAKE_DOC_OUT ${CMAKE_CURRENT_BINARY_DIR}/doc)
	SET (SPHINX_OUTPUT ${CMAKE_DOC_OUT}/html)
	SET (SPHINX_SRC ${CMAKE_DOC_OUT}/src)
	SET (SPHINX_LATEX_OUTPUT ${CMAKE_DOC_OUT}/tex)
	SET (SPHINX_MAN_OUTPUT ${CMAKE_DOC_OUT}/man)
	SET (SPHINX_FALSE_PYTHON_ENV ${CMAKE_CURRENT_BINARY_DIR}/fakeenv)

 	SET (PYTHON_DOC_ENV env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_BINARY_DIR}/src:${SPHINX_FALSE_PYTHON_ENV}:${CMAKE_CURRENT_SOURCE_DIR}/src:${CMAKE_CURRENT_SOURCE_DIR}/testing:${CMAKE_CURRENT_SOURCE_DIR}/bindings/pymorse/src/:$$PYTHONPATH PYTHONDONTWRITEBYTECODE="morse" MORSESOURCE=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE})
	SET (SPHINX_BUILD_ENV ${PYTHON_DOC_ENV} ${SPHINX_BUILD})

	# Copy the documentation in builddir, so we can include the generated part too
	ADD_CUSTOM_TARGET(
		copy_doc ALL
		COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/doc/morse ${SPHINX_SRC}/morse
		COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/doc/media ${SPHINX_SRC}/media
	)

	# Generate the documentation from the different components
	ADD_CUSTOM_TARGET(
		generate_doc ALL
		COMMAND ${PYTHON_DOC_ENV} ${CMAKE_CURRENT_SOURCE_DIR}/doc/tools/generate_doc
		WORKING_DIRECTORY ${SPHINX_SRC}/morse/user/
	)

	ADD_DEPENDENCIES(generate_doc copy_doc ${ALL_C_PYTHON_MODULES})

	# Populate the false python environment
	ADD_CUSTOM_TARGET(
		populate_false_env ALL
		COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_FALSE_PYTHON_ENV}
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/mathutils.py
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/bge.py
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/PhysicsConstraints.py

		COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_FALSE_PYTHON_ENV}/hla
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/hla/__init__.py

		COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_FALSE_PYTHON_ENV}/pymoos
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/pymoos/__init__.py
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/pymoos/MOOSCommClient.py

		COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_FALSE_PYTHON_ENV}/pymavlink/dialects/v10/
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/pymavlink/dialects/v10/__init__.py
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/pymavlink/dialects/v10/common.py
		COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_FALSE_PYTHON_ENV}/pymavlink/mavutil
		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/pymavlink/__init__.py

		COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/yarp.py
		COMMAND ${CMAKE_COMMAND} -DSPHINX_FALSE_PYTHON_ENV=${SPHINX_FALSE_PYTHON_ENV} -P ${CMAKE_CURRENT_SOURCE_DIR}/config/generate_false_env.cmake
	)

	# GeNoM fake stuff
	FOREACH(lib genPos lwr niut pom platine spark stereopixel viam viman)
		ADD_CUSTOM_TARGET(
			populate_false_env_${lib} ALL
			COMMAND ${CMAKE_COMMAND} -E make_directory ${SPHINX_FALSE_PYTHON_ENV}/${lib}
			COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/${lib}/struct.py
			COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_FALSE_PYTHON_ENV}/${lib}/__init__.py
		)
		ADD_DEPENDENCIES(generate_doc populate_false_env_${lib})
	ENDFOREACH()


	ADD_DEPENDENCIES(copy_doc revisiontag)


	FIND_PROGRAM(SPHINX_APIDOC NAMES sphinx-apidoc)
	IF (SPHINX_APIDOC)
		ADD_CUSTOM_TARGET(
			generate_api_doc ALL
			COMMAND ${PYTHON_DOC_ENV} ${SPHINX_APIDOC} -f -o ${SPHINX_SRC}/morse/user/code ${CMAKE_CURRENT_SOURCE_DIR}/src
			COMMAND ${PYTHON_DOC_ENV} ${SPHINX_APIDOC} -f -o ${SPHINX_SRC}/morse/user/code ${CMAKE_CURRENT_SOURCE_DIR}/testing)
	ELSE()
		ADD_CUSTOM_TARGET(
			generate_api_doc ALL
			COMMAND ${CMAKE_COMMAND} -E echo "sphinx-apidoc not found : skipping api documentation"
		)
	ENDIF()
	ADD_DEPENDENCIES(generate_api_doc copy_doc populate_false_env)

	# Generate API doc if we have the sphinx-api tool

	ADD_CUSTOM_TARGET(
		doc ALL
		COMMAND ${SPHINX_BUILD_ENV} -b html
								    -c ${CMAKE_DOC_OUT}
									${SPHINX_SRC}/morse
								    ${SPHINX_OUTPUT}
	)
	ADD_DEPENDENCIES(doc generate_doc generate_api_doc)

	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}/morse-run.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse-create.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse-import.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse-edit.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse-check.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse-add.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse-rm.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morseexec.1.gz 
					  ${SPHINX_MAN_OUTPUT}/morse_sync.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_DOC_OUT}
									${SPHINX_SRC}/morse
									${SPHINX_LATEX_OUTPUT}
	)
ENDIF()
ENDIF()


### 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")