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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 NOPROJECT)
  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. IF(NOT OV_INSTALL_LAUNCH_SCRIPT_NOPROJECT)
  32. GET_TARGET_PROPERTY(TMP_PROJECT_TARGET_PATH ${OV_INSTALL_LAUNCH_SCRIPT_EXECUTABLE_NAME} LOCATION)
  33. GET_FILENAME_COMPONENT(OV_CMD_EXECUTABLE ${TMP_PROJECT_TARGET_PATH} NAME)
  34. ENDIF()
  35. IF(${OV_CMD_EXECUTABLE} STREQUAL "TMP_PROJECT_TARGET_PATH-NOTFOUND")
  36. SET(OV_CMD_EXECUTABLE ${OV_INSTALL_LAUNCH_SCRIPT_EXECUTABLE_NAME})
  37. ELSE()
  38. IF(WIN32)
  39. SET(OV_CMD_EXECUTABLE "%OV_PATH_ROOT%/bin/${OV_CMD_EXECUTABLE}")
  40. ENDIF()
  41. ENDIF()
  42. SET(SCRIPT_NAME ${OV_INSTALL_LAUNCH_SCRIPT_SCRIPT_PREFIX}${SCRIPT_POSTFIX})
  43. SET(OV_CMD_ARGS ${OV_INSTALL_LAUNCH_SCRIPT_PARAMETERS})
  44. IF(OV_INSTALL_LAUNCH_SCRIPT_PAUSE)
  45. SET(OV_PAUSE "PAUSE")
  46. ELSE()
  47. SET(OV_PAUSE "")
  48. ENDIF()
  49. CONFIGURE_FILE(${OV_LAUNCHER_SOURCE_PATH}/openvibe-launcher${SCRIPT_POSTFIX}-base ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} @ONLY)
  50. INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT_NAME} DESTINATION ${DIST_ROOT})
  51. ENDIF()
  52. ENDFUNCTION()
  53. FUNCTION(OV_CONFIGURE_RC)
  54. SET(options )
  55. SET(oneValueArgs NAME ICON_PATH)
  56. SET(multiValueArgs )
  57. CMAKE_PARSE_ARGUMENTS(OV_CONFIGURE_RC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  58. SET(GENERATED_RC_FILE "${CMAKE_BINARY_DIR}/resource-files/${OV_CONFIGURE_RC_NAME}.rc")
  59. IF(OV_CONFIGURE_RC_ICON_PATH)
  60. SET(CONFIGURE_ICON "ID_Icon ICON DISCARDABLE \"${OV_CONFIGURE_RC_ICON_PATH}\"")
  61. ENDIF()
  62. IF(NOT(PROJECT_PRODUCT_NAME))
  63. SET(PROJECT_PRODUCT_NAME "${OV_CONFIGURE_RC_NAME}")
  64. ENDIF()
  65. SET(FILE_DESCRIPTION "${PROJECT_PRODUCT_NAME} for Win32")
  66. CONFIGURE_FILE(
  67. ${OV_LAUNCHER_SOURCE_PATH}/resource-file.rc-base
  68. ${GENERATED_RC_FILE}
  69. @ONLY)
  70. ENDFUNCTION()