From 825de0ec09cae3998cbcd891fc3fd45c6642ddff Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Thu, 29 Aug 2024 09:58:55 +0200 Subject: [PATCH] cmake: Fix building in dir with whitespace Part-of: --- cmake/GenerateKhrManifest.cmake | 9 ++-- cmake/GenerateKhrManifestInternals.cmake.in | 42 ++++++++++--------- doc/changes/misc_fixes/mr.2319.md | 1 + src/xrt/targets/openxr/CMakeLists.txt | 2 +- .../service/configure_and_install_units.cmake | 4 +- 5 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 doc/changes/misc_fixes/mr.2319.md diff --git a/cmake/GenerateKhrManifest.cmake b/cmake/GenerateKhrManifest.cmake index 38c20a85e..3685fb0e0 100644 --- a/cmake/GenerateKhrManifest.cmake +++ b/cmake/GenerateKhrManifest.cmake @@ -77,7 +77,7 @@ function(generate_khr_manifest_buildtree) message(FATAL_ERROR "Need MANIFEST_DESCRIPTION specified!") endif() if(_genmanifest_LIBMONADO) - set(_libmonado $) + set(_libmonado "$") endif() # Set template values @@ -101,6 +101,7 @@ function(generate_khr_manifest_buildtree) "${_script}" DEPENDS "${_script}" COMMENT "Generating ${_genmanifest_MANIFEST_DESCRIPTION} named ${_genmanifest_OUT_FILE} for build tree usage" + VERBATIM ) endfunction() @@ -144,14 +145,14 @@ function(generate_khr_manifest_at_install) set(_genmanifest_IS_INSTALL ON) # Template value set(TARGET_FILENAME - ${CMAKE_SHARED_MODULE_PREFIX}${_genmanifest_TARGET}${CMAKE_SHARED_MODULE_SUFFIX} + "${CMAKE_SHARED_MODULE_PREFIX}${_genmanifest_TARGET}${CMAKE_SHARED_MODULE_SUFFIX}" ) if(_genmanifest_LIBMONADO) - set(LIBMONADO ${CMAKE_SHARED_MODULE_PREFIX}${_genmanifest_LIBMONADO}${CMAKE_SHARED_MODULE_SUFFIX}) + set(LIBMONADO "${CMAKE_SHARED_MODULE_PREFIX}${_genmanifest_LIBMONADO}${CMAKE_SHARED_MODULE_SUFFIX}") endif() set(_script - ${CMAKE_CURRENT_BINARY_DIR}/make_manifest_${_genmanifest_TARGET}.cmake) + "${CMAKE_CURRENT_BINARY_DIR}/make_manifest_${_genmanifest_TARGET}.cmake") configure_file("${_KHR_MANIFEST_SCRIPT}" "${_script}" @ONLY) install(SCRIPT "${_script}" COMPONENT ${_genmanifest_COMPONENT}) endfunction() diff --git a/cmake/GenerateKhrManifestInternals.cmake.in b/cmake/GenerateKhrManifestInternals.cmake.in index a2c879a37..f2d4fa699 100644 --- a/cmake/GenerateKhrManifestInternals.cmake.in +++ b/cmake/GenerateKhrManifestInternals.cmake.in @@ -7,23 +7,25 @@ # 2019-2022 Rylie Pavlik # Get input from main CMake script -set(MANIFEST_TEMPLATE @_genmanifest_MANIFEST_TEMPLATE@) -set(DESTINATION @_genmanifest_DESTINATION@) -set(OUT_FILENAME @_genmanifest_OUT_FILENAME@) -set(CONFIGURE_OUTPUT_FILE @_genmanifest_INTERMEDIATE_MANIFEST@) +set(MANIFEST_TEMPLATE "@_genmanifest_MANIFEST_TEMPLATE@") +set(DESTINATION "@_genmanifest_DESTINATION@") +set(OUT_FILENAME "@_genmanifest_OUT_FILENAME@") +set(CONFIGURE_OUTPUT_FILE "@_genmanifest_INTERMEDIATE_MANIFEST@") set(IS_INSTALL @_genmanifest_IS_INSTALL@) set(MANIFEST_DESCRIPTION "@_genmanifest_MANIFEST_DESCRIPTION@") -set(TARGET @_genmanifest_TARGET@) +set(TARGET "@_genmanifest_TARGET@") # Target install dir relative to install prefix -set(RELATIVE_TARGET_DIR @_genmanifest_RELATIVE_TARGET_DIR@) +set(RELATIVE_TARGET_DIR "@_genmanifest_RELATIVE_TARGET_DIR@") # Target so/dll filename -set(TARGET_FILENAME @TARGET_FILENAME@) +set(TARGET_FILENAME "@TARGET_FILENAME@") # The relative path from the manifest dir to the library. Optional. set(TARGET_DIR_RELATIVE_TO_MANIFEST - @_genmanifest_TARGET_DIR_RELATIVE_TO_MANIFEST@) + "@_genmanifest_TARGET_DIR_RELATIVE_TO_MANIFEST@") # Config option -set(ABSOLUTE_TARGET_PATH @_genmanifest_ABSOLUTE_TARGET_PATH@) -set(LIBMONADO @LIBMONADO@) +set(ABSOLUTE_TARGET_PATH "@_genmanifest_ABSOLUTE_TARGET_PATH@") +if (NOT LIBMONADO) + set(LIBMONADO "@LIBMONADO@") +endif() if(TARGET_PATH) # This is at build time, not install time @@ -33,14 +35,14 @@ elseif(ABSOLUTE_TARGET_PATH) message( STATUS "Installing ${MANIFEST_DESCRIPTION} with absolute path to library") - set(TARGET_PATH ${RELATIVE_TARGET_DIR}/${TARGET_FILENAME}) + set(TARGET_PATH "${RELATIVE_TARGET_DIR}/${TARGET_FILENAME}") if(NOT IS_ABSOLUTE ${RELATIVE_TARGET_DIR}) - set(TARGET_PATH ${CMAKE_INSTALL_PREFIX}/${TARGET_PATH}) + set(TARGET_PATH "${CMAKE_INSTALL_PREFIX}/${TARGET_PATH}") endif() if(LIBMONADO) - set(LIBMONADO ${RELATIVE_TARGET_DIR}/${LIBMONADO}) + set(LIBMONADO "${RELATIVE_TARGET_DIR}/${LIBMONADO}") if(NOT IS_ABSOLUTE ${RELATIVE_TARGET_DIR}) - set(LIBMONADO ${CMAKE_INSTALL_PREFIX}/${LIBMONADO}) + set(LIBMONADO "${CMAKE_INSTALL_PREFIX}/${LIBMONADO}") endif() endif() elseif(TARGET_DIR_RELATIVE_TO_MANIFEST) @@ -49,10 +51,10 @@ elseif(TARGET_DIR_RELATIVE_TO_MANIFEST) STATUS "Installing ${MANIFEST_DESCRIPTION} with JSON-relative path to library" ) - set(TARGET_PATH ${TARGET_DIR_RELATIVE_TO_MANIFEST}/${TARGET_FILENAME}) + set(TARGET_PATH "${TARGET_DIR_RELATIVE_TO_MANIFEST}/${TARGET_FILENAME}") if(LIBMONADO) - get_filename_component(LIBMONADO ${LIBMONADO} NAME) - set(LIBMONADO ${TARGET_DIR_RELATIVE_TO_MANIFEST}/${LIBMONADO}) + get_filename_component(LIBMONADO "${LIBMONADO}" NAME) + set(LIBMONADO "${TARGET_DIR_RELATIVE_TO_MANIFEST}/${LIBMONADO}") endif() else() # Unqualified filename: requires it exist on the system shared library search path. @@ -60,9 +62,9 @@ else() STATUS "Installing ${MANIFEST_DESCRIPTION} with unqualified library filename (uses system search path)" ) - set(TARGET_PATH ${TARGET_FILENAME}) + set(TARGET_PATH "${TARGET_FILENAME}") if(LIBMONADO) - get_filename_component(LIBMONADO ${LIBMONADO} NAME) + get_filename_component(LIBMONADO "${LIBMONADO}" NAME) endif() endif() @@ -75,7 +77,7 @@ if(WIN32) string(REPLACE "/" [[\\]] TARGET_PATH ${TARGET_PATH}) endif() -set(target_path ${TARGET_PATH}) +set(target_path "${TARGET_PATH}") # Create manifest configure_file("${MANIFEST_TEMPLATE}" "${CONFIGURE_OUTPUT_FILE}") diff --git a/doc/changes/misc_fixes/mr.2319.md b/doc/changes/misc_fixes/mr.2319.md new file mode 100644 index 000000000..02a2c9254 --- /dev/null +++ b/doc/changes/misc_fixes/mr.2319.md @@ -0,0 +1 @@ +Fix: Be able to build properly in directories with whitespace. diff --git a/src/xrt/targets/openxr/CMakeLists.txt b/src/xrt/targets/openxr/CMakeLists.txt index 2fe1a92b6..6fbec80be 100644 --- a/src/xrt/targets/openxr/CMakeLists.txt +++ b/src/xrt/targets/openxr/CMakeLists.txt @@ -42,7 +42,7 @@ if(NOT WIN32) APPEND_STRING PROPERTY LINK_FLAGS - "-u xrNegotiateLoaderRuntimeInterface -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version" + "-u xrNegotiateLoaderRuntimeInterface -Wl,--version-script=\"${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version\"" ) # Re-link if the version script changes. set_property( diff --git a/src/xrt/targets/service/configure_and_install_units.cmake b/src/xrt/targets/service/configure_and_install_units.cmake index 67e74fc53..e75b00210 100644 --- a/src/xrt/targets/service/configure_and_install_units.cmake +++ b/src/xrt/targets/service/configure_and_install_units.cmake @@ -13,8 +13,8 @@ if(XRT_INSTALL_ABSOLUTE_SYSTEMD_UNIT_FILES) endif() # Create unit files -configure_file(@SOCKET_INPUT@ "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.socket") -configure_file(@SERVICE_INPUT@ "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service") +configure_file("@SOCKET_INPUT@" "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.socket") +configure_file("@SERVICE_INPUT@" "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service") # Install them file(