Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 293 lines (245 sloc) 10.197 kb
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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
cmake_minimum_required(VERSION 2.6)

set(PACKAGE_NAME morse)
set(PACKAGE_VERSION "1.2")

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

set(PythonInterp_FIND_VERSION 3.2)
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)

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)

if (BUILD_YARP2_SUPPORT)
EXECUTE_PROCESS(COMMAND
${PYTHON_EXECUTABLE} -c "import yarp;"
RESULT_VARIABLE YARP_PY_ERR
)
if (YARP_PY_ERR)
MESSAGE(FATAL_ERROR "BUILD_YARP_SUPPORT is required, but '${PYTHON_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
${PYTHON_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 '${PYTHON_EXECUTABLE}' can't find MOOS python binding")
endif (MOOS_PY_ERR)
endif(BUILD_MOOS_SUPPORT)

if (BUILD_HLA_SUPPORT)
EXECUTE_PROCESS(COMMAND
${PYTHON_EXECUTABLE} -c "import hla;"
RESULT_VARIABLE HLA_PY_ERR
)
if (HLA_PY_ERR)
MESSAGE(FATAL_ERROR "BUILD_HLA_SUPPORT is required, but '${PYTHON_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/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
)
INSTALL(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/bin/morse
${CMAKE_CURRENT_BINARY_DIR}/bin/morseexec
${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" ${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 touch ${SPHINX_FALSE_PYTHON_ENV}/yarp.py
)

FILE(WRITE ${SPHINX_FALSE_PYTHON_ENV}/hla/omt.py "HLAfloat32LE=0\ndef HLAfixedArray(x,y,z):\n pass")
FILE(WRITE ${SPHINX_FALSE_PYTHON_ENV}/hla/rti.py "class FederateAmbassador:\n pass")

# 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 ${SPHINX_FALSE_PYTHON_ENV}/hla/omt.py)


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}/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")

Something went wrong with that request. Please try again.