Xcode: Definitions are not passed correctly to Swift
Hello,
I am using:
- CMake 3.22.2
- Xcode 13.4.1
I am having with an issue with target_compile_definitions
and Swift.
When generating an Xcode project, this leads to : swift-frontend ... -Xcc -DTEST ...
And so it is not passed down to Swift source
If I use target_compile_options
, I got the desired : swift-frontend ... -D TEST ...
Here is a minimal example to reproduce the issue
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(swift_definitions LANGUAGES Swift)
add_executable(test main.swift)
# This is not passed down to swift in CMake/Xcode
target_compile_definitions(test PUBLIC TEST)
# This a workaround
#target_compile_options(test PUBLIC -DTEST)
main.swift
#if TEST
print("TEST defined")
#else
print("TEST not defined")
#endif