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!") message(FATAL_ERROR "Need MANIFEST_DESCRIPTION specified!")
endif() endif()
if(_genmanifest_LIBMONADO) if(_genmanifest_LIBMONADO)
set(_libmonado $<TARGET_FILE:${_genmanifest_LIBMONADO}>) set(_libmonado "$<TARGET_FILE:${_genmanifest_LIBMONADO}>")
endif() endif()
# Set template values # Set template values
@ -101,6 +101,7 @@ function(generate_khr_manifest_buildtree)
"${_script}" DEPENDS "${_script}" "${_script}" DEPENDS "${_script}"
COMMENT COMMENT
"Generating ${_genmanifest_MANIFEST_DESCRIPTION} named ${_genmanifest_OUT_FILE} for build tree usage" "Generating ${_genmanifest_MANIFEST_DESCRIPTION} named ${_genmanifest_OUT_FILE} for build tree usage"
VERBATIM
) )
endfunction() endfunction()
@ -144,14 +145,14 @@ function(generate_khr_manifest_at_install)
set(_genmanifest_IS_INSTALL ON) set(_genmanifest_IS_INSTALL ON)
# Template value # Template value
set(TARGET_FILENAME 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) 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() endif()
set(_script 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) configure_file("${_KHR_MANIFEST_SCRIPT}" "${_script}" @ONLY)
install(SCRIPT "${_script}" COMPONENT ${_genmanifest_COMPONENT}) install(SCRIPT "${_script}" COMPONENT ${_genmanifest_COMPONENT})
endfunction() endfunction()

View file

@ -7,23 +7,25 @@
# 2019-2022 Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com> # 2019-2022 Rylie Pavlik <rylie.pavlik@collabora.com> <rylie@ryliepavlik.com>
# Get input from main CMake script # Get input from main CMake script
set(MANIFEST_TEMPLATE @_genmanifest_MANIFEST_TEMPLATE@) set(MANIFEST_TEMPLATE "@_genmanifest_MANIFEST_TEMPLATE@")
set(DESTINATION @_genmanifest_DESTINATION@) set(DESTINATION "@_genmanifest_DESTINATION@")
set(OUT_FILENAME @_genmanifest_OUT_FILENAME@) set(OUT_FILENAME "@_genmanifest_OUT_FILENAME@")
set(CONFIGURE_OUTPUT_FILE @_genmanifest_INTERMEDIATE_MANIFEST@) set(CONFIGURE_OUTPUT_FILE "@_genmanifest_INTERMEDIATE_MANIFEST@")
set(IS_INSTALL @_genmanifest_IS_INSTALL@) set(IS_INSTALL @_genmanifest_IS_INSTALL@)
set(MANIFEST_DESCRIPTION "@_genmanifest_MANIFEST_DESCRIPTION@") set(MANIFEST_DESCRIPTION "@_genmanifest_MANIFEST_DESCRIPTION@")
set(TARGET @_genmanifest_TARGET@) set(TARGET "@_genmanifest_TARGET@")
# Target install dir relative to install prefix # 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 # 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. # The relative path from the manifest dir to the library. Optional.
set(TARGET_DIR_RELATIVE_TO_MANIFEST set(TARGET_DIR_RELATIVE_TO_MANIFEST
@_genmanifest_TARGET_DIR_RELATIVE_TO_MANIFEST@) "@_genmanifest_TARGET_DIR_RELATIVE_TO_MANIFEST@")
# Config option # Config option
set(ABSOLUTE_TARGET_PATH @_genmanifest_ABSOLUTE_TARGET_PATH@) set(ABSOLUTE_TARGET_PATH "@_genmanifest_ABSOLUTE_TARGET_PATH@")
set(LIBMONADO @LIBMONADO@) if (NOT LIBMONADO)
set(LIBMONADO "@LIBMONADO@")
endif()
if(TARGET_PATH) if(TARGET_PATH)
# This is at build time, not install time # This is at build time, not install time
@ -33,14 +35,14 @@ elseif(ABSOLUTE_TARGET_PATH)
message( message(
STATUS STATUS
"Installing ${MANIFEST_DESCRIPTION} with absolute path to library") "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}) if(NOT IS_ABSOLUTE ${RELATIVE_TARGET_DIR})
set(TARGET_PATH ${CMAKE_INSTALL_PREFIX}/${TARGET_PATH}) set(TARGET_PATH "${CMAKE_INSTALL_PREFIX}/${TARGET_PATH}")
endif() endif()
if(LIBMONADO) if(LIBMONADO)
set(LIBMONADO ${RELATIVE_TARGET_DIR}/${LIBMONADO}) set(LIBMONADO "${RELATIVE_TARGET_DIR}/${LIBMONADO}")
if(NOT IS_ABSOLUTE ${RELATIVE_TARGET_DIR}) if(NOT IS_ABSOLUTE ${RELATIVE_TARGET_DIR})
set(LIBMONADO ${CMAKE_INSTALL_PREFIX}/${LIBMONADO}) set(LIBMONADO "${CMAKE_INSTALL_PREFIX}/${LIBMONADO}")
endif() endif()
endif() endif()
elseif(TARGET_DIR_RELATIVE_TO_MANIFEST) elseif(TARGET_DIR_RELATIVE_TO_MANIFEST)
@ -49,10 +51,10 @@ elseif(TARGET_DIR_RELATIVE_TO_MANIFEST)
STATUS STATUS
"Installing ${MANIFEST_DESCRIPTION} with JSON-relative path to library" "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) if(LIBMONADO)
get_filename_component(LIBMONADO ${LIBMONADO} NAME) get_filename_component(LIBMONADO "${LIBMONADO}" NAME)
set(LIBMONADO ${TARGET_DIR_RELATIVE_TO_MANIFEST}/${LIBMONADO}) set(LIBMONADO "${TARGET_DIR_RELATIVE_TO_MANIFEST}/${LIBMONADO}")
endif() endif()
else() else()
# Unqualified filename: requires it exist on the system shared library search path. # Unqualified filename: requires it exist on the system shared library search path.
@ -60,9 +62,9 @@ else()
STATUS STATUS
"Installing ${MANIFEST_DESCRIPTION} with unqualified library filename (uses system search path)" "Installing ${MANIFEST_DESCRIPTION} with unqualified library filename (uses system search path)"
) )
set(TARGET_PATH ${TARGET_FILENAME}) set(TARGET_PATH "${TARGET_FILENAME}")
if(LIBMONADO) if(LIBMONADO)
get_filename_component(LIBMONADO ${LIBMONADO} NAME) get_filename_component(LIBMONADO "${LIBMONADO}" NAME)
endif() endif()
endif() endif()
@ -75,7 +77,7 @@ if(WIN32)
string(REPLACE "/" [[\\]] TARGET_PATH ${TARGET_PATH}) string(REPLACE "/" [[\\]] TARGET_PATH ${TARGET_PATH})
endif() endif()
set(target_path ${TARGET_PATH}) set(target_path "${TARGET_PATH}")
# Create manifest # Create manifest
configure_file("${MANIFEST_TEMPLATE}" "${CONFIGURE_OUTPUT_FILE}") 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 APPEND_STRING
PROPERTY PROPERTY
LINK_FLAGS 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. # Re-link if the version script changes.
set_property( set_property(

View file

@ -13,8 +13,8 @@ if(XRT_INSTALL_ABSOLUTE_SYSTEMD_UNIT_FILES)
endif() endif()
# Create unit files # Create unit files
configure_file(@SOCKET_INPUT@ "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.socket") configure_file("@SOCKET_INPUT@" "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.socket")
configure_file(@SERVICE_INPUT@ "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service") configure_file("@SERVICE_INPUT@" "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service")
# Install them # Install them
file( file(