1083 Commits
Author SHA1 Message Date
jcm a3ff10a963 Xcode: Propagate system include directories to Swift compiler
Previously, only non-system include directories would be propagated to
Swift. This meant that if, for example, an IMPORTED target contained a
Swift module, that module would not be found by a Swift consumer.

Fixes: #28097
2026-09-22 12:31:00 -05:00
Marc Chevrier a53691b73a cmCustomCommand: reduce raw pointer usage 2026-09-14 18:24:48 +02:00
Tor Arne Vestbø 90c03329dd Xcode: Honor generator expressions in XCODE_EMBED_<type>
Evaluate the XCODE_EMBED_<type> target property through the generator
expression evaluator before building the copy-files phase.  Xcode shares
one copy-files build phase across all configurations, so the embedded set
cannot vary by configuration.  Reject any expression whose result depends
on the configuration, matching the existing per-source diagnostic.

Fixes #28082
2026-09-11 16:45:25 +02:00
Brad King f2001c745f Merge topic 'target-types'
f1d7bedc4b TargetTypes: Improve use of imported target scope type
a5a9ec9113 TargetTypes: Extract target-related types to dedicated header

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12236
2026-07-02 08:00:51 -04:00
Matthew Woehlke a5a9ec9113 TargetTypes: Extract target-related types to dedicated header
Move some target related enumeration types from `cmStateTypes.h` to a
new header, as these really aren't "state" types. Also, make
`TargetType` a strongly-typed enumeration.
2026-07-01 14:44:11 -04:00
Anton Tokar de28f37ce4 Xcode: Propagate add_custom_command COMMENT to generated projects
Propagate the COMMENT section of add_custom_command(OUTPUT) as Xcode
Build Phase, if present. Otherwise fallback to the current behavior

Fixes: #27910
2026-07-01 12:10:03 -04:00
Marc Chevrier 6043014d1d source_group(): Add file set support 2026-06-23 14:55:26 +02:00
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
Marc Chevrier c06d409f12 FILE_SET: add SKIP_PRECOMPILE_HEADERS property support 2026-06-01 18:39:23 +02:00
halx99 5ff6ac07e8 Xcode: Fix target-name embedding overriding code-sign attributes
Multiple targets embedding the same internal framework dependency with
different code-signing attributes should not overwrite each other in the
generated `PBXBuildFile`.  Extend commit 0282429c5a (Xcode: Fix
XCODE_EMBED_FRAMEWORKS when settings differ across targets, 2024-12-02,
v4.0.0-rc1~358^2) to cover target names.

Remove `FileRefToEmbedBuildFileMap` entirely, forcing CMake to
instantiate a brand-new `PBXBuildFile` reference object with a unique
ref value for every separate target embedding action, matching Xcode's
native multi-target configuration behavior.

Fixes: #27850
2026-05-27 11:56:16 -04:00
Tor Arne Vestbø b34e15a07d Xcode: Don't add frameworks without absolute paths to Frameworks PBXGroup
We can't represent frameworks as PBXFileReferences unless we have
an existing absolute path, or are able to resolve relative paths
(including framework name only) to an SDK-root relative or absolute
path, which we don't do at the moment.

Which means we can't represent these frameworks in the Frameworks
group in the project, as they will have wrong paths and be shown
by Xcode as missing.
2026-05-19 14:48:59 -04:00
Tor Arne Vestbø 41f8011d61 Xcode: Don't add bare-name framework items to the link build phase
XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION moves non-target library
items with a known path into the "Link Binary With Libraries" build
phase, requiring a valid PBXFileReference. Framework items specified
without a directory component (e.g. $<LINK_LIBRARY:FRAMEWORK,Foundation>)
are stored as ItemIsPath::Yes in cmComputeLinkInformation, but their
value is just a bare name. This caused CreateXCodeFileReferenceFromPath
to CollapseFullPath the bare name against the current working directory,
producing a broken reference to a non-existent path that Xcode shows
as a missing file, and that results in failure to link the project.

We now check that a non-target framework item has a non-empty directory
component before allowing it into the link phase. Without a concrete
path we can't produce a valid PBXFileReference, so we fall back to
OTHER_LDFLAGS where the item is already correctly formatted as
-framework Name.
2026-05-11 22:22:20 +02:00
Brad King ac04c630e9 Merge topic 'vs-fortran'
ec06d16178 cmSourceGroup: Constify clients
f513867bc4 VS: Fix regression causing source accumulation across Fortran projects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11999
2026-05-04 10:10:10 -04:00
Brad King ec06d16178 cmSourceGroup: Constify clients
The generators do not need to modify the groups.
2026-05-01 10:43:32 -04:00
Evan Wilde 94faee3099 Swift: Add option to pass package name to swiftc invocation
Add a `Swift_PACKAGE_NAME` target property to specify the package name.

Fixes: #26886
2026-04-28 15:24:05 -04:00
Matthew Woehlke 1309532390 Diagnostics: Use new methods
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
2026-04-16 15:10:35 -04:00
Marc Chevrier 5c5b68f44e FILE_SET: Add support for the SOURCES type
Fixes: #27550
2026-03-31 09:49:59 +02:00
Tyler Yankee 858fdd426b add_custom_command: Disallow exe-suffixed targets in DEPENDS
Two targets whose names differ only in a `.exe` suffix create a
conflict when adding target- and file-level dependencies for a custom
command. Add CMP0212 to provide compatibility with the old behavior.

Issue: #27612
2026-03-23 09:50:46 -04:00
John Franklin Rickard e531e7420d Reduce string copies by using View function alternatives 2026-02-06 12:27:13 -05:00
Tyler YankeeandBrad King 98f9874703 cmake: Add per-language link flags for all target types
Previously, `CMAKE_<LANG>_LINK_FLAGS` was an undocumented variable used
for linking executables only. Re-spell that variable mirroring the
existing spellings for shared and module libraries, and add policy
CMP0210 to preserve compatibility.

Then, repurpose `CMAKE_<LANG>_LINK_FLAGS` to provide a variable to be
used for per-language link flags for all target types, along with a
per-configuration variant. These are added to the `<LINK_FLAGS>` rule
placeholder in the generators.

Fixes: #21934
Relates: #25620

Co-authored-by: Brad King <brad.king@kitware.com>
2026-01-31 19:37:09 -05:00
Tyler Yankee bc1847c70b cmLocalGenerator: De-duplicate target property link flags lookup 2026-01-29 15:30:55 -05:00
Tyler Yankee 33a1fc5693 cmLocalGenerator: De-duplicate linker flags lookup 2026-01-29 15:30:44 -05:00
Brad King 77dbfed17d cmGlobalXCodeGenerator: De-duplicate target creation flags lookup 2026-01-26 12:19:09 -05:00
Timon Sassor 452808f2a9 Xcode: Add developmentRegion and knownRegions project properties
Closes: #27436
2026-01-09 13:30:48 +01:00
Cristiano Carvalheiro caf6e782e1 cmSourceGroup: Move FindSourceGroup out of cmMakefile 2025-11-26 18:16:05 +00:00
Cristiano Carvalheiro de2afc5d53 cmMakeFile: Remove source groups argument from FindSourceGroup 2025-11-26 17:39:02 +00:00
Eduard Voronkin e42881422f FASTBuild: optimize try_compile builds
The generator does a lot of tricks in order to make the "rebuild-bff"
target up-to-date immediately after the generation. We can skip all of
those during "TryCompile" runs, which should reduce configure time.
2025-10-22 17:32:48 -07:00
Brad King 6fdb345f03 Merge topic 'sort-xcode-folders'
4ca5e5480a Xcode: Order targets alphabetically

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11289
2025-10-08 09:32:56 -04:00
Peter Steneteg 4ca5e5480a Xcode: Order targets alphabetically
Fixes: #21659
2025-10-07 11:07:11 -04:00
Craig Scott f38f325e08 fileAPI: Add direct dependencies to target codemodel files
This adds the following new arrays, which together capture all direct
dependencies and interface dependencies of a target:

- linkLibraries
- interfaceLinkLibraries
- compileDependencies
- interfaceCompileDependencies
- objectDependencies
- orderDependencies

Fixes: #21995, #25213
2025-10-07 10:44:28 -04:00
Brad King bef873755b Merge topic 'define-windll'
83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
206fcbb392 Tests/RunCMake/FileAPI: Fix whitespace in codemodel-v2 expectation data

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11194
2025-10-01 09:18:05 -04:00
AJIOB 83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
Visual Studio defines this automatically for `.dll` targets.
For consistency, define it when compiling for the MSVC ABI
with other generators.  Add policy CMP0203 for compatibility.

Fixes: #27253
2025-09-29 18:26:44 -04:00
Darryl Pogue e97fdf7d9a Xcode: Support new Icon Composer .icon resources
These are a new type of resource folder (treated as a file) similar to
xcassets, supported in Xcode 26 to provide application icons.
2025-09-28 01:45:56 -07:00
Ben Boeckel bbdc2fd908 cmSourceFile: internally track CMake-managed source files
These source file types don't necessarily show up in the CMake code, but
are side effects of other behaviors in CMake. Support tracking them
specially so that heuristics are not required to figure out if a given
`cmSourceFile` is one of them.
2025-09-08 11:59:57 -04:00
Daniel Pfeifer ee1c32b6d7 source: Pass cmBuildOptions by value 2025-07-30 11:55:34 -04:00
Stepanov Igor 0b7d8e4ad6 xcode: Restore ctest --build-and-test without --build-project
Previously, it used to be possible to execute ctest --build-and-test
without specifying --build-project. When used with the Xcode generator,
this would work as long as there was only one .xcodeproj file in the
directory, where xcodebuild would then default to using that project.
The recent changes to support .xcworkspace files broke that logic, placing
a malformed pair of options "-project .xcodeproj" on the command line
instead of omitting the "-project" option altogether.

Fixes: #27090
2025-07-26 19:43:28 +10:00
Stepanov IgorandCraig Scott 26869fb4ba cmake --build: Fix building multiple targets in Xcode workspace
Extend commit 844d79916a (cmake --build: Add support for driving Xcode
workspaces, 2025-06-02) to support multiple `--target` arguments.
`xcodebuild -scheme` cannot be repeated in a single call, so call it
multiple times instead.

Issue: #26958

Co-Authored-By: Craig Scott <craig.scott@crascit.com>
2025-06-14 16:53:25 +10:00
Brad King b59925a842 Merge topic 'xcode-build-workspace'
844d79916a cmake --build: Add support for driving Xcode workspaces

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10855
2025-06-11 10:26:54 -04:00
Stepanov IgorandBrad King 844d79916a cmake --build: Add support for driving Xcode workspaces
External tools may create a `.xcworkspace` directory next to the
`.xcodeproj` directory that CMake generates.  If a workspace exists,
drive the build through it instead.

Closes: #26958
Co-authored-by: Brad King <brad.king@kitware.com>
2025-06-10 11:08:04 -04:00
Brad King a2414480e8 cmGlobalXCodeGenerator: Remove unused argument from LookupFlags helper 2025-06-07 06:43:08 -04:00
Brad King 35317a7ae2 Xcode: De-duplicate -dynamiclib/-bundle flags for SHARED/MODULE libraries
Xcode automatically adds a flag matching the generated `LIBRARY_STYLE`:

* For SHARED libraries we've been duplicating `-dynamiclib` with a copy
  in `CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS`.  Remove it for Xcode.

* For MODULE libraries we've been not duplicating `-bundle` only by accident.
  Since commit 586a9427d3 (ENH: Created target property INSTALL_NAME_DIR...,
  2006-02-24, v2.4.0~418) we've looked up `CMAKE_<LANG>_LINK_FLAGS`, meant
  for EXECUTABLEs, instead of `CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS`.
  Switch to the latter, but remove `-bundle` for Xcode.
2025-06-07 06:43:08 -04:00
Brad King 5fdd4a5859 cmGlobalXCodeGenerator: Convert GetTargetProductType signature to string_view 2025-06-07 06:42:56 -04:00
Brad King ced6b31c48 cmGlobalXCodeGenerator: Convert CreateString signature to string_view 2025-06-07 06:36:49 -04:00
Ben Boeckel b82a74d918 generators: use GetSupportDirectory() in more places 2025-05-23 11:39:53 +02:00
Ben Boeckel 557c44b93e cmStrCat: use character literals where possible
Found and replaced using the `cmstrcat-to-char-literal` rule for
`ast-grep`.
2025-05-15 19:12:04 +02:00
Ben Boeckel 23779057fd cmStrCat: combine neighboring arguments where possible
Found using the `cmstrcat-adjacent-literals` rule for `ast-grep`.
2025-05-15 19:11:41 +02:00
Brad King 93cbcd7596 Merge topic 'xcode-debugger-workdir'
149ee3b4bc Xcode: Use DEBUGGER_WORKING_DIRECTORY as a fallback for scheme work dir
0f1b9ef32a Help: VS_DEBUGGER_WORKING_DIRECTORY precedence

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10736
2025-05-05 08:52:54 -04:00
Craig Scott 149ee3b4bc Xcode: Use DEBUGGER_WORKING_DIRECTORY as a fallback for scheme work dir
This also means when XCODE_SCHEME_WORKING_DIRECTORY is
set and a Xcode generator is used, that property will be used when
writing the debugger field in the file API replies.

Fixes: #26909
2025-05-03 10:16:15 -04:00
Brad King cacd17230f Merge topic 'apple-CoreFoundation-headers'
d736dafa22 Merge branch 'backport-3.31-apple-CoreFoundation-headers'
42390e7aa2 Source: Include specific CoreFoundation headers instead of umbrella header
14ffd1cc4e cmXCodeObject: Drop unused CoreFoundation header

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10616
2025-04-09 09:08:38 -04:00
Brad King d736dafa22 Merge branch 'backport-3.31-apple-CoreFoundation-headers' 2025-04-08 11:39:10 -04:00