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.

FindOVSDK.cmake 4.9KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # ---------------------------------
  2. # Finds OpenViBE SDK binary distribution
  3. # ---------------------------------
  4. if(NOT CMAKE_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio*")
  5. set(MULTI_BUILD TRUE)
  6. elseif(CMAKE_BUILD_TYPE AND OV_PACKAGE)
  7. set(SOLO_PACKAGE TRUE)
  8. elseif(CMAKE_BUILD_TYPE)
  9. set(SOLO_BUILD TRUE)
  10. else()
  11. message(FATAL_ERROR "Build should specify a type or use a multi-type generator (like Visual Studio)")
  12. endif()
  13. if(NOT DEFINED TRIED_FIND_OVSDK)
  14. if(MULTI_BUILD)
  15. set(SEEK_PATHS ${OPENVIBE_SDK_PATH};${LIST_DEPENDENCIES_PATH})
  16. unset(OPENVIBE_SDK_PATH CACHE)
  17. foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  18. # set(OPENVIBE_SDK_PATH ${OPENVIBE_SDK_PATH}/$<UPPER_CASE:$<CONFIG>>)
  19. string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU )
  20. unset(OPENVIBE_SDK_PATH_TMP CACHE)
  21. find_path(OPENVIBE_SDK_PATH_TMP include/openvibe/ov_all.h PATHS ${SEEK_PATHS} PATH_SUFFIXES openvibe-sdk-${OUTPUTCONFIG} ${OUTPUTCONFIG} NO_DEFAULT_PATH)
  22. set(OPENVIBE_SDK_PATH_${OUTPUTCONFIGU} ${OPENVIBE_SDK_PATH_TMP})
  23. if(OPENVIBE_SDK_PATH_TMP)
  24. message("Found ${OUTPUTCONFIG} of sdk at ${OPENVIBE_SDK_PATH_TMP}")
  25. string(CONCAT OPENVIBE_SDK_PATH ${OPENVIBE_SDK_PATH} $<$<CONFIG:${OUTPUTCONFIGU}>:${OPENVIBE_SDK_PATH_TMP}>)
  26. set(AT_LEAST_ONE_OV_BUILD TRUE)
  27. endif()
  28. endforeach()
  29. if(NOT DEFINED AT_LEAST_ONE_OV_BUILD)
  30. message(FATAL_ERROR "Did not find any valid build of OpenViBE SDK")
  31. endif()
  32. else() # Regular build
  33. string(TOLOWER ${CMAKE_BUILD_TYPE} OV_SDK_BUILD_TYPE)
  34. find_path(OPENVIBE_SDK_PATH include/openvibe/ov_all.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openvibe-sdk-${OV_SDK_BUILD_TYPE} NO_DEFAULT_PATH)
  35. if(NOT OPENVIBE_SDK_PATH)
  36. message(FATAL_ERROR " FAILED to find OpenViBE SDK [${OPENVIBE_SDK_PATH}]")
  37. endif()
  38. string(REGEX REPLACE "\\\\+" "/" OPENVIBE_SDK_PATH ${OPENVIBE_SDK_PATH})
  39. debug_message(" Found OpenViBE SDK... [${OPENVIBE_SDK_PATH}]")
  40. endif()
  41. set(TRIED_FIND_OVSDK TRUE)
  42. endif()
  43. if(INSTALL_SDK)
  44. if(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  45. foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
  46. string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU)
  47. file(GLOB EXE_SCRIPT_LIST "${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/*.cmd" "${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/*.sh")
  48. if(EXE_SCRIPT_LIST)
  49. foreach(SCRIPT IN LISTS EXE_SCRIPT_LIST)
  50. get_filename_component(base_name ${SCRIPT} NAME_WE)
  51. if(WIN32)
  52. set(exe_name "${base_name}.exe")
  53. else()
  54. set(exe_name ${base_name})
  55. endif()
  56. IF(WIN32)
  57. SET(SCRIPT_POSTFIX ".cmd")
  58. ELSEIF(APPLE)
  59. SET(SCRIPT_POSTFIX "-macos.sh")
  60. ELSEIF(UNIX)
  61. # Debian recommends that extensions such as .sh are not used; On Linux, scripts with such extensions shouldn't be packaged
  62. SET(SCRIPT_POSTFIX ".sh")
  63. ENDIF()
  64. IF(WIN32)
  65. SET(OV_CMD_EXECUTABLE "%OV_PATH_ROOT%/bin/${exe_name}")
  66. ENDIF()
  67. SET(SCRIPT_NAME ${base_name}${SCRIPT_POSTFIX})
  68. SET(OV_CMD_ARGS "")
  69. SET(OV_PAUSE "")
  70. CONFIGURE_FILE(${OV_LAUNCHER_SOURCE_PATH}/openvibe-launcher${SCRIPT_POSTFIX}-base ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} @ONLY)
  71. INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} DESTINATION ${DIST_ROOT})
  72. endforeach()
  73. endif()
  74. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/include DESTINATION ${DIST_INCLUDEDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  75. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/bin DESTINATION ${DIST_BINDIR} CONFIGURATIONS ${OUTPUTCONFIG}) # FILES_MATCHING PATTERN "openvibe-plugins*dll") or *so*
  76. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/lib DESTINATION ${DIST_LIBDIR} CONFIGURATIONS ${OUTPUTCONFIG}) # FILES_MATCHING PATTERN "openvibe-plugins*dll")
  77. # install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/etc DESTINATION ${DIST_SYSCONFDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  78. install(DIRECTORY ${OPENVIBE_SDK_PATH_${OUTPUTCONFIGU}}/share DESTINATION ${DIST_DATADIR} CONFIGURATIONS ${OUTPUTCONFIG})
  79. endforeach()
  80. else()
  81. file(GLOB EXE_SCRIPT_LIST "${OPENVIBE_SDK_PATH}/*.cmd" "${OPENVIBE_SDK_PATH}/*.sh")
  82. foreach(SCRIPT IN LISTS EXE_SCRIPT_LIST)
  83. get_filename_component(base_name ${SCRIPT} NAME_WE)
  84. if(WIN32)
  85. set(exe_name "${base_name}.exe")
  86. else()
  87. set(exe_name ${base_name})
  88. endif()
  89. OV_INSTALL_LAUNCH_SCRIPT(SCRIPT_PREFIX ${base_name} EXECUTABLE_NAME ${exe_name} NOPROJECT)
  90. endforeach()
  91. install(DIRECTORY ${OPENVIBE_SDK_PATH}/include DESTINATION ${DIST_INCLUDEDIR})
  92. install(DIRECTORY ${OPENVIBE_SDK_PATH}/bin DESTINATION ${DIST_BINDIR}) # FILES_MATCHING PATTERN "openvibe-plugins*dll") or *so*
  93. install(DIRECTORY ${OPENVIBE_SDK_PATH}/lib DESTINATION ${DIST_LIBDIR}) # FILES_MATCHING PATTERN "openvibe-plugins*dll")
  94. # install(DIRECTORY ${OPENVIBE_SDK_PATH}/etc DESTINATION ${DIST_SYSCONFDIR})
  95. install(DIRECTORY ${OPENVIBE_SDK_PATH}/share DESTINATION ${DIST_DATADIR})
  96. endif()
  97. endif()