cmake: Fix building in dir with whitespace

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2319>
This commit is contained in:
Patrick Nicolas 2024-08-29 09:58:55 +02:00 committed by Rylie Pavlik
parent 6db9d570d8
commit 825de0ec09
5 changed files with 31 additions and 27 deletions

View file

@ -77,7 +77,7 @@ function(generate_khr_manifest_buildtree)
message(FATAL_ERROR "Need MANIFEST_DESCRIPTION specified!")
endif()
if(_genmanifest_LIBMONADO)
set(_libmonado $<TARGET_FILE:${_genmanifest_LIBMONADO}>)
set(_libmonado "$<TARGET_FILE:${_genmanifest_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()

View file

@ -7,23 +7,25 @@
# 2019-2022 Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com>
# 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}")

View file

@ -0,0 +1 @@
Fix: Be able to build properly in directories with whitespace.

View file

@ -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(

View file

@ -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(