You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. CMAKE_MINIMUM_REQUIRED(VERSION 3.4)
  2. cmake_policy(SET CMP0026 OLD)
  3. cmake_policy(SET CMP0039 NEW)
  4. cmake_policy(SET CMP0042 OLD)
  5. cmake_policy(SET CMP0043 OLD)
  6. cmake_policy(SET CMP0045 OLD)
  7. cmake_policy(SET CMP0048 OLD)
  8. cmake_policy(SET CMP0057 NEW)
  9. PROJECT(Designer)
  10. SET(CMAKE_INSTALL_LIBDIR lib) # Fix for non debian-based distrib, as it seeems to be a common occurence to name this folder lib32/lib64
  11. LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules")
  12. # OpenViBE-specific helper functions that are used by the CMakeLists of the subprojects.
  13. INCLUDE("OvAddProjects")
  14. INCLUDE("OvInstallLaunchScript")
  15. INCLUDE("OvLinkBoostLib")
  16. INCLUDE("OvDelayLoad")
  17. INCLUDE("SetProjectVersion")
  18. INCLUDE("Utilities") # Include functions debug_message, SET_BUILD_PLATFORM
  19. # ----------------------
  20. # Build CMake flags
  21. # ----------------------
  22. OPTION(Flag_VerboseOutput "Verbose CMake output" OFF)
  23. SET(OEM_DISTRIBUTION "openvibe" CACHE STRING "The OEM distribution for this build, can be openvibe or mensia")
  24. OPTION(OV_DISPLAY_ERROR_LOCATION ON)
  25. SET(OV_SOURCE_DEPENDENCIES_PATH "${CMAKE_SOURCE_DIR}/dependencies-source")
  26. SET(OV_ICON_PATH "${CMAKE_SOURCE_DIR}/scripts/icons")
  27. if(NOT(${Flag_VerboseOutput}))
  28. set(CMAKE_INSTALL_MESSAGE LAZY)
  29. endif()
  30. IF(WIN32)
  31. IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  32. SET(OV_DEPENDENCIES_PLATFORM_FOLDER_NAME "dependencies_x64")
  33. ELSEIF("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
  34. SET(OV_DEPENDENCIES_PLATFORM_FOLDER_NAME "dependencies")
  35. ELSE()
  36. SET(OV_DEPENDENCIES_PLATFORM_FOLDER_NAME "dependencies")
  37. ENDIF()
  38. ELSE()
  39. SET(OV_DEPENDENCIES_PLATFORM_FOLDER_NAME "dependencies")
  40. ENDIF()
  41. LIST(APPEND LIST_DEPENDENCIES_PATH "${CMAKE_SOURCE_DIR}/${OV_DEPENDENCIES_PLATFORM_FOLDER_NAME}")
  42. # ----------------------
  43. # Set build version
  44. # ----------------------
  45. # These versions are used by the subprojects by default.
  46. set_version()
  47. # Sets the PROJECT_VERSION variable to something, depending on overriding OvSetProjectVersion.cmake files
  48. SET_PROJECT_VERSION()
  49. MESSAGE(STATUS "BUILDING VERSION Designer: ${OV_GLOBAL_VERSION_STRING} Branch : ${OV_PROJECT_BRANCH}~${OV_PROJECT_COMMITHASH}. Based on OpenViBE SDK: ${OV_SDK_VERSION_STRING}")
  50. # Sort target into directories for better visualization in IDE
  51. SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
  52. SET(APP_FOLDER Applications)
  53. SET(MODULES_FOLDER Modules)
  54. SET(PLUGINS_FOLDER Plugins)
  55. SET(TESTS_FOLDER Unit-Tests)
  56. SET(VALIDATION_FOLDER Validation-Tests)
  57. IF(NOT CMAKE_INSTALL_PREFIX)
  58. # Default is to build to dist/. If you wish a custom install, set your own MAKE_INSTALL_PREFIX when you call CMake. Safest to do under a fakeroot.
  59. SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/dist")
  60. ENDIF()
  61. IF(NOT DEFINED OV_PACKAGE)
  62. SET(OV_PACKAGE FALSE)
  63. ENDIF()
  64. # Setup knowledge of GNU-style install path variables
  65. INCLUDE("GNUInstallDirs")
  66. if(NOT CMAKE_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio*")
  67. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_INSTALL_PREFIX}/bin" )
  68. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib" )
  69. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  70. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  71. string(CONCAT DIST_ROOT ${DIST_ROOT} $<$<CONFIG:${OUTPUTCONFIGU}>:${CMAKE_INSTALL_PREFIX}/${OUTPUTCONFIG}>)
  72. set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIGU} "${CMAKE_INSTALL_PREFIX}/${OUTPUTCONFIG}/bin" )
  73. set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIGU} "${CMAKE_INSTALL_PREFIX}/${OUTPUTCONFIG}/lib" )
  74. endforeach()
  75. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "OV_CMAKE_PATH_ROOT=\"${DIST_ROOT}\"")
  76. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "OV_CMAKE_PATH_BIN=\"${DIST_ROOT}/bin\"")
  77. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "OV_CMAKE_PATH_LIB=\"${DIST_ROOT}/lib\"")
  78. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "OV_CMAKE_PATH_DATA=\"${DIST_ROOT}/share/openvibe\"")
  79. set(DIST_BINDIR ${DIST_ROOT}/bin)
  80. set(DIST_LIBDIR ${DIST_ROOT}/lib)
  81. set(DIST_INCLUDEDIR ${DIST_ROOT}/include)
  82. set(DIST_DATADIR ${DIST_ROOT}/share)
  83. set(DIST_DOCDIR ${DIST_ROOT}/doc)
  84. set(DIST_DOCTMP ${DIST_ROOT}/doc-tmp)
  85. set(DIST_SYSCONFDIR ${DIST_ROOT}/etc)
  86. # Install the .install file inside the dists folders
  87. install(FILES ${CMAKE_BINARY_DIR}/.install DESTINATION ${DIST_ROOT})
  88. elseif(CMAKE_BUILD_TYPE AND OV_PACKAGE)
  89. # Add directories that OpenViBE will use to look for its components runtime, unless overridden by environment variables in the launch scripts.
  90. # These defines should only be used in "openvibe/ov_directories.h".
  91. add_definitions(-DOV_CMAKE_PATH_ROOT="${CMAKE_INSTALL_PREFIX}")
  92. add_definitions(-DOV_CMAKE_PATH_BIN="${CMAKE_INSTALL_FULL_BINDIR}")
  93. add_definitions(-DOV_CMAKE_PATH_LIB="${CMAKE_INSTALL_FULL_LIBDIR}")
  94. add_definitions(-DOV_CMAKE_PATH_DATA="${CMAKE_INSTALL_FULL_DATADIR}/openvibe")
  95. set(CMAKE_INSTALL_PREFIX .)
  96. set(DIST_ROOT ${CMAKE_INSTALL_PREFIX})
  97. set(DIST_BINDIR ${CMAKE_INSTALL_BINDIR})
  98. set(DIST_LIBDIR ${CMAKE_INSTALL_LIBDIR})
  99. set(DIST_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
  100. set(DIST_DATADIR ${CMAKE_INSTALL_DATADIR})
  101. set(DIST_DOCDIR ${DIST_ROOT}/doc)
  102. set(DIST_DOCTMP ${DIST_ROOT}/doc-tmp)
  103. set(DIST_SYSCONFDIR ${CMAKE_INSTALL_SYSCONFDIR})
  104. set(CPACK_GENERATOR "ZIP")
  105. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
  106. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenViBE Designer")
  107. set(CPACK_PACKAGE_VENDOR "Inria & Mensia Technologies")
  108. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
  109. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.md")
  110. set(CPACK_PACKAGE_VERSION ${OV_GLOBAL_VERSION_MAJOR}.${OV_GLOBAL_VERSION_MINOR}.${OV_GLOBAL_VERSION_PATCH}.${OV_GLOBAL_VERSION_BUILD})
  111. set(CPACK_PACKAGE_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
  112. set(CPACK_PACKAGE_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR})
  113. set(CPACK_PACKAGE_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH})
  114. if(UNIX)
  115. execute_process(COMMAND bash -c "echo -n $(lsb_release -i -s)$(lsb_release -r -s)"
  116. OUTPUT_VARIABLE CPACK_SYSTEM_NAME)
  117. endif()
  118. IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  119. SET(PLATFORM_TARGET "x64")
  120. ELSEIF("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
  121. SET(PLATFORM_TARGET "x86")
  122. ELSE()
  123. SET(PLATFORM_TARGET "Unknown")
  124. ENDIF()
  125. set(CPACK_PACKAGE_NAME "OpenViBE${CMAKE_PROJECT_NAME}-${CMAKE_BUILD_TYPE}-${PLATFORM_TARGET}")
  126. include(CPack)
  127. elseif(CMAKE_BUILD_TYPE)
  128. # Add directories that OpenViBE will use to look for its components runtime, unless overridden by environment variables in the launch scripts.
  129. # These defines should only be used in "openvibe/ov_directories.h".
  130. add_definitions(-DOV_CMAKE_PATH_ROOT="${CMAKE_INSTALL_PREFIX}")
  131. add_definitions(-DOV_CMAKE_PATH_BIN="${CMAKE_INSTALL_FULL_BINDIR}")
  132. add_definitions(-DOV_CMAKE_PATH_LIB="${CMAKE_INSTALL_FULL_LIBDIR}")
  133. add_definitions(-DOV_CMAKE_PATH_DATA="${CMAKE_INSTALL_FULL_DATADIR}/openvibe")
  134. set(DIST_ROOT ${CMAKE_INSTALL_PREFIX})
  135. set(DIST_BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
  136. set(DIST_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
  137. set(DIST_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR})
  138. set(DIST_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
  139. set(DIST_DOCDIR ${DIST_ROOT}/doc)
  140. set(DIST_DOCTMP ${DIST_ROOT}/doc-tmp)
  141. set(DIST_SYSCONFDIR ${CMAKE_INSTALL_FULL_SYSCONFDIR})
  142. else()
  143. message(FATAL_ERROR "Build should specify a type or use a multi-type generator (like Visual Studio)")
  144. endif()
  145. find_path(SDK_MODULE_PATH NAMES "AddOpenViBESDKComponents.cmake" PATHS ${OPENVIBE_SDK_PATH} PATH_SUFFIXES share NO_DEFAULT_PATH) # Finds multi-type builds
  146. if(CMAKE_BUILD_TYPE)
  147. string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
  148. find_path(SDK_MODULE_PATH NAMES AddOpenViBESDKComponents.cmake PATHS ${OPENVIBE_SDK_PATH};${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openvibe-sdk-${CMAKE_BUILD_TYPE_LOWER}/share NO_DEFAULT_PATH) # Find "regular builds
  149. else()
  150. find_path(SDK_MODULE_PATH NAMES "AddOpenViBESDKComponents.cmake" PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openvibe-sdk-Debug/share openvibe-sdk-Release/share NO_DEFAULT_PATH) # Finds multi-type builds
  151. endif()
  152. if(SDK_MODULE_PATH)
  153. LIST(APPEND CMAKE_MODULE_PATH ${SDK_MODULE_PATH})
  154. endif()
  155. include(FindOVSDK)
  156. # include(AddOpenViBESDKComponents)
  157. # OpenViBE SDK modules list
  158. SET(INCLUDED_OV_SDK_COMPONENTS BASE ALLPLUGINS EBML SYSTEM FS XML TOOLKIT)
  159. string(TIMESTAMP COPYRIGHT_DATE "2012-%Y")
  160. # We deduce the branding from the OEM_DISTRIBUTION
  161. IF(OEM_DISTRIBUTION STREQUAL "openvibe")
  162. SET(OV_CONFIG_SUBDIR "OpenVIBE" CACHE STRING "Subdirectory under user directory when configuration and logs will be saved")
  163. SET(BRAND_NAME "OpenViBE")
  164. SET(COMPANY_NAME "Inria")
  165. SET(DESIGNER_NAME "Designer")
  166. SET(LICENCE_TEXT "\
  167. This program is free software: you can redistribute it and/or modify\
  168. it under the terms of the GNU Affero General Public License as\
  169. published by the Free Software Foundation, either version 3 of the\
  170. License, or (at your option) any later version.\
  171. \
  172. This program is distributed in the hope that it will be useful, but\
  173. WITHOUT ANY WARRANTY; without even the implied warranty of\
  174. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\
  175. Affero General Public License for more details.\
  176. \
  177. You should have received a copy of the GNU Affero General Public\
  178. License along with this program. If not, see http://www.gnu.org/licenses/ .")
  179. ELSEIF(OEM_DISTRIBUTION STREQUAL "mensia")
  180. SET(OV_CONFIG_SUBDIR "mensia" CACHE STRING "Subdirectory under user directory when configuration and logs will be saved")
  181. SET(BRAND_NAME "NeuroRT")
  182. SET(DESIGNER_NAME "Studio")
  183. SET(COMPANY_NAME "Mensia Technologies SA")
  184. ADD_DEFINITIONS(-DMENSIA_DISTRIBUTION)
  185. ELSE()
  186. MESSAGE(FATAL_ERROR "OEM_DISTRIBUTION unrecognized (${OEM_DISTRIBUTION}) ! CMake cannot deduce the brand and product names. ")
  187. ENDIF()
  188. IF(OV_DISPLAY_ERROR_LOCATION)
  189. ADD_DEFINITIONS(-DOV_DISPLAY_ERROR_LOCATION)
  190. ENDIF()
  191. # The user files will be stored in .../OV_CONFIG_SUBDIR folder
  192. ADD_DEFINITIONS("-DOV_PROJECT_NAME=\"openvibe\"")
  193. ADD_DEFINITIONS("-DOV_CONFIG_SUBDIR=\"${OV_CONFIG_SUBDIR}\"")
  194. set(CMAKE_CXX_STANDARD 11)
  195. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  196. IF(WIN32)
  197. ADD_DEFINITIONS("-DNOMINMAX -DBOOST_ALL_NO_LIB")
  198. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4355")
  199. SET(OV_WIN32_BOOST_VERSION "1_58")
  200. ELSEIF(APPLE)
  201. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  202. ELSEIF(UNIX)
  203. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  204. FIND_PATH(PKGCONFIG_PATH lib/pkgconfig/atk.pc PATHS ${LIST_DEPENDENCIES_PATH})
  205. SET(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_PATH}/lib/pkgconfig")
  206. ELSE(WIN32)
  207. MESSAGE(WARNING "Warning: unknown platform")
  208. ENDIF(WIN32)
  209. # Print the used compilation parameters (for transparency)
  210. GET_DIRECTORY_PROPERTY(TMP_DEFINITIONS COMPILE_DEFINITIONS)
  211. debug_message("Compilation flags used at source root: ")
  212. debug_message(" COMPILE_DEFINITIONS = '${TMP_DEFINITIONS}'")
  213. debug_message(" CMAKE_CXX_FLAGS = '${CMAKE_CXX_FLAGS}'")
  214. debug_message(" CMAKE_CXX_FLAGS_RELEASE = '${CMAKE_CXX_FLAGS_RELEASE}'")
  215. debug_message(" CMAKE_CXX_FLAGS_DEBUG = '${CMAKE_CXX_FLAGS_DEBUG}'")
  216. # if no specific branch has been given for an openvibe component, default is to compile its trunk folder
  217. ## SET(OV_TRUNK "trunc")
  218. # By setting SKIP[_FOLDER]* you can skip a subtree (example: SKIP_A_B_C skips folder a/b/c and all its subfolders if any)
  219. # Custom cmakelist can be used to overwrite the default compilation & packaging parameters
  220. IF(EXISTS "${CMAKE_SOURCE_DIR}/CustomCMakeLists.txt")
  221. debug_message("Found custom build settings")
  222. INCLUDE("${CMAKE_SOURCE_DIR}/CustomCMakeLists.txt")
  223. ENDIF()
  224. #################################################################
  225. string(TOLOWER ${BRAND_NAME} LOWER_BRAND_NAME)
  226. string(TOLOWER ${DESIGNER_NAME} LOWER_DESIGNER_NAME)
  227. ADD_DEFINITIONS(-DBRAND_NAME="${BRAND_NAME}")
  228. ADD_DEFINITIONS(-DDESIGNER_NAME="${DESIGNER_NAME}")
  229. #################################################################
  230. SET(OV_LAUNCHER_SOURCE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules/launchers")
  231. # a list of all project which will be filled by the directory traversal. This is needed to generate the documentation.
  232. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS "")
  233. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR "")
  234. # Used by the various Find* scripts to locate OpenViBE modules
  235. SET(OV_BASE_DIR ${CMAKE_SOURCE_DIR})
  236. # needed for making visual studio projects when this script is called without CMAKE_BUILD_TYPE
  237. SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG "TARGET_BUILDTYPE_Debug")
  238. SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE "TARGET_BUILDTYPE_Release")
  239. SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO "TARGET_BUILDTYPE_Release")
  240. MESSAGE(STATUS "Building ${BRAND_NAME} ${DESIGNER_NAME} [${OEM_DISTRIBUTION}] Version : ${PROJECT_VERSION} ${OV_PROJECT_BRANCH}~${OV_PROJECT_COMMITHASH}")
  241. # Add vendor specific installation instructions
  242. # Traverse these directories and build their components
  243. ADD_SUBDIRECTORY("documentation/")
  244. IF(NOT(SKIP_PLUGINS))
  245. ADD_SUBDIRECTORY("plugins/")
  246. ENDIF()
  247. IF(NOT(SKIP_APPLICATIONS))
  248. ADD_SUBDIRECTORY("applications/")
  249. ENDIF()
  250. IF(NOT(SKIP_LIBRARIES))
  251. ADD_SUBDIRECTORY("libraries/")
  252. ENDIF()
  253. IF(NOT(SKIP_VISUALIZATION_TOOLKIT))
  254. ADD_SUBDIRECTORY("visualization-toolkit/")
  255. ENDIF()
  256. # add the scripts to the project so IDEs using the CMake file are aware of them
  257. FILE(GLOB_RECURSE script_files scripts/*.cmd scripts/*.sh )
  258. ADD_CUSTOM_TARGET(openvibe-scripts SOURCES ${script_files})
  259. INSTALL(FILES "${CMAKE_BINARY_DIR}/.install" DESTINATION ${CMAKE_INSTALL_PREFIX})