Commit Graph

43 Commits

Author SHA1 Message Date
Brad King
888259c894 CMP0022: Remove support for OLD behavior 2025-01-18 09:51:45 -05:00
Martin Duffy
7b553a3b1d cmExportInstallFileGenerator: Report errors with IssueMessage 2024-12-30 10:59:44 -05:00
Brad King
264dcae5e4 Tests: Fix clang -Wstrict-prototypes warnings 2023-10-26 09:20:45 -04:00
Brad King
84a1e529ee Tests: Fix failures on macOS arm64 due to Xcode 15 skipping ad-hoc signature
Update commit 1c15eb39d2 (Tests: Suppress failures on macOS arm64 due to
separate Xcode signing phase, 2021-02-22, v3.20.0-rc2~11^2) for Xcode 15,
which ignores our `-Xlinker -adhoc_codesign` flag, prioritizes its own
`-Xlinker -no_adhoc_codesign` flag, and does not add an ad-hoc signature
at link time.

Issue: #21845
2023-09-26 10:04:08 -04:00
Brad King
8c96d145c1 Tests/RunCMake: Match 'Tried extensions' output more robustly 2023-03-09 14:35:05 -05:00
Hyper Nova Sun
40dd46a96a Xcode: Add tests for OBJECT library per target OSX_ARCHITECTURES
Added test to cover handling of when `CMAKE_OSX_ARCHITECTURES` differs from
OBJECT library target's `OSX_ARCHITECTURES`:

TargetOverrideSingleArch:
- When `CMAKE_OSX_ARCHITECTURES` is set to multiple archs,
- But OBJECT library's `OSX_ARCHITECTURES` is set to single
- Assert that OBJECT library target "`HasKnownObjectFileLocation`" and is
  installable

TargetOverrideMultiArch:
- When `CMAKE_OSX_ARCHITECTURES` is set to single arch,
- But OBJECT library's `OSX_ARCHITECTURES` is set to multiple
- Assert that OBJECT library target does not "`HasKnownObjectFileLocation`"
  and hence not installable
2022-04-12 09:11:47 -07:00
Brad King
cb777dd81e Ninja Multi-Config: Restore TARGET_OBJECTS support in cross-configs
Since commit 2ae72ef74b (Xcode: Enable multi-arch TARGET_OBJECTS genex
in [INTERFACE_]LINK_LIBRARIES, 2021-05-26, v3.21.0-rc1~126^2) the
TARGET_OBJECTS genex, when referenced for linking, is now evaluated with
EvaluateForBuildsystem enabled.  This causes the object file paths to be
computed with a buildsystem-specific placeholder for the configuration.

This is normally fine because the placeholder will be evaluated by the
native buildsystem tool using the proper configuration.  However, the
Ninja Multi-Config generator's `${CONFIGURATION}` placeholder may not
have the correct value for cross-config object files.  Switch back to
using the per-config location of each object file for this generator.

Fixes: #22436
2021-07-21 11:46:15 -04:00
Brad King
5a8b37e53b Merge topic 'autogen-clear-early-source-cache'
b84f1e6159 Autogen: Restore mocs_compilation in OBJECT libraries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6024
2021-04-21 10:42:17 -04:00
Brad King
b84f1e6159 Autogen: Restore mocs_compilation in OBJECT libraries
Since commit f65f20938c (Autogen: Avoid processing CSharp targets,
2020-11-12, v3.20.0-rc1~301^2) we collect all sources for a target
earlier than previously.  Clear the sources cache so that it will be
re-computed later after AUTOGEN processing.

Fixes: #22085
2021-04-20 16:04:08 -04:00
Kyle Edwards
f31e8d33ef Genex: Fix grammatical error in TARGET_OBJECTS error message 2021-02-24 14:55:17 -05:00
Brad King
1c15eb39d2 Tests: Suppress failures on macOS arm64 due to separate Xcode signing phase
Some tests fail because Xcode runs `POST_BUILD` commands before signing
the binaries they run.  Tell the linker to perform ad-hoc codesign even
though Xcode normally tells it not to.

Other tests fail because `install_name_tool` does not revise ad-hoc
signatures without the codesign `linker-signed` flag.  Add that flag
ourselves where needed by our tests.

For now these changes help our test suite pass so we can use it to cover
everything else.  Both of these cases may need further investigation to
update CMake to help projects in general.

Issue: #21845, #21854
2021-02-22 15:47:13 -08:00
Craig Scott
4d46b1401f add_library(): Allow imported object libraries with multi-arch
Fixes: #21276
2021-02-06 11:34:28 +11:00
Robert Maynard
7628153edb Refactor file extension queries to be more consistent
It was very easy to forgot to check against all language file
extensions. This updates the internal API to have a unified API.
2020-06-22 09:13:16 -04:00
Brad King
4150a18910 Tests: Fix -Wstrict-prototypes warnings in some C sources
Some RunCMake tests fail with this warning due to extra stderr content:

    warning: this old-style function definition is not preceded by a prototype

Convert `foo()` to `foo(void)` in `.c` sources of affected tests.
2020-05-13 08:11:59 -04:00
Cristian Adam
fa93b4a59b Unity: Proper handling of object libraries
Fixes: #20051
2019-12-07 15:44:38 +01:00
Brad King
4891f0f966 Ninja: Ensure shared library version symlinks are created for dependents
When linking to a shared library target that has version symlinks, add
an order-only dependency on the build statement that creates the links.
This ensures that the links exist for use at runtime.

Fixes: #19774
2019-10-01 14:34:03 -04:00
Ben Boeckel
d17580909f cmExportInstallFileGenerator: improve error message
Following commit 49cfd390 (cmExportBuildFileGenerator: improve error
message, 2019-06-26), improve the error message related to installed
export sets by referencing the files which contain the exported target
ambiguously.
2019-08-20 10:15:03 -04:00
Kyle Edwards
8cc04b1918 cmake: Display error if generate step fails 2019-05-13 10:31:39 -04:00
Robert Maynard
ce078dda79 Relax the usage of TARGET_OBJECTS generator expression
The geneator expression can now be used with static, shared, and
module libraries and executables.
2019-04-19 13:52:50 -04:00
Kyle Edwards
bab24e782c target_link_libraries: Propagate dependencies of object libraries
Prior to this commit, linking against an object library did not
propagate private link dependencies of object libraries to their
consuming targets. This change implements the correct behavior.

Fixes: #18692
Co-Author: Brad King <brad.king@kitware.com>
2018-12-10 14:57:28 -05:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
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 6.0.

* 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.
2018-06-01 09:53:42 -04:00
Brad King
7776ce98c3 Tests: Add cases for usage requirements of linked object libs
Add tests to cover transitive usage requirements on installation and
export of targets that link to object libraries.

Issue: #14778
2018-03-01 09:28:00 -05:00
Deniz Bahadir
57538224d0 objlib: Link object-files from OBJECT libraries.
Note: This finally links the object-files of the `OBJECT` library from
the right-hand side of `target_link_libraries` to the target on the
left-hand side. However, this will only happen with directly linked
`OBJECT` libraries, not with `OBJECT` libraries "linked" through
property `INTERFACE_LINK_LIBRARIES` of a target on the right-hand side!

Fixes: #14778
2018-03-01 09:24:25 -05:00
Deniz Bahadir
9a7f039ee7 objlib: Allow OBJECT libraries to link to OBJECT libraries.
Note: This still does not link the object-files of the `OBJECT` library
from the right-hand side of `target_link_libraries` to the target on the
left-hand side. (In this particular case of another `OBJECT` library on
the left-hand side this would not make any sense anyway. The target on
the left-hand side has no link-step.)

Issue: #14778
2018-03-01 09:24:25 -05:00
Deniz Bahadir
dfb6e84082 objlib: Allow other libraries to link to OBJECT libraries.
Note: This only allows `OBJECT` libraries to be on the right-hand side
of `target_link_libraries` but still does not link its object-files to
the target on the left-hand side.

Issue: #14778
2018-03-01 09:24:24 -05:00
Deniz Bahadir
51249e69ea objlib: Allow OBJECT libraries to link to other libraries.
The proper way to use libraries is now through `target_link_libraries`
for things such as usage requirements, compile definitions, include
directories, etc. To facilitate this, allow `OBJECT` libraries to "link"
to other libraries.

Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
Issue: #14778
2018-03-01 09:24:24 -05:00
Brad King
ea0ce73a19 install,export: Maybe transform OBJECT libraries to INTERFACE libraries
Teach the `install` and `export` commands to support installing and
exporting `OBJECT` libraries without their object files.  Transform
them to `INTERFACE` libraries in such cases.

For `install(TARGETS)`, activate this when no destination for the object
files is specified.  For `export`, activate this only under Xcode with
multiple architectures when we have no well-defined object file
locations to give to clients.
2018-02-28 10:58:10 -05:00
Deniz Bahadir
b0e2f1415e target_link_libraries: Slightly fix some error-messages.
Some error-messages are slightly adjusted to better tell what
invocation would be correct instead. Tests are adjusted accordingly.
2017-11-29 17:01:47 +01:00
Brad King
d89e10cd58 Diagnose object library self-reference
The code

    add_library(A OBJECT a.c)
    target_sources(A PRIVATE $<TARGET_OBJECTS:A>)

used to crash CMake via infinite recursion while evaluating the
generator expression.  Then the change in commit v3.9.0-rc1~266^2~1
(cmGeneratorTarget: Replace source classifier implementation,
2017-04-07) avoided the infinite recursion because GetKindedSources now
creates a map entry and initializes it once.  If it is called again on
the same target during that initialization, the partially computed
results are returned.  This is still wrong but does not crash.
Detect and diagnose this case instead.

Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
Fixes: #16578
2017-07-14 14:05:22 -04:00
Robert Maynard
eec93bceec Allow OBJECT libraries to be installed, exported, and imported
Teach install() and export() to handle the actual object files.
Disallow this on Xcode with multiple architectures because it
still cannot be cleanly supported there.

Co-Author: Brad King <brad.king@kitware.com>
2017-04-18 11:36:10 -04:00
Brad King
b35a949bb6 Tests: Change RunCMake.ObjectLibrary dependencies case to C 2017-02-26 10:43:32 -05:00
Brad King
0134795418 Tests: Fix RunCMake.ObjectLibrary dependency delay
Sleep before the second copy to avoid the need for a touch.
Sleep for longer on generators whose build tools have low
resolution timestamps.
2017-02-26 10:43:30 -05:00
Gregor Jasny
624021a09e Add test for object library dependencies
Issue: #16615
2017-02-22 15:21:06 -05:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* 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.
2016-05-16 16:05:19 -04:00
Brad King
2c470b775a add_library: Allow arbitrary non-linked sources in OBJECT libraries
Loosen this restriction on OBJECT libraries to allow source files of any
name to be generated by custom commands or listed for reference in IDE
projects so long as they would not affect linking of a normal library.
Update the rejection message to be more specific about the looser
restriction.

Extend the ObjectLibrary test to cover a ".cmake" file generated by a
custom command in an OBJECT library.
2014-07-09 09:43:42 -04:00
Stephen Kelly
fdcefe3c42 cmGeneratorTarget: Compute consumed object libraries on demand.
Remove up-front object library computation from cmGlobalGenerator.

Adjust tests for message coming from the generator expression
evaluation.
2014-04-02 23:12:56 +02:00
Stephen Kelly
e5da9e51d0 cmTarget: Allow any generator expression in SOURCES property.
Remove use of UseObjectLibraries from Makefile and Ninja generators. It
is not needed now because those generators use GetExternalObjects
which already contains the objects from object libraries.

The VS10 generator calls both the UseObjectLibraries and the GetExternalObjects
methods. Ensure that duplicates are not created by skipping objects
from object libraries in handling of GetExternalObjects.

Similarly, fix VS6, VS7 and Xcode object handling by skipping
external objects from OBJECT_LIBRARY usage as appropriate.

The error message in the BadSourceExpression1 test is now reported
by the generator expression evaluator, so it has different text.
2014-04-02 23:12:56 +02:00
Brad King
53ac9b8d86 Merge topic 'object-library-missing-source'
5a2fc3d Check for OBJECT_LIBRARY source files at start of generation
2013-11-02 10:54:15 -04:00
Brad King
5a2fc3d696 Check for OBJECT_LIBRARY source files at start of generation
Teach cmGlobalGenerator::CheckTargets to include OBJECT_LIBRARY targets
in the check for source file existence.

Extend the RunCMake.ObjectLibrary test to cover this case.
2013-11-01 14:46:58 -04:00
Stephen Kelly
310aef959b Make ExportLanguages a subtest of the ObjectLibrary test
It was a subtest of the RunCMake.ObjectLibrary test. However, we need
to test a build with ExternalProject after running CMake, which RunCMake tests
do not do.
2013-10-24 19:05:34 +02:00
Brad King
d05a9bd1e6 Cygwin: Avoid legacy warnings in RunCMake.* tests
Set the minimum required version of CMake high enough to avoid the
warning for CMAKE_LEGACY_CYGWIN_WIN32.  The warning appears on stderr
and breaks the expected output matching.
2013-08-13 09:50:15 -04:00
Brad King
db7ef82402 Test OBJECT library language propagation
Teach the RunCMake.ObjectLibrary test to verify that languages used in
an OBJECT library are propagated to targets that use it so that the
languages can be included in link analysis.
2012-03-16 10:12:30 -04:00
Brad King
5683101669 Test OBJECT library failure cases
Add "RunCMake.ObjectLibrary" test to verify that unsupported use cases
are rejected with errors:

* An OBJECT library may not reference another object library
* An OBJECT library may not be referenced in target_link_libraries
* An OBJECT library may not contain non-compiling sources
* An OBJECT library may not have pre/post build/link commands
* An OBJECT library may not be installed, exported, or imported

Also verify that invalid $<TARGET_OBJECTS:...> expressions are
diagnosed.
2012-03-16 10:12:30 -04:00