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.

AddOpenViBESDKComponents.cmake 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. # ---------------------------------
  2. # Finds OpenViBE SDK binary distribution
  3. # Adds library to target, include path and execute install commands
  4. # Also add library specific compiler flags
  5. # This should be used with a defined INCLUDED_OV_SDK_COMPONENTS variable in scope
  6. # Value should be a list of libraries to include
  7. # They are organized into groups, and group name can also be used to add all members of said group
  8. # This include :
  9. # ALL : will include groups BASE, ALLPLUGINS and ALLMODULES
  10. # BASE : MAIN KERNEL
  11. # ALLPLUGINS : CLASSIFICATION DATA_GENERATION FEATURE_EXTRACTION FILE_IO SIGNAL_PROCESSING STIMULATION STREAM_CODECS STREAMING TOOLS
  12. # ALLMODULES : EBML SYSTEM FS SOCKET XML DATE CSV TOOLKIT
  13. # ---------------------------------
  14. option(DYNAMIC_LINK_OPENVIBE_SDK "Dynamically link OpenViBE SDK" ON)
  15. if(NOT CMAKE_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio*")
  16. set(MULTI_BUILD TRUE)
  17. elseif(CMAKE_BUILD_TYPE AND OV_PACKAGE)
  18. set(SOLO_PACKAGE TRUE)
  19. elseif(CMAKE_BUILD_TYPE)
  20. set(SOLO_BUILD TRUE)
  21. else()
  22. message(FATAL_ERROR "Build should specify a type or use a multi-type generator (like Visual Studio)")
  23. endif()
  24. include_directories(${OPENVIBE_SDK_PATH}/include/)# TODO ?
  25. if(DYNAMIC_LINK_OPENVIBE_SDK)
  26. set(OPENVIBE_SDK_LINKING "")
  27. set(LINKING_SUFFIX Shared)
  28. add_definitions(-DOV_Shared)
  29. else()
  30. set(OPENVIBE_SDK_LINKING "-static")
  31. set(LINKING_SUFFIX Static)
  32. endif()
  33. if("${INCLUDED_OV_SDK_COMPONENTS}" STREQUAL "ALL")
  34. list(REMOVE_ITEM INCLUDED_OV_SDK_COMPONENTS "ALL")
  35. list(APPEND INCLUDED_OV_SDK_COMPONENTS BASE ALLPLUGINS ALLMODULES)
  36. endif()
  37. if(BASE IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  38. list(REMOVE_ITEM INCLUDED_OV_SDK_COMPONENTS BASE)
  39. list(APPEND INCLUDED_OV_SDK_COMPONENTS MAIN KERNEL)
  40. endif()
  41. if(ALLPLUGINS IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  42. list(REMOVE_ITEM INCLUDED_OV_SDK_COMPONENTS ALLPLUGINS)
  43. list(APPEND INCLUDED_OV_SDK_COMPONENTS CLASSIFICATION DATA_GENERATION FEATURE_EXTRACTION FILE_IO SIGNAL_PROCESSING STIMULATION STREAM_CODECS STREAMING TOOLS)
  44. endif()
  45. if(ALLMODULES IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  46. list(REMOVE_ITEM INCLUDED_OV_SDK_COMPONENTS ALLMODULES)
  47. list(APPEND INCLUDED_OV_SDK_COMPONENTS EBML SYSTEM FS SOCKET XML DATE CSV TOOLKIT COMMUNICATION)
  48. endif()
  49. if(WIN32)
  50. set(LIB_PREFIX "")
  51. set(ORIG_LIB_DIR bin)
  52. set(DEST_LIB_DIR ${DIST_BINDIR})
  53. set(LIB_EXT lib)
  54. set(DLL_EXT dll)
  55. set(EXE_EXT .exe)
  56. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  57. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  58. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  59. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/ DESTINATION ${DIST_BINDIR} CONFIGURATIONS ${OUTPUTCONFIG} FILES_MATCHING PATTERN "*cmd")
  60. endforeach()
  61. else()
  62. install(DIRECTORY ${OPENVIBE_SDK_PATH}/bin/ DESTINATION ${DIST_BINDIR} FILES_MATCHING PATTERN "*cmd")
  63. endif()
  64. elseif(UNIX)
  65. set(LIB_PREFIX lib)
  66. set(ORIG_LIB_DIR lib)
  67. set(DEST_LIB_DIR ${DIST_LIBDIR})
  68. if(DYNAMIC_LINK_OPENVIBE_SDK)
  69. set(LIB_EXT "so")
  70. if(APPLE)
  71. set(LIB_EXT "dylib")
  72. endif()
  73. else()
  74. set(LIB_EXT "a")
  75. endif()
  76. set(DLL_EXT "${LIB_EXT}*")
  77. set(EXE_EXT "")
  78. endif()
  79. function(add_component TOKEN MODULE_NAME)
  80. if(${TOKEN} IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  81. target_link_libraries(${PROJECT_NAME} "${OPENVIBE_SDK_PATH}/lib/${LIB_PREFIX}${MODULE_NAME}${OPENVIBE_SDK_LINKING}.${LIB_EXT}")
  82. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  83. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  84. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  85. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/${ORIG_LIB_DIR}/ DESTINATION ${DEST_LIB_DIR} CONFIGURATIONS ${OUTPUTCONFIG} FILES_MATCHING PATTERN "*${MODULE_NAME}*${DLL_EXT}")
  86. endforeach()
  87. else()
  88. install(DIRECTORY ${OPENVIBE_SDK_PATH}/${ORIG_LIB_DIR}/ DESTINATION ${DEST_LIB_DIR} FILES_MATCHING PATTERN "*${MODULE_NAME}*${DLL_EXT}")
  89. endif()
  90. set(FLAGS_LIST ${ARGV})
  91. list(REMOVE_AT FLAGS_LIST 0 1) # Remove mandatory args to get only optional args
  92. foreach(COMPILE_FLAG IN LISTS FLAGS_LIST)
  93. add_definitions(-D${COMPILE_FLAG})
  94. endforeach()
  95. endif()
  96. endfunction(add_component)
  97. function(add_plugin TOKEN MODULE_NAME)
  98. if(${TOKEN} IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  99. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  100. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  101. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  102. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/${ORIG_LIB_DIR}/ DESTINATION ${DEST_LIB_DIR} CONFIGURATIONS ${OUTPUTCONFIG} FILES_MATCHING PATTERN "*${MODULE_NAME}*${DLL_EXT}")
  103. endforeach()
  104. else()
  105. install(DIRECTORY ${OPENVIBE_SDK_PATH}/${ORIG_LIB_DIR}/ DESTINATION ${DEST_LIB_DIR} FILES_MATCHING PATTERN "*${MODULE_NAME}*${DLL_EXT}")
  106. endif()
  107. endif()
  108. endfunction(add_plugin)
  109. add_component(MAIN "openvibe" "TARGET_HAS_OpenViBE")
  110. add_component(KERNEL "openvibe-kernel") #TODO TARGET_HAS_
  111. add_component(TOOLKIT "openvibe-toolkit" "TARGET_HAS_OpenViBEToolkit" "OVTK_${LINKING_SUFFIX}")
  112. #modules
  113. add_component(EBML "openvibe-module-ebml" "TARGET_HAS_EBML" "EBML_${LINKING_SUFFIX}")
  114. add_component(SYSTEM "openvibe-module-system" "TARGET_HAS_System" "System_${LINKING_SUFFIX}")
  115. add_component(FS "openvibe-module-fs" "TARGET_HAS_FS" "FS_${LINKING_SUFFIX}")
  116. add_component(SOCKET "openvibe-module-socket" "TARGET_HAS_Socket" "Socket_${LINKING_SUFFIX}")
  117. add_component(XML "openvibe-module-xml" "TARGET_HAS_XML" "XML_${LINKING_SUFFIX}")
  118. add_component(CSV "openvibe-module-csv" "TARGET_HAS_CSV" "CSV_${LINKING_SUFFIX}")
  119. add_component(DATE "openvibe-module-date" "TARGET_HAS_DATE" "DATE_${LINKING_SUFFIX}")
  120. add_component(COMMUNICATION "openvibe-module-communication" "TARGET_HAS_COMMUNICATION" "COMMUNICATION_${LINKING_SUFFIX}")
  121. #plugins
  122. add_plugin(CLASSIFICATION "openvibe-plugins-base-classification")
  123. add_plugin(DATA_GENERATION "openvibe-plugins-base-data-generation")
  124. add_plugin(FEATURE_EXTRACTION "openvibe-plugins-base-feature-extraction")
  125. add_plugin(FILE_IO "openvibe-plugins-base-file-io")
  126. add_plugin(SIGNAL_PROCESSING "openvibe-plugins-base-signal-processing")
  127. add_plugin(STIMULATION "openvibe-plugins-base-stimulation")
  128. add_plugin(STREAM_CODECS "openvibe-plugins-base-stream-codecs")
  129. add_plugin(STREAMING "openvibe-plugins-base-streaming")
  130. add_plugin(TOOLS "openvibe-plugins-base-tools")
  131. add_definitions(-DTARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines)
  132. # Install binary dependencies if requested
  133. if(DEPENDENCIES IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  134. if(WIN32)
  135. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  136. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  137. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  138. install(FILES
  139. ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/libexpat.dll
  140. ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/xerces-c_3_1.dll
  141. ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/xerces-c_3_1D.dll
  142. DESTINATION ${DEST_LIB_DIR} CONFIGURATIONS ${OUTPUTCONFIG})
  143. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/include/ DESTINATION ${DIST_INCLUDEDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  144. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/lib/ DESTINATION ${DIST_LIBDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  145. endforeach()
  146. else()
  147. install(FILES
  148. ${OPENVIBE_SDK_PATH}/bin/libexpat.dll
  149. ${OPENVIBE_SDK_PATH}/bin/xerces-c_3_1.dll
  150. ${OPENVIBE_SDK_PATH}/bin/xerces-c_3_1D.dll
  151. DESTINATION ${DEST_LIB_DIR})
  152. install(DIRECTORY ${OPENVIBE_SDK_PATH}/include/ DESTINATION ${DIST_INCLUDEDIR})
  153. install(DIRECTORY ${OPENVIBE_SDK_PATH}/lib/ DESTINATION ${DIST_LIBDIR})
  154. endif()
  155. endif()
  156. endif()
  157. # Install applications if required
  158. if(DEVELOPER_TOOLS IN_LIST INCLUDED_OV_SDK_COMPONENTS)
  159. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  160. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  161. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  162. install(FILES
  163. ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/openvibe-id-generator${EXE_EXT}
  164. ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/openvibe-plugin-inspector${EXE_EXT}
  165. DESTINATION ${DIST_BINDIR} CONFIGURATIONS ${OUTPUTCONFIG} FILE_PERMISSIONS OWNER_EXECUTE)
  166. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/include/ DESTINATION ${DIST_INCLUDEDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  167. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/lib/ DESTINATION ${DIST_BINDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  168. endforeach()
  169. else()
  170. install(FILES
  171. ${OPENVIBE_SDK_PATH}/bin/openvibe-id-generator${EXE_EXT}
  172. ${OPENVIBE_SDK_PATH}/bin/openvibe-plugin-inspector${EXE_EXT}
  173. DESTINATION ${DIST_BINDIR} PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
  174. install(DIRECTORY ${OPENVIBE_SDK_PATH}/include/ DESTINATION ${DIST_INCLUDEDIR})
  175. install(DIRECTORY ${OPENVIBE_SDK_PATH}/lib/ DESTINATION ${DIST_BINDIR})
  176. endif()
  177. endif()
  178. # if we link with the module socket in Static, we must link the project with the dependency on win32
  179. if(WIN32 AND SOCKET IN_LIST INCLUDED_OV_SDK_COMPONENTS AND NOT DYNAMIC_LINK_OPENVIBE_SDK)
  180. include("FindThirdPartyWinsock2")
  181. include("FindThirdPartyFTDI")
  182. endif()
  183. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  184. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  185. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  186. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/share/ DESTINATION ${DIST_DATADIR} CONFIGURATIONS ${OUTPUTCONFIG})
  187. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin/
  188. USE_SOURCE_PERMISSIONS
  189. DESTINATION ${DIST_BINDIR}
  190. CONFIGURATIONS ${OUTPUTCONFIG}
  191. FILES_MATCHING PATTERN "*example*")
  192. endforeach()
  193. else()
  194. install(DIRECTORY ${OPENVIBE_SDK_PATH}/share/ DESTINATION ${DIST_DATADIR})
  195. install(DIRECTORY ${OPENVIBE_SDK_PATH}/bin/
  196. USE_SOURCE_PERMISSIONS
  197. DESTINATION ${DIST_BINDIR}
  198. FILES_MATCHING PATTERN "*example*")
  199. endif()