xcode: add support for xcconfig files

Fixes: #18420
This commit is contained in:
Gregor Jasny
2022-03-24 22:01:09 +01:00
parent 183b6bbf51
commit 53ca6edd8a
18 changed files with 189 additions and 0 deletions

View File

@@ -141,6 +141,16 @@ endfunction()
XcodeRemoveExcessiveISystem()
function(XcodeXCConfig)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeXCConfig-build)
run_cmake(XcodeXCConfig)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(XcodeXCConfig-build ${CMAKE_COMMAND} --build . --config Debug)
run_cmake_command(XcodeXCConfig-build ${CMAKE_COMMAND} --build . --config Release)
endfunction()
XcodeXCConfig()
# Isolate device tests from host architecture selection.
unset(ENV{CMAKE_OSX_ARCHITECTURES})

View File

@@ -0,0 +1,20 @@
#ifndef BUILD_DEBUG
# error BUILD_DEBUG is undefined
#endif
#ifndef GLOBAL_DEBUG
# error GLOBAL_DEBUG is undefined
#endif
#ifndef TARGET_DEBUG
# error TARGET_DEBUG is undefined
#endif
#if GLOBAL_DEBUG != BUILD_DEBUG
# error GLOBAL_DEBUG does not match BUILD_DEBUG
#endif
#if TARGET_DEBUG != BUILD_DEBUG
# error TARGET_DEBUG does not match BUILD_DEBUG
#endif
void some_symbol()
{
}

View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.23)
project(XcodeXCConfig C)
set(CMAKE_XCODE_XCCONFIG "$<IF:$<CONFIG:Debug>,XcodeXCConfig.global.debug.xcconfig,XcodeXCConfig.global.release.xcconfig>")
add_library(somelib XcodeXCConfig.c)
target_compile_definitions(somelib PUBLIC "BUILD_DEBUG=$<IF:$<CONFIG:Debug>,1,0>")
set_target_properties(somelib PROPERTIES
XCODE_XCCONFIG "$<IF:$<CONFIG:Debug>,XcodeXCConfig.target.debug.xcconfig,XcodeXCConfig.target.release.xcconfig>"
)

View File

@@ -0,0 +1 @@
OTHER_CFLAGS = $(inherited) -DGLOBAL_DEBUG=1

View File

@@ -0,0 +1 @@
OTHER_CFLAGS = $(inherited) -DGLOBAL_DEBUG=0

View File

@@ -0,0 +1 @@
OTHER_CFLAGS = $(inherited) -DTARGET_DEBUG=1

View File

@@ -0,0 +1 @@
OTHER_CFLAGS = $(inherited) -DTARGET_DEBUG=0