From 5555284a70ec747ee82a79a1cc3a3bd85ecadd55 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 7 Jan 2023 16:55:32 +0100 Subject: [PATCH] cmake: use target_compile_options to use -idirafter for khronos headers --- CMakeLists.txt | 9 ++++++--- cmake/macros.cmake | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a0e0b8b6..7417aa5f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,10 +301,13 @@ target_include_directories(sdl-build-options ) # Note: The clang toolset for Visual Studio does not support the '-idirafter' option. if(USE_GCC OR (USE_CLANG AND NOT MSVC_CLANG)) - # !!! FIXME: do we _need_ to mess with CMAKE_C_FLAGS here? - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -idirafter \"${SDL3_SOURCE_DIR}/src/video/khronos\"") + if(CMAKE_VERSION VERSION_LESS 3.12) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -idirafter \"${SDL3_SOURCE_DIR}/src/video/khronos\"") + else() + target_compile_options(sdl-global-options INTERFACE "SHELL:-idirafter \"${SDL3_SOURCE_DIR}/src/video/khronos\"") + endif() else() - target_include_directories(sdl-build-options INTERFACE "${SDL3_SOURCE_DIR}/src/video/khronos") + target_include_directories(sdl-global-options INTERFACE "${SDL3_SOURCE_DIR}/src/video/khronos") endif() # All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 5e38a7b94..a3ed37c62 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -78,10 +78,15 @@ function(listtostr LIST OUTPUT) # Do not use string(REPLACE ";" " ") here to avoid messing up list entries set(res) foreach(ITEM ${${LIST}}) + string(SUBSTRING "${ITEM}" 0 6 start) + if(start STREQUAL "SHELL:") + string(SUBSTRING "${ITEM}" 6 -1 ITEM) + endif() if(ITEM) set(res "${res} ${LPREFIX}${ITEM}") endif() endforeach() + string(STRIP "${res}" res) set(${OUTPUT} "${res}" PARENT_SCOPE) endfunction() @@ -96,8 +101,13 @@ function(listtostrrev _LIST _OUTPUT) # entries set(res) foreach(_ITEM ${${_LIST}}) + string(SUBSTRING "${_ITEM}" 0 6 start) + if(start STREQUAL "SHELL:") + string(SUBSTRING "${_ITEM}" 6 -1 _ITEM) + endif() set(res "${res} ${_LPREFIX}${_ITEM}") endforeach() + string(STRIP "${res}" res) set($_OUTPUT} "${res}" PARENT_SCOPE) endfunction()