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.

FindOVDesigner.cmake 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # ---------------------------------
  2. # Finds OpenViBE Designer 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_OVDESIGNER)
  14. if(MULTI_BUILD)
  15. set(SEEK_PATHS ${DESIGNER_SDK_PATH};${LIST_DEPENDENCIES_PATH})
  16. unset(DESIGNER_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(DESIGNER_SDK_PATH_TMP CACHE)
  21. find_path(DESIGNER_SDK_PATH_TMP include/visualization-toolkit/ovviz_all.h PATHS ${SEEK_PATHS} PATH_SUFFIXES openvibe-designer-${OUTPUTCONFIG} ${OUTPUTCONFIG} NO_DEFAULT_PATH)
  22. set(DESIGNER_SDK_PATH_${OUTPUTCONFIGU} ${DESIGNER_SDK_PATH_TMP})
  23. if(DESIGNER_SDK_PATH_TMP)
  24. message(STATUS "Found ${OUTPUTCONFIG} of designer at ${DESIGNER_SDK_PATH_TMP}")
  25. string(CONCAT DESIGNER_SDK_PATH ${DESIGNER_SDK_PATH} $<$<CONFIG:${OUTPUTCONFIGU}>:${DESIGNER_SDK_PATH_TMP}>)
  26. set(AT_LEAST_ONE_DESIGNER_BUILD TRUE)
  27. endif()
  28. endforeach()
  29. if(NOT DEFINED AT_LEAST_ONE_DESIGNER_BUILD)
  30. message(FATAL_ERROR "Did not find any valid build of OpenViBE Designer")
  31. endif()
  32. else() # Regular build
  33. # find_path(DESIGNER_SDK_PATH bin PATHS ${DESIGNER_SDK_PATH} PATH_SUFFIXES designer NO_DEFAULT_PATH)
  34. find_path(DESIGNER_SDK_PATH include/visualization-toolkit/ovviz_all.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openvibe-designer-${CMAKE_BUILD_TYPE_LOWER} NO_DEFAULT_PATH)
  35. if(NOT DESIGNER_SDK_PATH)
  36. MESSAGE(ERROR "Could not find DESIGNER_SDK_PATH (value : ${OPENVIBE_SDK_PATH}). Please either specify it or put OpenViBE designer binaries into dependencies/openvibe-designer-{debug/release} folder")
  37. endif()
  38. string(REGEX REPLACE "\\\\+" "/" DESIGNER_SDK_PATH ${DESIGNER_SDK_PATH})
  39. message(" Found Designer... [${DESIGNER_SDK_PATH}]")
  40. endif()
  41. set(TRIED_FIND_OVDESIGNER TRUE)
  42. endif()
  43. if(INSTALL_DESIGNER)
  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 "${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/*.cmd" "${DESIGNER_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. set(OV_CMD_EXECUTABLE ${exe_name})
  65. # IF(WIN32)
  66. # SET(OV_CMD_EXECUTABLE "%OV_PATH_ROOT%/bin/${exe_name}")
  67. # ENDIF()
  68. set(SCRIPT_NAME ${base_name}${SCRIPT_POSTFIX})
  69. set(OV_CMD_ARGS "")
  70. set(OV_PAUSE "")
  71. configure_file(${OV_LAUNCHER_SOURCE_PATH}/openvibe-launcher${SCRIPT_POSTFIX}-base ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} @ONLY)
  72. install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} DESTINATION ${DIST_ROOT})
  73. endforeach()
  74. endif()
  75. install(DIRECTORY ${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/include/ DESTINATION ${DIST_INCLUDEDIR} CONFIGURATIONS ${OUTPUTCONFIG})
  76. install(DIRECTORY ${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/bin/ DESTINATION ${DIST_BINDIR} CONFIGURATIONS ${OUTPUTCONFIG} USE_SOURCE_PERMISSIONS) # FILES_MATCHING PATTERN "openvibe-plugins*dll") or *so*
  77. install(DIRECTORY ${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/lib/ DESTINATION ${DIST_LIBDIR} CONFIGURATIONS ${OUTPUTCONFIG}) # FILES_MATCHING PATTERN "openvibe-plugins*dll")
  78. install(DIRECTORY ${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/etc/ DESTINATION ${DIST_SYSCONFDIR} CONFIGURATIONS ${OUTPUTCONFIG} OPTIONAL)
  79. install(DIRECTORY ${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/share/ DESTINATION ${DIST_DATADIR} CONFIGURATIONS ${OUTPUTCONFIG})
  80. if(DESIGNER_SDK_PATH_${OUTPUTCONFIGU})
  81. file(COPY "${DESIGNER_SDK_PATH_${OUTPUTCONFIGU}}/share/openvibe/applications/designer/designer.conf" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
  82. file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/designer.conf ${CMAKE_CURRENT_BINARY_DIR}/designer.conf_${OUTPUTCONFIG})
  83. file(READ ${CMAKE_CURRENT_BINARY_DIR}/designer.conf_${OUTPUTCONFIG} FILE_CONTENT)
  84. set(MATCH_EXPR "(ProjectVersion_Components *= *.\{[^\}]+)(.\}\n)")
  85. string(REGEX REPLACE ${MATCH_EXPR} "\\1, \"openvibe-extras\":\"${OV_GLOBAL_VERSION_STRING}\"\\2" FILE_CONTENT ${FILE_CONTENT})
  86. set(MATCH_EXPR "(Designer_WebBrowserHelpURLBase *= *\\$\{[^\}]+\}/documentation)/[\\.0-9a-zA-Z]+\n")
  87. string(REGEX REPLACE ${MATCH_EXPR} "\\1/${OV_GLOBAL_VERSION_STRING}\n" FILE_CONTENT ${FILE_CONTENT})
  88. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/designer.conf_${OUTPUTCONFIG} ${FILE_CONTENT})
  89. file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/designer.conf_${OUTPUTCONFIG} "Application_Name = OpenViBE Designer\nApplication_Version = ${OV_GLOBAL_VERSION_STRING}\nAcquisitionServer_HostName = localhost\n")
  90. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/designer.conf_${OUTPUTCONFIG}" DESTINATION "${DIST_DATADIR}/openvibe/applications/designer" RENAME designer.conf CONFIGURATIONS ${OUTPUTCONFIG})
  91. endif()
  92. endforeach()
  93. else()
  94. file(GLOB EXE_SCRIPT_LIST "${DESIGNER_SDK_PATH}/*.cmd" "${DESIGNER_SDK_PATH}/*.sh")
  95. foreach(SCRIPT IN LISTS EXE_SCRIPT_LIST)
  96. get_filename_component(base_name ${SCRIPT} NAME_WE)
  97. if(WIN32)
  98. set(exe_name "${base_name}.exe")
  99. else()
  100. set(exe_name ${base_name})
  101. endif()
  102. OV_INSTALL_LAUNCH_SCRIPT(SCRIPT_PREFIX ${base_name} EXECUTABLE_NAME ${exe_name} NOPROJECT)
  103. endforeach()
  104. install(DIRECTORY ${DESIGNER_SDK_PATH}/include/ DESTINATION ${DIST_INCLUDEDIR})
  105. install(DIRECTORY ${DESIGNER_SDK_PATH}/bin/ DESTINATION ${DIST_BINDIR} USE_SOURCE_PERMISSIONS) # FILES_MATCHING PATTERN "openvibe-plugins*dll") or *so*
  106. install(DIRECTORY ${DESIGNER_SDK_PATH}/lib/ DESTINATION ${DIST_LIBDIR}) # FILES_MATCHING PATTERN "openvibe-plugins*dll")
  107. install(DIRECTORY ${DESIGNER_SDK_PATH}/etc/ DESTINATION ${DIST_SYSCONFDIR} OPTIONAL)
  108. install(DIRECTORY ${DESIGNER_SDK_PATH}/share/ DESTINATION ${DIST_DATADIR})
  109. file(COPY "${DESIGNER_SDK_PATH}/share/openvibe/applications/designer/designer.conf" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
  110. file(READ ${CMAKE_CURRENT_BINARY_DIR}/designer.conf FILE_CONTENT)
  111. set(MATCH_EXPR "(ProjectVersion_Components *= *.\{[^\}]+)(.\}\n)")
  112. string(REGEX REPLACE ${MATCH_EXPR} "\\1, \"openvibe-extras\":\"${OV_GLOBAL_VERSION_STRING}\"\\2" FILE_CONTENT ${FILE_CONTENT})
  113. set(MATCH_EXPR "(Designer_WebBrowserHelpURLBase *= *\\$\{[^\}]+\}/documentation)/[\\.0-9a-zA-Z]+\n")
  114. string(REGEX REPLACE ${MATCH_EXPR} "\\1/${OV_GLOBAL_VERSION_STRING}\n" FILE_CONTENT ${FILE_CONTENT})
  115. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/designer.conf ${FILE_CONTENT})
  116. file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/designer.conf "Application_Name = OpenViBE Designer\nApplication_Version = ${OV_GLOBAL_VERSION_STRING}\nAcquisitionServer_HostName = localhost\n")
  117. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/designer.conf DESTINATION "${DIST_DATADIR}/openvibe/applications/designer")
  118. endif()
  119. endif()