CMake: Add macro to wrap C++ command line definitions for swiftc

Similar to the existing macros for compile options and link options,
this macro wraps the command line definitions for swiftc in a way that
avoids warnings about conditional compilation flags not having values.
This commit is contained in:
Andrew Kaster 2025-04-04 07:25:26 -06:00
parent d454108fcd
commit 5dc673e0c2
4 changed files with 12 additions and 3 deletions

View file

@ -14,6 +14,15 @@ macro(add_cxx_compile_options)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX,ASM>:${args}>)
endmacro()
macro(add_cxx_compile_definitions)
set(args "")
foreach(arg ${ARGN})
string(APPEND args ${arg}$<SEMICOLON>)
add_compile_options("SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xcc -D${arg}>")
endforeach()
add_compile_definitions($<$<COMPILE_LANGUAGE:C,CXX,ASM>:${args}>)
endmacro()
macro(add_cxx_link_options)
set(args "")
foreach(arg ${ARGN})

View file

@ -3,5 +3,5 @@ include_guard()
if (NOT APPLE AND NOT ANDROID)
find_package(Fontconfig REQUIRED)
set(HAS_FONTCONFIG ON CACHE BOOL "" FORCE)
add_compile_definitions(USE_FONTCONFIG=1)
add_cxx_compile_definitions(USE_FONTCONFIG=1)
endif()

View file

@ -18,7 +18,7 @@ if (NOT WIN32)
endif()
if (LINUX)
add_compile_definitions(_FILE_OFFSET_BITS=64)
add_cxx_compile_definitions(_FILE_OFFSET_BITS=64)
endif()
if (APPLE)

View file

@ -5,6 +5,6 @@ if (NOT APPLE)
find_package(Vulkan QUIET)
if (VulkanHeaders_FOUND AND Vulkan_FOUND)
set(HAS_VULKAN ON CACHE BOOL "" FORCE)
add_compile_definitions(USE_VULKAN=1)
add_cxx_compile_definitions(USE_VULKAN=1)
endif()
endif()