A command line tool which extracts build configurations for cmake, from existing xcode project.
Using hello in this repository as an example.
cd /path/to/this/repo
Generate cmake files from xcode project.pbxproj
mkdir -p cmake/
plutil -convert json -o cmake/project.json hello/project.pbxproj
./xcode-cmake.py -i cmake/project.json -o cmake/
It generates project-level build settings to cmake/xcode_attr.cmake
, and target-level build settings to cmake/${targetName}.cmake
. These files are included by CMakeLists.txt.
Then generate xcode project files using cmake.
mkdir -p build/
cmake -GXcode -S ./ -B build/
NOTE:
-
project.pbxproj refers to
Info.plist
by relative path(hello/Info.plist
), so the generatedcmake/hello.cmake
behaves the same. PutCMakeLists.txt
in the parent directory ofhello
if you want to include target-level cmake files. -
Included settings could be overwritten, provided that configuration variant is explicitly stated. See
set_target_properties
in CMakeLists.txt for example.
I hope cmake generated projects have xcode-default warnings enabled (see Xcode -> PROJECT -> Build Settings -> Apple Clang - Warnings).