RuntimeUtilities.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #[[
  2. Utility functions used to set the output of runtime executables and dependencies.
  3. ]]
  4. #[[
  5. Change the runtime output directory of all targets declared in this scope. This is particularly helpful on Windows
  6. when building the project as a shared library, so that all DLLs are located together with any built executables. The
  7. set() call is guarded against pre-definitions in order to respect consumer choice.
  8. ]]
  9. function(setup_runtime_output_directory)
  10. if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
  11. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
  12. endif()
  13. endfunction()
  14. # RMLUI_CMAKE_MINIMUM_VERSION_RAISE_NOTICE:
  15. # From CMake 3.21 there is no need for the following function, as we can set the RUNTIME_DEPENDENCY_SET on
  16. # install(TARGETS) directly.
  17. #[[
  18. Output variable to conditionally set up runtime dependency arguments when installing targets.
  19. This feature is only available from CMake 3.21, on older version this feature will be disabled.
  20. Output variable:
  21. - RMLUI_RUNTIME_DEPENDENCY_SET_ARG: Argument to use for the install(TARGETS) command.
  22. ]]
  23. function(setup_runtime_dependency_set_arg)
  24. set(RMLUI_RUNTIME_DEPENDENCY_SET_ARG "" PARENT_SCOPE)
  25. if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21")
  26. set(RMLUI_RUNTIME_DEPENDENCY_SET_ARG RUNTIME_DEPENDENCY_SET rmlui_runtime_dependencies PARENT_SCOPE)
  27. endif()
  28. endfunction()
  29. #[[
  30. Install runtime dependencies on supported platforms, when enabled by the user.
  31. ]]
  32. function(install_runtime_dependencies)
  33. if(WIN32 AND RMLUI_RUNTIME_DEPENDENCY_SET_ARG)
  34. option(RMLUI_INSTALL_RUNTIME_DEPENDENCIES "Include runtime dependencies when installing RmlUi." ON)
  35. mark_as_advanced(RMLUI_INSTALL_RUNTIME_DEPENDENCIES)
  36. if(RMLUI_INSTALL_RUNTIME_DEPENDENCIES)
  37. install(RUNTIME_DEPENDENCY_SET rmlui_runtime_dependencies
  38. PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-"
  39. POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
  40. )
  41. endif()
  42. endif()
  43. endfunction()