From 743f8a3a0a798bdb7df2aed8bbef50aec9801ffb Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 4 Apr 2025 07:25:26 -0600 Subject: [PATCH] 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. --- Meta/CMake/common_compile_options.cmake | 9 +++++++++ Meta/CMake/fontconfig.cmake | 2 +- Meta/CMake/lagom_compile_options.cmake | 2 +- Meta/CMake/vulkan.cmake | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Meta/CMake/common_compile_options.cmake b/Meta/CMake/common_compile_options.cmake index 30863769dfb..87c01fd9224 100644 --- a/Meta/CMake/common_compile_options.cmake +++ b/Meta/CMake/common_compile_options.cmake @@ -14,6 +14,15 @@ macro(add_cxx_compile_options) add_compile_options($<$:${args}>) endmacro() +macro(add_cxx_compile_definitions) + set(args "") + foreach(arg ${ARGN}) + string(APPEND args ${arg}$) + add_compile_options("SHELL:$<$:-Xcc -D${arg}>") + endforeach() + add_compile_definitions($<$:${args}>) +endmacro() + macro(add_cxx_link_options) set(args "") foreach(arg ${ARGN}) diff --git a/Meta/CMake/fontconfig.cmake b/Meta/CMake/fontconfig.cmake index 4ea63d69bee..84556ae59b2 100644 --- a/Meta/CMake/fontconfig.cmake +++ b/Meta/CMake/fontconfig.cmake @@ -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() diff --git a/Meta/CMake/lagom_compile_options.cmake b/Meta/CMake/lagom_compile_options.cmake index 022d32c2f57..671d39e729c 100644 --- a/Meta/CMake/lagom_compile_options.cmake +++ b/Meta/CMake/lagom_compile_options.cmake @@ -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) diff --git a/Meta/CMake/vulkan.cmake b/Meta/CMake/vulkan.cmake index c9847706dce..41b457f9353 100644 --- a/Meta/CMake/vulkan.cmake +++ b/Meta/CMake/vulkan.cmake @@ -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()