Files
cmake/Tests/RunCMake/XcodeProject/DeterministicProductIds.cmake
lapfelix 2cc75c6072 Xcode: Use deterministic object ids for product file references
Follow-up commit 1fa2ec1bbd (Xcode: Use deterministic object ids for
targets, 2024-04-04, v3.30.0-rc1~263^2).  Each target's product
PBXFileReference (the libfoo.a / foo entries under the Products group)
was created with a random object id on every regeneration.  When a
CMake-generated Xcode project is embedded in another Xcode project, that
parent keeps the product reference's id in its remoteGlobalIDString; a
random id means the reference no longer resolves and the link falls back
to a bare `-l` flag (e.g. `ld: library 'foo' not found`).

Derive the product PBXFileReference id from the target name and the
build-tree-relative product path, the same hashing path already used for
the target object id.  The id is now stable across regenerations and
independent of the absolute build tree location.
2026-06-17 09:59:31 -04:00

11 lines
426 B
CMake

enable_language(C)
# Each target's product PBXFileReference must get a deterministic object id so
# that a parent project embedding this one can keep a stable remoteGlobalIDString.
add_library(productStatic STATIC empty.c)
add_library(productShared SHARED empty.c)
add_executable(productExe empty.c)
# A target in a subdirectory exercises the relative-path component of the key.
add_subdirectory(DeterministicProductIdsSub)