CMake updates of project.pbxproj file are ignored by Xcode
> ls
CMakeLists.txt boo.cpp
> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.11)
project(foo)
add_executable(foo boo.cpp)
> cmake -H. -B_builds -G Xcode
> mv boo.cpp bar.cpp
> gsed -i 's,boo,bar,' CMakeLists.txt
> cmake --build _builds --config Release
CMake run configure again since CMakeLists.txt changed but Xcode don't see these changes:
=== BUILD AGGREGATE TARGET ZERO_CHECK OF PROJECT foo WITH CONFIGURATION Release ===
Check dependencies
...
-- Configuring done
-- Generating done
-- Build files have been written to: /.../_builds
=== BUILD TARGET foo OF PROJECT foo WITH CONFIGURATION Release ===
clang: error: no such file or directory: '/.../boo.cpp'
clang: error: no input files
** BUILD FAILED **
Even if bar.cpp
is in project.pbxproj
:
> grep bar.cpp _builds/foo.xcodeproj/project.pbxproj
59...EF /* /.../bar.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = bar.cpp; path = bar.cpp; sourceTree = SOURCE_ROOT; };
As a simple workaround that can be introduced in CMake you can always run ZERO_CHECK
target first, which is similar to doing:
cmake --build _builds --target ZERO_CHECK && cmake --build _builds
> cmake --version
cmake version 3.11.0-rc4
> xcodebuild -version
Xcode 9.2
Build version 9C40b