1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-21 04:01:40 +08:00

298 Commits

Author SHA1 Message Date
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Brad King
5394d79b35 Merge topic 'cxxmodules-obj-lib'
c09f8d27cd cxxmodules: compute link information for C++ module-consuming targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !9154
2024-01-17 09:36:45 -05:00
Matheus Izvekov
c09f8d27cd
cxxmodules: compute link information for C++ module-consuming targets
Compute link information for all C++ targets which support
modules instead of just those which may provide modules, as
they may import modules as well. This captures `OBJECT` libraries using modules
which otherwise do not have link steps.

Fixes: #25592
2024-01-14 14:14:26 -03:00
Brad King
a3f76a4e4d Merge topic 'link-stubs-transitively'
2c6ec6de15 Link to transitive dependencies on stub libraries only on some linkers
dd4a6dff92 Link explicitly to private transitive dependencies on stub libraries
5f1bbdb3b3 Tests: Enable RunCMake.RuntimePath test on more platforms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9050
2024-01-08 09:47:15 -05:00
Rafael Sadowski
1fafe35e81 Source: Restore compilation on OpenBSD
We cannot use `OpenBSD` as a name, it is defined in `sys/param.h`.
2024-01-05 15:36:44 -05:00
Brad King
2c6ec6de15 Link to transitive dependencies on stub libraries only on some linkers
Only linkers that enforce `--no-allow-shlib-undefined` recursively need
to link private transitive dependencies on stub libraries explicitly.
2024-01-04 11:59:26 -05:00
Brad King
dd4a6dff92 Link explicitly to private transitive dependencies on stub libraries
We represent stub libraries, e.g., for CUDA, using imported `SHARED`
library targets with only `IMPORTED_IMPLIB`, and no `IMPORTED_LOCATION`,
to indicate that the stub file is meant only for linkers and not dynamic
loaders.  See commit 7351d590ee (cmTarget: Add a way to represent
imported shared library stubs, 2023-07-17, v3.28.0-rc1~344^2) and commit
fc6508921c (cmComputeLinkInformation: Restore soname lookup for
non-imported targets, 2023-12-05, v3.28.0~4^2).

If a shared library is linked to a stub, it has a `NEEDED` field
populated with the `SONAME` found in the stub.  When a dependent target
links to such a shared library, some linkers want to find a library file
on disk and load it to see what symbols it provides.  This is necessary
for linkers that enforce `--no-allow-shlib-undefined`.  On hosts with
only the stub library installed, e.g., with only the CUDA toolkit
development package, the real runtime library corresponding to the
stub's `SONAME` may not even exist, so no `-rpath-link` flag can help
linkers find it.  Pass the stub library to linkers explicitly so they
can find it without searching.
2024-01-04 11:59:26 -05:00
Brad King
fc6508921c cmComputeLinkInformation: Restore soname lookup for non-imported targets
In commit 7351d590ee (cmTarget: Add a way to represent imported shared
library stubs, 2023-07-17, v3.28.0-rc1~344^2) we accidentally stopped
passing the SONAME of a non-imported SHARED library to our runtime
search path ordering logic.  Unfortunately I have not found a way to add
a test case for this, but it at least shouldn't regress existing tests
or those added by that commit.
2023-12-05 15:50:56 -05:00
Ben Boeckel
1175f1c874 LinkItem: track cmSourceFile instances for external objects
The target may be required in order to provide Fortran modules, so track
the source file so that the target may be looked up when needed.
2023-11-23 14:26:31 -05:00
Brad King
2744f14db1 codespell: Fix typos 2023-11-17 09:58:21 -05:00
Brad King
d7988ff6b8 Merge branch 'backport-target-objects' into target-objects 2023-11-14 15:42:07 -05:00
Brad King
377b78aef9 cmComputeLinkInformation: Simplify recording OBJECT libraries as link items
Simplify commit 2c7acd34e2 (cmComputeLinkInformation: add `OBJECT`
libraries as link items, 2023-07-24, v3.28.0-rc1~279^2) using the
existing local variables.
2023-11-14 15:40:29 -05:00
Brad King
50fdaf8f1f cmComputeLinkInformation: Track targets named by TARGET_OBJECTS sources
Since commit b6a5382217 (Ninja: depend on language module information
files directly, 2023-02-10, v3.27.0-rc1~502^2), the return value of
`cmCommonTargetGenerator::GetLinkedTargetDirectories` must account for
linked object libraries because they may provide modules (#25112).
These were added by commit b665966933 (cmComputeLinkInformation: track
OBJECT library dependencies, 2023-07-22, v3.27.1~5^2).  However, targets
named by `$<TARGET_OBJECTS:...>` sources are also needed (#25365).

The latter were added by commit 22da18b995 (Fortran: Restore support for
TARGET_OBJECTS providing modules, 2023-10-27, v3.28.0-rc4~9^2) and
commit 035302b7e3 (cmComputeLinkDepends: also copy the target from
object link items, 2023-10-27, v3.28.0-rc4~9^2~2).  However, their
approach added link entries not actually specified by projects.  It also
incorrectly re-used `cmComputeLinkDepends::AddLinkObject` for object
library targets when it is meant for their individual object files.
These problems caused additional regressions (#25417).  Revert the
implementation parts of those commits and leave behind an assertion and
comment to help avoid the mistake in the future.  Instead, track targets
named by `$<TARGET_OBJECTS:...>` sources with a dedicated member.

Issue: #25112
Issue: #25365
Fixes: #25417
Co-authored-by: Ben Boeckel <ben.boeckel@kitware.com>
2023-11-14 14:50:08 -05:00
Brad King
3a515b31b3 Merge topic 'modules-depends-via-target-objects' into release-3.28
22da18b995 Fortran: Restore support for TARGET_OBJECTS providing modules
64d9240564 cmComputeLinkInformation: skip over linking to items for object purposes
035302b7e3 cmComputeLinkDepends: also copy the target from object link items
861876b936 Tests/ObjectLibrary: fix comment

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !8923
2023-10-31 09:12:28 -04:00
Ben Boeckel
64d9240564 cmComputeLinkInformation: skip over linking to items for object purposes
If a name is only found because it is a link entry of kind `Object`, do
not add anything to the link line.
2023-10-27 15:52:01 -04:00
Brad King
787dde5569 Merge topic 'fortran-in-custom-targets'
d870a47e23 Tests/FortranModules: add a test for iface Fortran sources
e3d511fb9c Tests/FortranModules: also test INTERFACE targets with Fortran sources
978b68d3bb add_custom_target: Fix regression with Fortran sources
619aca80ae Tests/FortranModules: add a test case for #25223
45513c1a69 Tests/FortranModules: move issue 25112 fix from FortranOnly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8814
2023-09-20 10:16:18 -04:00
Ben Boeckel
978b68d3bb add_custom_target: Fix regression with Fortran sources
Since commit 74b1d6caf3 (cmComputeLinkInformation: compute link info for
module-using targets, 2023-09-05, v3.27.5~7^2) we accidentally try to
compute link information for custom targets if they have Fortran
sources.  For module dependencies, we only need to consider target types
that can compile.

Fixes: #25252
2023-09-20 09:14:58 -04:00
Ben Boeckel
045d8eca6c Merge branch 'fortran-object-libraries-release' into fortran-object-libraries
* fortran-object-libraries-release:
  cmComputeLinkInformation: compute link info for module-using targets
  cmGeneratorTarget: support config-independent Fortran source queries
2023-09-05 19:27:41 -04:00
Ben Boeckel
74b1d6caf3 cmComputeLinkInformation: compute link info for module-using targets
Targets which contain C++ module or Fortran sources need to participate
in link information unconditionally regardless of whether they actually
have link artifacts or not.

Fixes: #25223
2023-09-05 18:12:25 -04:00
Ben Boeckel
2c7acd34e2 cmComputeLinkInformation: add OBJECT libraries as link items
This completes the transition started in commit b665966933
(cmComputeLinkInformation: track OBJECT library dependencies,
2023-07-22).
2023-08-01 10:06:02 -04:00
Kyle Edwards
7050ac56a1 macOS: Add support for linking against .xcframework folders
Issue: #21752
2023-07-26 17:00:01 -04:00
Brad King
f8c3fd0c45 Merge topic 'dyndep-module-info-objlib-dependency'
b665966933 cmComputeLinkInformation: track OBJECT library dependencies
a99b87a628 Tests/RunCMake/CXXModules: add a test for issue #25112
2870a67540 Tests/FortranOnly: add a test case for issue #25112

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8645
2023-07-24 08:31:53 -04:00
Ben Boeckel
b665966933 cmComputeLinkInformation: track OBJECT library dependencies
In commit b6a5382217 (Ninja: depend on language module information files
directly, 2023-02-10), introduced via !8197, language-specific module
information files (`CMakeFiles/<target>.dir/<lang>Modules.json`) files
were added as real dependencies to the dyndep collation steps.
Previously, the behavior was to inform the collator of all possible
targets and search for the files manually ignoring those which did not
exist with ordering enforced by depending on the linker output of all
dependent targets. This behavior could lead to stale information being
used (e.g., if a target stops providing any targets) and also did not
reliably build everything needed on rebuilds. Afterwards, the internal
computation changed the dependency from all possible targets to an exact
set of "these targets might have modules" query, however one that did
not include `OBJECT` libraries since do not have `LinkEntry` items
internally (their objects are instead treated as source files).

As a stopgap measure, track `OBJECT` libraries in a separate list and
query them explicitly when gathering targets which may have interesting
information. Future work can add `LinkEntry` items to represent these
targets once all `LinkEntry` consumers have been audited to make sure
they are not surprised by any `OBJECT` library entries.

Fixes: #25112
2023-07-22 07:12:43 -04:00
Robert Maynard
7351d590ee cmTarget: Add a way to represent imported shared library stubs
Shared library stubs can be used for linking, but not at runtime.
Their role is similar to import libraries on Windows, so represent
their location with the `IMPORTED_IMPLIB` target property.

Fixes: #24940
2023-07-18 13:21:01 -04:00
Kyle Edwards
d605f728f7 macOS: Allow IMPORTED_LOCATION to be a framework folder
Issue: #24946
2023-06-23 12:07:18 -04:00
Marc Chevrier
bfa5b430b3 Apple text-based stubs: ensure runpath is correctly defined
This is a complement to !8204.
2023-06-04 15:29:42 +02:00
Marc Chevrier
241304190f CMake code rely on cmList class for CMake lists management (part. 2) 2023-04-29 09:54:31 +02:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Marc Chevrier
ce1bdec3a4 Xcode: Fix missing Frameworks search paths
Fixes: #24541
2023-03-06 09:15:48 -05:00
Marc Chevrier
fcbd723a50 Enhance support functions
* Avoid duplicate definiitions for IsExecutableWithExports, etc...
* Add helper IsApple()
2023-02-28 14:24:03 +01:00
Ben Boeckel
af08f9dc55 cmComputeLinkInformation: use characters where possible 2023-02-06 13:41:00 -05:00
Ben Boeckel
52ca45e485 cmComputeLinkInformation: combine string literals where possible 2023-02-06 13:40:36 -05:00
Ben Boeckel
41da256b02 cmComputeLinkInformation: use cmStrCat where appropriate 2023-02-03 15:54:50 -05:00
Kitware Robot
33abef7416 Revise C++ coding style using clang-format-15
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 15.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Fixes: #24315
2023-01-18 16:20:47 -05:00
Vitaly Stakhovsky
b3edfcf46e cmValue: Use operator* explicitly to convert to std::string; avoid extra call 2023-01-15 23:39:02 -05:00
Craig Scott
a817948423
Code comments: Fix trivial typos 2022-12-18 09:47:11 +11:00
Marc Chevrier
0bd3efffbc Genex LINK_LIBRARY: Add support for framework with postfix 2022-09-21 16:14:36 +02:00
Marc Chevrier
fc06450ff4 Apple: Fix regression when linking a framework with postfix
Fix a regression caused by commit 40178f3c90 (cmGlobalGenerator: Add
helper to split framework path, 2022-02-10, v3.24.0-rc1~661^2~1).

Fixes: #23961
2022-09-14 14:55:27 -04:00
Marc Chevrier
e8792da04b genex-LINK_LIBRARY: ensure correct generation inside LINK_GROUP genex
This fix ensures the following pattern is correctly handled:
$<LINK_GROUP:group_feat,$<LINK_LIBRARY:lib_feat,mylib>>

With:
CMAKE_LINK_GROUP_USING_group_feat = "—START_GROUP" "—END_GROUP"
CMAKE_LINK_LIBRARY_USING_lib_feat = "—PREFIX" "—LINK <LIBRARY>" "—SUFFIX"

Before the fix, we get the following generation:
—START_GROUP —PREFIX —LINK /path/to/mylib —END_GROUP —SUFFIX
—END_GROUP and —SUFFIX are in the wrong order

After the fix, we get the correct order:
—START_GROUP —PREFIX —LINK /path/to/mylib —SUFFIX —END_GROUP
2022-07-05 10:00:04 +02:00
Marc Chevrier
45ac71d8bc Ensure targets which are frameworks can be used freely
Ensure flag -F/path/to/framework is specified during compilation step
of consumers of the framework.

Fixes: #23336
2022-03-29 13:57:11 +02:00
Marc Chevrier
1777883f8b genex-LINK_(LIBRARY|GROUP) features: update variables behavior
Variable CMAKE_LINK_(LIBRARY|GROUP)_USING_<FEATURE>_SUPPORTED is evaluated
only if CMAKE_<LANG>_LINK_(LIBRARY|GROUP)_USING_<FEATURE>_SUPPORTED is not defined.

This new behavior enable to activate a feature globally on a platform and to disable
it for some compilers and languages.
2022-03-25 12:29:28 +01:00
Marc Chevrier
0a81ea1f12 Genex-LINK_GROUP: Add possibility to group libraries at link step
Fixes: #23121
2022-02-28 10:26:26 +01:00
Marc Chevrier
01ff75b2ff cmComputeDepends::LinkEntry: introduce enum to specify item type 2022-02-25 11:08:17 +01:00
Marc Chevrier
397ee55cd6 genex-LINK_LIBRARY: rename configuration variables
To be more consistent between genex and variables as well as
the forecomming LINK_GROUP genex, rename variable *_LINK_USING_<FEATURE>*
in *_LINK_LIBRARY_USING_<FEATURE>*
2022-02-16 18:34:28 +01:00
Marc Chevrier
a2cfa2da4f GenEx/LINK_LIBRARY: Add features for framework support on Apple 2022-02-15 10:53:33 +01:00
Marc Chevrier
40178f3c90 cmGlobalGenerator: Add helper to split framework path
cmComputeLinkInformation and cmGlobalXCodeGenerator now rely on
this method to handle framework paths.
2022-02-13 15:39:14 +01:00
Marc Chevrier
2a6b0415d7 $<LINK_LIBRARY>: Add LINK_LIBRARY_OVERRIDE target property
To enable the management of incompatible $<LINK_LIBRARY> declarations,
add LINK_LIBRARY_OVERRIDE and LINK_LIBRARY_OVERRIDE_<LIBRARY> target
properties.
2022-02-08 11:41:04 +01:00
Marc Chevrier
42965799b4 Genex: Add $<LINK_LIBRARY:...>
This generator expression offers the capability, for the link step, to
decorate libraries with prefix/suffix flags and/or adding any specific flag for each
library.

Fixes: #22812, #18751, #20078, #22703
2022-02-08 00:02:32 +01:00
Marc Chevrier
28d7432468 cmComputeLinkInformation: use cmComputeLinkDepends::LinkEntry
In preparation of support of genex $<LINK_LIBRARY:...>, propagate
cmComputeLinkDepends::LinkEntry instances to ensure to have, when needed,
all attributes attached to the link item.
2022-02-06 14:32:24 +01:00
Brad King
1a25f057da cmComputeLinkInformation: Add context to warning about linking a directory 2021-10-27 12:58:46 -04:00