Quote include paths in SFML and FreeType

Fixes issues if the build path contains spaces
This commit is contained in:
Lukas Dürrenberger 2025-01-30 11:02:40 +01:00
parent 0a2e9ac340
commit 85362fa232
9 changed files with 15 additions and 12 deletions

View File

@ -260,13 +260,13 @@ macro(sfml_add_library module)
# add <project>/include as public include directory # add <project>/include as public include directory
target_include_directories(${target} target_include_directories(${target}
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
PRIVATE ${PROJECT_SOURCE_DIR}/src) PRIVATE "${PROJECT_SOURCE_DIR}/src")
if(SFML_BUILD_FRAMEWORKS) if(SFML_BUILD_FRAMEWORKS)
target_include_directories(${target} INTERFACE $<INSTALL_INTERFACE:SFML.framework>) target_include_directories(${target} INTERFACE "$<INSTALL_INTERFACE:SFML.framework>")
else() else()
target_include_directories(${target} INTERFACE $<INSTALL_INTERFACE:include>) target_include_directories(${target} INTERFACE "$<INSTALL_INTERFACE:include>")
endif() endif()
# define SFML_STATIC if the build type is not set to 'shared' # define SFML_STATIC if the build type is not set to 'shared'

View File

@ -9,4 +9,4 @@ sfml_add_example(X11Example GUI_APP
DEPENDS SFML::Window X11::X11) DEPENDS SFML::Window X11::X11)
# external dependency headers # external dependency headers
target_include_directories(X11Example SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/include) target_include_directories(X11Example SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/examples/include")

View File

@ -9,6 +9,6 @@ sfml_add_example(island GUI_APP
DEPENDS SFML::Graphics) DEPENDS SFML::Graphics)
# external dependency headers # external dependency headers
target_include_directories(island SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/island) target_include_directories(island SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/examples/island")
target_link_libraries(island PRIVATE Threads::Threads) target_link_libraries(island PRIVATE Threads::Threads)

View File

@ -15,4 +15,4 @@ sfml_add_example(opengl GUI_APP
DEPENDS SFML::Graphics) DEPENDS SFML::Graphics)
# external dependency headers # external dependency headers
target_include_directories(opengl SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/include) target_include_directories(opengl SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/examples/include")

View File

@ -7,4 +7,4 @@ sfml_add_example(vulkan GUI_APP
DEPENDS SFML::Graphics) DEPENDS SFML::Graphics)
# external dependency headers # external dependency headers
target_include_directories(vulkan SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/vulkan) target_include_directories(vulkan SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/examples/vulkan")

View File

@ -7,4 +7,4 @@ sfml_add_example(window GUI_APP
DEPENDS SFML::Window) DEPENDS SFML::Window)
# external dependency headers # external dependency headers
target_include_directories(window SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/examples/include) target_include_directories(window SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/examples/include")

View File

@ -76,7 +76,7 @@ sfml_add_library(System
# enable precompiled headers # enable precompiled headers
if (SFML_ENABLE_PCH) if (SFML_ENABLE_PCH)
message(VERBOSE "enabling PCH for SFML library 'sfml-system' (reused as the PCH for other SFML libraries)") message(VERBOSE "enabling PCH for SFML library 'sfml-system' (reused as the PCH for other SFML libraries)")
target_precompile_headers(sfml-system PRIVATE ${PROJECT_SOURCE_DIR}/src/SFML/PCH.hpp) target_precompile_headers(sfml-system PRIVATE "${PROJECT_SOURCE_DIR}/src/SFML/PCH.hpp")
endif() endif()
if(SFML_OS_ANDROID) if(SFML_OS_ANDROID)

View File

@ -20,7 +20,7 @@ set_target_properties(Catch2 PROPERTIES COMPILE_OPTIONS "" EXPORT_COMPILE_COMMAN
set_target_properties(Catch2WithMain PROPERTIES EXPORT_COMPILE_COMMANDS OFF) set_target_properties(Catch2WithMain PROPERTIES EXPORT_COMPILE_COMMANDS OFF)
set_target_properties(Catch2 Catch2WithMain PROPERTIES FOLDER "Dependencies") set_target_properties(Catch2 Catch2WithMain PROPERTIES FOLDER "Dependencies")
get_target_property(CATCH2_INCLUDE_DIRS Catch2 INTERFACE_INCLUDE_DIRECTORIES) get_target_property(CATCH2_INCLUDE_DIRS Catch2 INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(Catch2 SYSTEM INTERFACE ${CATCH2_INCLUDE_DIRS}) target_include_directories(Catch2 SYSTEM INTERFACE "${CATCH2_INCLUDE_DIRS}")
add_library(sfml-test-main STATIC add_library(sfml-test-main STATIC
TestUtilities/SystemUtil.hpp TestUtilities/SystemUtil.hpp

View File

@ -1,3 +1,6 @@
file(READ "${FREETYPE_DIR}/CMakeLists.txt" FREETYPE_CMAKELISTS_CONTENTS) file(READ "${FREETYPE_DIR}/CMakeLists.txt" FREETYPE_CMAKELISTS_CONTENTS)
string(REPLACE " install(\n FILES \${PROJECT_BINARY_DIR}/freetype2.pc\n DESTINATION \${CMAKE_INSTALL_LIBDIR}/pkgconfig\n COMPONENT pkgconfig)" "" FREETYPE_CMAKELISTS_CONTENTS "${FREETYPE_CMAKELISTS_CONTENTS}") string(REPLACE " install(\n FILES \${PROJECT_BINARY_DIR}/freetype2.pc\n DESTINATION \${CMAKE_INSTALL_LIBDIR}/pkgconfig\n COMPONENT pkgconfig)" "" FREETYPE_CMAKELISTS_CONTENTS "${FREETYPE_CMAKELISTS_CONTENTS}")
string(REPLACE " \$<INSTALL_INTERFACE:include/freetype2>\n \$<BUILD_INTERFACE:\${CMAKE_CURRENT_BINARY_DIR}/include>\n \$<BUILD_INTERFACE:\${CMAKE_CURRENT_SOURCE_DIR}/include>" " \"\$<INSTALL_INTERFACE:include/freetype2>\"\n \"\$<BUILD_INTERFACE:\${CMAKE_CURRENT_BINARY_DIR}/include>\"\n \"\$<BUILD_INTERFACE:\${CMAKE_CURRENT_SOURCE_DIR}/include>\"" FREETYPE_CMAKELISTS_CONTENTS "${FREETYPE_CMAKELISTS_CONTENTS}")
string(REPLACE " \${CMAKE_CURRENT_BINARY_DIR}/include\n \${CMAKE_CURRENT_SOURCE_DIR}/include" " \"\${CMAKE_CURRENT_BINARY_DIR}/include\"\n \"\${CMAKE_CURRENT_SOURCE_DIR}/include\"" FREETYPE_CMAKELISTS_CONTENTS "${FREETYPE_CMAKELISTS_CONTENTS}")
string(REPLACE "\${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config" "\"\${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config\"" FREETYPE_CMAKELISTS_CONTENTS "${FREETYPE_CMAKELISTS_CONTENTS}")
file(WRITE "${FREETYPE_DIR}/CMakeLists.txt" "${FREETYPE_CMAKELISTS_CONTENTS}") file(WRITE "${FREETYPE_DIR}/CMakeLists.txt" "${FREETYPE_CMAKELISTS_CONTENTS}")