CMake Top Level Xcode Project Properties
I recently needed the same thing so I had to look into the source code of CMake.
Currently, you can set attributes only for the targets and there is no way to set them on the project level.
However, it is possible to change ONLY_ACTIVE_ARCH
on the project level in a slightly different way. The implemented logic in cmake is the following (for version 2.8.12):
- If
CMAKE_OSX_ARCHITECTURES
is not set, then cmake setsONLY_ACTIVE_ARCH
toYES
on the project level, and depending on xcode version it sets default architectures to either$(ARCHS_STANDARD_32_64_BIT)
or$(ARCHS_STANDARD_32_BIT)
- If
CMAKE_OSX_ARCHITECTURES
is defined, thenONLY_ACTIVE_ARCH
becomesNO
I prefer to set CMAKE_OSX_ARCHITECTURES, so that XCode builds fat libraries and for the biggest libraries I just manually set ONLY_ACTIVE_ARCH to YES for Debug configuration only. This looks like that:
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")...set_target_properties(test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] "YES")