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.

OvInstallLaunchScript.cmake 3.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. INCLUDE(CMakeParseArguments)
  2. #
  3. # Creates launch script from a common OpenViBE template (in "cmake-modules/launchers/"), but dedicated to scenarios to be executed with the Designer
  4. #
  5. # The mandatory 1st argument SCRIPT_PREFIX specifies what the resulting script is called. A platform specific postfix will be added.
  6. # The mandatory 2nd argument EXECUTABLE_NAME specifies what the resulting script will called eventually.
  7. # The optional 3nd argument ARGV1 specifies some extra argument or switch that is given to the launched executable by the script
  8. #
  9. FUNCTION(OV_INSTALL_LAUNCH_SCRIPT)
  10. SET(options PAUSE)
  11. SET(oneValueArgs SCRIPT_PREFIX EXECUTABLE_NAME ICON_PATH)
  12. SET(multiValueArgs PARAMETERS)
  13. CMAKE_PARSE_ARGUMENTS(OV_INSTALL_LAUNCH_SCRIPT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  14. OV_CONFIGURE_RC(NAME ${OV_INSTALL_LAUNCH_SCRIPT_SCRIPT_PREFIX} ICON_PATH ${OV_INSTALL_LAUNCH_SCRIPT_ICON_PATH})
  15. # Install executable launcher if install_exe option is set to on, the os is WIN32, and no argument has been specified
  16. IF(WIN32 AND INSTALL_EXE AND NOT(OV_INSTALL_LAUNCH_SCRIPT_PAUSE) AND NOT(OV_INSTALL_LAUNCH_SCRIPT_PARAMETERS))
  17. # Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir
  18. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_EXE_PROJECTS_TO_INSTALL)
  19. SET(OV_TMP "${OV_TMP};${OV_INSTALL_LAUNCH_SCRIPT_SCRIPT_PREFIX}")
  20. SET_PROPERTY(GLOBAL PROPERTY OV_EXE_PROJECTS_TO_INSTALL ${OV_TMP})
  21. ELSE()
  22. IF(WIN32)
  23. SET(SCRIPT_POSTFIX ".cmd")
  24. ELSEIF(APPLE)
  25. SET(SCRIPT_POSTFIX "-macos.sh")
  26. ELSEIF(UNIX)
  27. # Debian recommends that extensions such as .sh are not used; On Linux, scripts with such extensions shouldn't be packaged
  28. SET(SCRIPT_POSTFIX ".sh")
  29. ENDIF()
  30. # Extract the filename of the project executable, the variable in the script base will be replaced with it by CONFIGURE_FILE()
  31. GET_TARGET_PROPERTY(TMP_PROJECT_TARGET_PATH ${OV_INSTALL_LAUNCH_SCRIPT_EXECUTABLE_NAME} LOCATION)
  32. GET_FILENAME_COMPONENT(OV_CMD_EXECUTABLE ${TMP_PROJECT_TARGET_PATH} NAME)
  33. IF(${OV_CMD_EXECUTABLE} STREQUAL "TMP_PROJECT_TARGET_PATH-NOTFOUND")
  34. SET(OV_CMD_EXECUTABLE ${OV_INSTALL_LAUNCH_SCRIPT_EXECUTABLE_NAME})
  35. ELSE()
  36. IF(WIN32)
  37. SET(OV_CMD_EXECUTABLE "%OV_PATH_ROOT%/bin/${OV_CMD_EXECUTABLE}")
  38. ENDIF()
  39. ENDIF()
  40. SET(SCRIPT_NAME ${OV_INSTALL_LAUNCH_SCRIPT_SCRIPT_PREFIX}${SCRIPT_POSTFIX})
  41. SET(OV_CMD_ARGS ${OV_INSTALL_LAUNCH_SCRIPT_PARAMETERS})
  42. IF(OV_INSTALL_LAUNCH_SCRIPT_PAUSE)
  43. SET(OV_PAUSE "PAUSE")
  44. ELSE()
  45. SET(OV_PAUSE "")
  46. ENDIF()
  47. CONFIGURE_FILE(${OV_LAUNCHER_SOURCE_PATH}/openvibe-launcher${SCRIPT_POSTFIX}-base ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} @ONLY)
  48. # IF(MULTI_BUILD) # Replace with generator expression in CMake 3.5+
  49. # FOREACH(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
  50. # STRING(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIGU)
  51. # INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} DESTINATION ${DIST_ROOT}/${OUTPUTCONFIG})
  52. # ENDFOREACH()
  53. # ELSE()
  54. # INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} DESTINATION ${DIST_ROOT})
  55. # ENDIF()
  56. INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} DESTINATION ${DIST_ROOT})
  57. ENDIF()
  58. ENDFUNCTION()
  59. FUNCTION(OV_CONFIGURE_RC)
  60. SET(options )
  61. SET(oneValueArgs NAME ICON_PATH)
  62. SET(multiValueArgs )
  63. CMAKE_PARSE_ARGUMENTS(OV_CONFIGURE_RC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  64. SET(GENERATED_RC_FILE "${CMAKE_BINARY_DIR}/resource-files/${OV_CONFIGURE_RC_NAME}.rc")
  65. IF(OV_CONFIGURE_RC_ICON_PATH)
  66. SET(CONFIGURE_ICON "ID_Icon ICON DISCARDABLE \"${OV_CONFIGURE_RC_ICON_PATH}\"")
  67. ENDIF()
  68. IF(NOT(PROJECT_PRODUCT_NAME))
  69. SET(PROJECT_PRODUCT_NAME "${OV_CONFIGURE_RC_NAME}")
  70. ENDIF()
  71. SET(FILE_DESCRIPTION "${PROJECT_PRODUCT_NAME} for Win32")
  72. CONFIGURE_FILE(
  73. ${OV_LAUNCHER_SOURCE_PATH}/resource-file.rc-base
  74. ${GENERATED_RC_FILE}
  75. @ONLY)
  76. ENDFUNCTION()