Dependencies.cmake 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. macro(DeployMacOS TARGET)
  2. if (EXISTS ${TARGET_FILE})
  3. message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}")
  4. get_target_property(QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
  5. execute_process(
  6. COMMAND ${QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS
  7. OUTPUT_VARIABLE QT_PLUGIN_DIR
  8. OUTPUT_STRIP_TRAILING_WHITESPACE
  9. )
  10. install(CODE "set(TARGET_FILE \"${TARGET_FILE}\")" COMPONENT "Hyperion")
  11. install(CODE "set(TARGET_BUNDLE_NAME \"${TARGET}.app\")" COMPONENT "Hyperion")
  12. install(CODE "set(PLUGIN_DIR \"${QT_PLUGIN_DIR}\")" COMPONENT "Hyperion")
  13. install(CODE "set(BUILD_DIR \"${CMAKE_BINARY_DIR}\")" COMPONENT "Hyperion")
  14. install(CODE "set(ENABLE_EFFECTENGINE \"${ENABLE_EFFECTENGINE}\")" COMPONENT "Hyperion")
  15. install(CODE [[
  16. file(GET_RUNTIME_DEPENDENCIES
  17. EXECUTABLES ${TARGET_FILE}
  18. RESOLVED_DEPENDENCIES_VAR resolved_deps
  19. UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
  20. )
  21. foreach(dependency ${resolved_deps})
  22. string(FIND ${dependency} "dylib" _index)
  23. if (${_index} GREATER -1)
  24. file(INSTALL
  25. FILES "${dependency}"
  26. DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/Frameworks"
  27. TYPE SHARED_LIBRARY
  28. )
  29. else()
  30. file(INSTALL
  31. FILES "${dependency}"
  32. DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/lib"
  33. TYPE SHARED_LIBRARY
  34. )
  35. endif()
  36. endforeach()
  37. list(LENGTH unresolved_deps unresolved_length)
  38. if("${unresolved_length}" GREATER 0)
  39. MESSAGE("The following unresolved dependencies were discovered: ${unresolved_deps}")
  40. endif()
  41. foreach(PLUGIN "platforms" "sqldrivers" "imageformats")
  42. if(EXISTS ${PLUGIN_DIR}/${PLUGIN})
  43. file(GLOB files "${PLUGIN_DIR}/${PLUGIN}/*")
  44. list(FILTER files EXCLUDE REGEX ".*libqwebp\\.dylib$")
  45. foreach(file ${files})
  46. file(GET_RUNTIME_DEPENDENCIES
  47. EXECUTABLES ${file}
  48. RESOLVED_DEPENDENCIES_VAR PLUGINS
  49. UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
  50. )
  51. foreach(DEPENDENCY ${PLUGINS})
  52. file(INSTALL
  53. DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/lib"
  54. TYPE SHARED_LIBRARY
  55. FILES ${DEPENDENCY}
  56. )
  57. endforeach()
  58. get_filename_component(singleQtLib ${file} NAME)
  59. list(APPEND QT_PLUGINS "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/plugins/${PLUGIN}/${singleQtLib}")
  60. file(INSTALL
  61. FILES ${file}
  62. DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/plugins/${PLUGIN}"
  63. TYPE SHARED_LIBRARY
  64. )
  65. endforeach()
  66. endif()
  67. endforeach()
  68. include(BundleUtilities)
  69. fixup_bundle("${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}" "${QT_PLUGINS}" "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/lib" IGNORE_ITEM "python;python3;Python;Python3;.Python;.Python3")
  70. if(ENABLE_EFFECTENGINE)
  71. # Detect the Python version and modules directory
  72. find_package(Python3 3.5 REQUIRED)
  73. execute_process(
  74. COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(standard_lib=True))"
  75. OUTPUT_VARIABLE PYTHON_MODULES_DIR
  76. OUTPUT_STRIP_TRAILING_WHITESPACE
  77. )
  78. MESSAGE("Add Python ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} to bundle")
  79. MESSAGE("PYTHON_MODULES_DIR: ${PYTHON_MODULES_DIR}")
  80. # Copy Python modules to '/../Frameworks/Python.framework/Versions/Current/lib/PythonMAJOR.MINOR' and ignore the unnecessary stuff listed below
  81. if (PYTHON_MODULES_DIR)
  82. set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
  83. file(
  84. COPY ${PYTHON_MODULES_DIR}/
  85. DESTINATION "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/Frameworks/Python.framework/Versions/Current/lib/python${PYTHON_VERSION_MAJOR_MINOR}"
  86. PATTERN "*.pyc" EXCLUDE # compiled bytecodes
  87. PATTERN "__pycache__" EXCLUDE # any cache
  88. PATTERN "config-${PYTHON_VERSION_MAJOR_MINOR}*" EXCLUDE # static libs
  89. PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation
  90. PATTERN "tkinter" EXCLUDE # Tk interface
  91. PATTERN "turtledemo" EXCLUDE # Tk demo folder
  92. PATTERN "turtle.py" EXCLUDE # Tk demo file
  93. PATTERN "test" EXCLUDE # unittest module
  94. PATTERN "sitecustomize.py" EXCLUDE # site-specific configs
  95. )
  96. endif(PYTHON_MODULES_DIR)
  97. endif(ENABLE_EFFECTENGINE)
  98. file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/${TARGET_BUNDLE_NAME}/Contents/lib")
  99. file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/share")
  100. ]] COMPONENT "Hyperion")
  101. else()
  102. add_custom_command(
  103. TARGET ${TARGET} POST_BUILD
  104. COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$<TARGET_FILE:${TARGET}>"
  105. ARGS ${CMAKE_SOURCE_DIR}
  106. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  107. VERBATIM
  108. )
  109. endif()
  110. endmacro()
  111. macro(DeployLinux TARGET)
  112. if (EXISTS ${TARGET_FILE})
  113. message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}")
  114. include(GetPrerequisites)
  115. set(SYSTEM_LIBS_SKIP
  116. "libatomic"
  117. "libc"
  118. "libdbus"
  119. "libdl"
  120. "libexpat"
  121. "libfontconfig"
  122. "libgcc_s"
  123. "libgcrypt"
  124. "libglib"
  125. "libglib-2"
  126. "libgpg-error"
  127. "liblz4"
  128. "liblzma"
  129. "libm"
  130. "libpcre"
  131. "libpcre2"
  132. "libpthread"
  133. "librt"
  134. "libstdc++"
  135. "libsystemd"
  136. "libudev"
  137. "libusb"
  138. "libusb-1"
  139. "libutil"
  140. "libuuid"
  141. "libz"
  142. )
  143. if (ENABLE_DISPMANX)
  144. list(APPEND SYSTEM_LIBS_SKIP "libcec")
  145. endif()
  146. # Extract dependencies ignoring the system ones
  147. get_prerequisites(${TARGET_FILE} DEPENDENCIES 0 1 "" "")
  148. message(STATUS "Dependencies for target file: ${DEPENDENCIES}")
  149. # Append symlink and non-symlink dependencies to the list
  150. set(PREREQUISITE_LIBS "")
  151. foreach(DEPENDENCY ${DEPENDENCIES})
  152. get_filename_component(resolved ${DEPENDENCY} NAME_WE)
  153. list(FIND SYSTEM_LIBS_SKIP ${resolved} _index)
  154. if (${_index} GREATER -1)
  155. continue() # Skip system libraries
  156. else()
  157. gp_resolve_item("${TARGET_FILE}" "${DEPENDENCY}" "" "" resolved_file)
  158. get_filename_component(resolved_file ${resolved_file} ABSOLUTE)
  159. gp_append_unique(PREREQUISITE_LIBS ${resolved_file})
  160. get_filename_component(file_canonical ${resolved_file} REALPATH)
  161. gp_append_unique(PREREQUISITE_LIBS ${file_canonical})
  162. endif()
  163. endforeach()
  164. # Append the OpenSSL library to the list
  165. find_package(OpenSSL 1.0.0 REQUIRED)
  166. if (OPENSSL_FOUND)
  167. foreach(openssl_lib ${OPENSSL_LIBRARIES})
  168. get_prerequisites(${openssl_lib} openssl_deps 0 1 "" "")
  169. foreach(openssl_dep ${openssl_deps})
  170. get_filename_component(resolved ${openssl_dep} NAME_WE)
  171. list(FIND SYSTEM_LIBS_SKIP ${resolved} _index)
  172. if (${_index} GREATER -1)
  173. continue() # Skip system libraries
  174. else()
  175. gp_resolve_item("${openssl_lib}" "${openssl_dep}" "" "" resolved_file)
  176. get_filename_component(resolved_file ${resolved_file} ABSOLUTE)
  177. gp_append_unique(PREREQUISITE_LIBS ${resolved_file})
  178. get_filename_component(file_canonical ${resolved_file} REALPATH)
  179. gp_append_unique(PREREQUISITE_LIBS ${file_canonical})
  180. endif()
  181. endforeach()
  182. gp_append_unique(PREREQUISITE_LIBS ${openssl_lib})
  183. get_filename_component(file_canonical ${openssl_lib} REALPATH)
  184. gp_append_unique(PREREQUISITE_LIBS ${file_canonical})
  185. endforeach()
  186. else()
  187. message( WARNING "OpenSSL NOT found (https webserver will not work)")
  188. endif(OPENSSL_FOUND)
  189. # Detect the Qt plugin directory, source: https://github.com/lxde/lxqt-qtplugin/blob/master/src/CMakeLists.txt
  190. if ( TARGET Qt${QT_VERSION_MAJOR}::qmake )
  191. get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
  192. execute_process(
  193. COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS
  194. OUTPUT_VARIABLE QT_PLUGINS_DIR
  195. OUTPUT_STRIP_TRAILING_WHITESPACE
  196. )
  197. endif()
  198. # Copy Qt plugins to 'share/hyperion/lib'
  199. if (QT_PLUGINS_DIR)
  200. foreach(PLUGIN "platforms" "sqldrivers" "imageformats")
  201. if (EXISTS ${QT_PLUGINS_DIR}/${PLUGIN})
  202. file(GLOB files "${QT_PLUGINS_DIR}/${PLUGIN}/*.so")
  203. foreach(file ${files})
  204. get_prerequisites(${file} PLUGINS 0 1 "" "")
  205. foreach(DEPENDENCY ${PLUGINS})
  206. get_filename_component(resolved ${DEPENDENCY} NAME_WE)
  207. list(FIND SYSTEM_LIBS_SKIP ${resolved} _index)
  208. if (${_index} GREATER -1)
  209. continue() # Skip system libraries
  210. else()
  211. gp_resolve_item("${file}" "${DEPENDENCY}" "" "" resolved_file)
  212. get_filename_component(resolved_file ${resolved_file} ABSOLUTE)
  213. gp_append_unique(PREREQUISITE_LIBS ${resolved_file})
  214. get_filename_component(file_canonical ${resolved_file} REALPATH)
  215. gp_append_unique(PREREQUISITE_LIBS ${file_canonical})
  216. endif()
  217. endforeach()
  218. install(
  219. FILES ${file}
  220. DESTINATION "share/hyperion/lib/${PLUGIN}"
  221. COMPONENT "Hyperion"
  222. )
  223. endforeach()
  224. endif()
  225. endforeach()
  226. endif(QT_PLUGINS_DIR)
  227. # Create a qt.conf file in 'share/hyperion/bin' to override hard-coded search paths in Qt plugins
  228. file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n")
  229. install(
  230. FILES "${CMAKE_BINARY_DIR}/qt.conf"
  231. DESTINATION "share/hyperion/bin"
  232. COMPONENT "Hyperion"
  233. )
  234. # Copy dependencies to 'share/hyperion/lib'
  235. foreach(PREREQUISITE_LIB ${PREREQUISITE_LIBS})
  236. install(
  237. FILES ${PREREQUISITE_LIB}
  238. DESTINATION "share/hyperion/lib"
  239. COMPONENT "Hyperion"
  240. )
  241. endforeach()
  242. if(ENABLE_EFFECTENGINE)
  243. # Detect the Python version and modules directory
  244. if (NOT CMAKE_VERSION VERSION_LESS "3.12")
  245. set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
  246. set(PYTHON_MODULES_DIR "${Python3_STDLIB}")
  247. else()
  248. set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
  249. execute_process(
  250. COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(standard_lib=True))"
  251. OUTPUT_VARIABLE PYTHON_MODULES_DIR
  252. OUTPUT_STRIP_TRAILING_WHITESPACE
  253. )
  254. endif()
  255. # Copy Python modules to 'share/hyperion/lib/pythonMAJOR.MINOR' and ignore the unnecessary stuff listed below
  256. if (PYTHON_MODULES_DIR)
  257. install(
  258. DIRECTORY ${PYTHON_MODULES_DIR}/
  259. DESTINATION "share/hyperion/lib/python${PYTHON_VERSION_MAJOR_MINOR}"
  260. COMPONENT "Hyperion"
  261. PATTERN "*.pyc" EXCLUDE # compiled bytecodes
  262. PATTERN "__pycache__" EXCLUDE # any cache
  263. PATTERN "config-${PYTHON_VERSION_MAJOR_MINOR}*" EXCLUDE # static libs
  264. PATTERN "lib2to3" EXCLUDE # automated Python 2 to 3 code translation
  265. PATTERN "tkinter" EXCLUDE # Tk interface
  266. PATTERN "turtle.py" EXCLUDE # Tk demo
  267. PATTERN "test" EXCLUDE # unittest module
  268. PATTERN "sitecustomize.py" EXCLUDE # site-specific configs
  269. )
  270. endif(PYTHON_MODULES_DIR)
  271. endif(ENABLE_EFFECTENGINE)
  272. else()
  273. # Run CMake after target was built to run get_prerequisites on ${TARGET_FILE}
  274. add_custom_command(
  275. TARGET ${TARGET} POST_BUILD
  276. COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$<TARGET_FILE:${TARGET}>"
  277. ARGS ${CMAKE_SOURCE_DIR}
  278. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  279. VERBATIM
  280. )
  281. endif()
  282. endmacro()
  283. macro(DeployWindows TARGET)
  284. if (EXISTS ${TARGET_FILE})
  285. message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}")
  286. find_package(Qt${QT_VERSION_MAJOR}Core REQUIRED)
  287. find_package(OpenSSL REQUIRED)
  288. # Find the windeployqt binaries
  289. get_target_property(QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
  290. get_filename_component(QT_BIN_DIR "${QMAKE_EXECUTABLE}" DIRECTORY)
  291. find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
  292. # Collect the runtime libraries
  293. get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" DIRECTORY)
  294. if (QT_VERSION_MAJOR EQUAL 5)
  295. set(WINDEPLOYQT_PARAMS --no-angle --no-opengl-sw)
  296. else()
  297. set(WINDEPLOYQT_PARAMS --no-opengl-sw)
  298. endif()
  299. execute_process(
  300. COMMAND "${CMAKE_COMMAND}" -E
  301. env "PATH=${COMPILER_PATH};${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}"
  302. --dry-run
  303. ${WINDEPLOYQT_PARAMS}
  304. --list mapping
  305. "${TARGET_FILE}"
  306. OUTPUT_VARIABLE DEPS
  307. OUTPUT_STRIP_TRAILING_WHITESPACE
  308. )
  309. # Parse DEPS into a semicolon-separated list.
  310. separate_arguments(DEPENDENCIES WINDOWS_COMMAND ${DEPS})
  311. string(REPLACE "\\" "/" DEPENDENCIES "${DEPENDENCIES}")
  312. # Copy dependencies to 'hyperion/lib' or 'hyperion'
  313. while (DEPENDENCIES)
  314. list(GET DEPENDENCIES 0 src)
  315. list(GET DEPENDENCIES 1 dst)
  316. get_filename_component(dst ${dst} DIRECTORY)
  317. if (NOT "${dst}" STREQUAL "")
  318. install(
  319. FILES ${src}
  320. DESTINATION "lib/${dst}"
  321. COMPONENT "Hyperion"
  322. )
  323. else()
  324. install(
  325. FILES ${src}
  326. DESTINATION "bin"
  327. COMPONENT "Hyperion"
  328. )
  329. endif()
  330. list(REMOVE_AT DEPENDENCIES 0 1)
  331. endwhile()
  332. # Copy libssl/libcrypto to 'hyperion'
  333. if (OPENSSL_FOUND)
  334. string(REGEX MATCHALL "[0-9]+" openssl_versions "${OPENSSL_VERSION}")
  335. list(GET openssl_versions 0 openssl_version_major)
  336. list(GET openssl_versions 1 openssl_version_minor)
  337. set(library_suffix "-${openssl_version_major}_${openssl_version_minor}")
  338. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  339. string(APPEND library_suffix "-x64")
  340. endif()
  341. find_file(OPENSSL_SSL
  342. NAMES "libssl${library_suffix}.dll"
  343. PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin
  344. NO_DEFAULT_PATH
  345. )
  346. find_file(OPENSSL_CRYPTO
  347. NAMES "libcrypto${library_suffix}.dll"
  348. PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin
  349. NO_DEFAULT_PATH
  350. )
  351. install(
  352. FILES ${OPENSSL_SSL} ${OPENSSL_CRYPTO}
  353. DESTINATION "bin"
  354. COMPONENT "Hyperion"
  355. )
  356. endif(OPENSSL_FOUND)
  357. # Copy libjpeg-turbo to 'hyperion'
  358. if (ENABLE_MF)
  359. find_package(TurboJPEG)
  360. if (TURBOJPEG_FOUND)
  361. find_file(TURBOJPEG_DLL
  362. NAMES "turbojpeg.dll"
  363. PATHS ${TurboJPEG_INCLUDE_DIRS}/.. ${TurboJPEG_INCLUDE_DIRS}/../bin
  364. NO_DEFAULT_PATH
  365. )
  366. find_file(JPEG_DLL
  367. NAMES "jpeg62.dll"
  368. PATHS ${TurboJPEG_INCLUDE_DIRS}/.. ${TurboJPEG_INCLUDE_DIRS}/../bin
  369. NO_DEFAULT_PATH
  370. )
  371. install(
  372. FILES ${TURBOJPEG_DLL} ${JPEG_DLL}
  373. DESTINATION "bin"
  374. COMPONENT "Hyperion"
  375. )
  376. endif(TURBOJPEG_FOUND)
  377. endif(ENABLE_MF)
  378. # Create a qt.conf file in 'bin' to override hard-coded search paths in Qt plugins
  379. file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n")
  380. install(
  381. FILES "${CMAKE_BINARY_DIR}/qt.conf"
  382. DESTINATION "bin"
  383. COMPONENT "Hyperion"
  384. )
  385. if(ENABLE_EFFECTENGINE)
  386. # Download embed python package (only release build package available)
  387. # Currently only cmake version >= 3.12 implemented
  388. set(url "https://www.python.org/ftp/python/${Python3_VERSION}/")
  389. set(filename "python-${Python3_VERSION}-embed-amd64.zip")
  390. if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${filename}" OR NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/python")
  391. file(DOWNLOAD "${url}${filename}" "${CMAKE_CURRENT_BINARY_DIR}/${filename}"
  392. STATUS result
  393. )
  394. # Check if the download is successful
  395. list(GET result 0 result_code)
  396. if(NOT result_code EQUAL 0)
  397. list(GET result 1 reason)
  398. message(FATAL_ERROR "Could not download file ${url}${filename}: ${reason}")
  399. endif()
  400. # Unpack downloaded embed python
  401. file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/python)
  402. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python)
  403. execute_process(
  404. COMMAND ${CMAKE_COMMAND} -E tar -xfz "${CMAKE_CURRENT_BINARY_DIR}/${filename}"
  405. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python
  406. OUTPUT_QUIET
  407. )
  408. endif()
  409. # Copy pythonXX.dll and pythonXX.zip to 'hyperion'
  410. foreach(PYTHON_FILE
  411. "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}.dll"
  412. "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}.zip"
  413. )
  414. install(
  415. FILES ${CMAKE_CURRENT_BINARY_DIR}/python/${PYTHON_FILE}
  416. DESTINATION "bin"
  417. COMPONENT "Hyperion"
  418. )
  419. endforeach()
  420. endif(ENABLE_EFFECTENGINE)
  421. if (ENABLE_DX)
  422. # Download DirectX End-User Runtimes (June 2010)
  423. set(url "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe")
  424. if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe")
  425. file(DOWNLOAD "${url}" "${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe"
  426. STATUS result
  427. )
  428. # Check if the download is successful
  429. list(GET result 0 result_code)
  430. if (NOT result_code EQUAL 0)
  431. list(GET result 1 reason)
  432. message(FATAL_ERROR "Could not download DirectX End-User Runtimes: ${reason}")
  433. endif()
  434. endif()
  435. # Copy DirectX End-User Runtimes to 'hyperion'
  436. install(
  437. FILES ${CMAKE_CURRENT_BINARY_DIR}/dx_redist.exe
  438. DESTINATION "bin"
  439. COMPONENT "Hyperion"
  440. )
  441. endif (ENABLE_DX)
  442. else()
  443. # Run CMake after target was built
  444. add_custom_command(
  445. TARGET ${TARGET} POST_BUILD
  446. COMMAND "${CMAKE_COMMAND}" "-DTARGET_FILE=$<TARGET_FILE:${TARGET}>"
  447. ARGS ${CMAKE_SOURCE_DIR}
  448. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  449. VERBATIM
  450. )
  451. endif()
  452. endmacro()