Commit Graph

18 Commits

Author SHA1 Message Date
Brad King
9e3b559b6a Tests: Update cmake_minimum_required versions to 3.10 2024-10-03 14:18:16 -04:00
Brad King
16c5977504 Fix per-config sources in multi-config generators when first config adds none
Since commit b1c3ae33ea (cmTarget: Short-circuit language computation if
context independent., 2014-04-09, v3.1.0-rc1~669^2~1) we've tried to
avoid repeating computation of the list of sources for a target for
every configuration in the case that a per-config source (or object
library) contributes zero sources.  However, it is possible that an
entry contributes zero sources in the first configuration processed but
at least one source in other configurations.

Fixes: #25400
2023-11-13 14:00:12 -05:00
Brad King
51f285b998 Merge topic 'tests-CMAKE_BUILD_TYPE-None'
ce1cadd35a Tests/ConfigSources: fix for non main stream CMAKE_BUILD_TYPE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5967
2021-04-05 11:37:50 -04:00
Đoàn Trần Công Danh
ce1cadd35a Tests/ConfigSources: fix for non main stream CMAKE_BUILD_TYPE
- None is a valid CMAKE_BUILD_TYPE
- Most of distros uses None as CMAKE_BUILD_TYPE
- When CMAKE_BUILD_TYPE=None, main_other.cpp will be compiled and linked
  into final executable, this program requires some symbols only exist
  when CUSTOM_CFG_OTHER is defined.
- And CMake also allows other CMAKE_BUILD_TYPE, too, CMake documentation
  specificaly mentions funny CMAKE_BUILD_TYPE like ReLeAsE [1]

Let's define them when non main stream like None is specified as CMAKE_BUILD_TYPE.

[1]: https://cmake.org/cmake/help/v3.20/variable/CMAKE_BUILD_TYPE.html
2021-04-02 08:07:46 +07:00
Chuck Atkins
a55feff69c Tests: Update for the Fujitsu compiler 2021-03-31 09:14:38 -04:00
Brad King
0dcc03cd16 Tests: Fix ConfigSources test with Intel compiler on Windows
The test regularly fails updating the `vc*.pdb` compiler-generated
PDB file.  Add the `/Z7` flag as the compiler suggests for this.
2021-01-06 11:13:03 -05:00
Brad King
ddd52aac54 Merge topic 'test-ConfigSources-config'
3af0671019 Tests: Fix ConfigSources test with empty CMAKE_BUILD_TYPE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5643
2020-12-22 13:49:29 -05:00
Brad King
3af0671019 Tests: Fix ConfigSources test with empty CMAKE_BUILD_TYPE
The test requires a non-empty `CMAKE_BUILD_TYPE` to function on
single-config generators.  Force a non-empty configuration if the test
is configured explicitly with empty `-DCMAKE_BUILD_TYPE=`.
2020-12-21 21:27:35 -05:00
Brad King
c257c25419 add_custom_{command,target}: Add genex support to OUTPUT and BYPRODUCTS
Move rejection of `#`, `<`, and `>` characters in outputs and byproducts
to a generate-time check.  This removes the front-end check that
disallowed generator expressions.  The generators have already been
updated to handle them.

Fixes: #12877
2020-12-11 08:24:21 -05:00
Deniz Bahadir
cd33bfcad5 add_custom_command: Properly recognize if sources depend on config
Fixes: #21349
2020-10-22 23:03:05 +02:00
Deniz Bahadir
2f76e7429b OBJECT libraries: Properly recognize if sources depend on configuration
Fixes: #21198
2020-09-23 10:05:55 -04:00
Brad King
70c85c1d6f Tests: Add case for source files named with CONFIG genex
This is now expected to work on all generators where the test runs.
Recent ancestors of this commit fix the Visual Studio generator.

Fixes: #20648
2020-05-18 15:34:18 -04:00
Brad King
25995b2b30 cmGlobalGenerator: Fix CheckTargetsForMissingSources after refactoring
Refactoring in commit 01b2d6ab74 (Modernize: Use ranged for-loops when
possible, 2019-02-07, v3.15.0-rc1~575^2) accidentally changed a loop
condition in this method from "keep iterating if srcs.empty()" to
"stop iterating if srcs.empty()".  Switch it back.

The bug could only manifest in very subtle conditions in a multi-config
generator.  Add one such case to the test suite.

Fixes: #20706
2020-05-15 05:39:25 -04:00
Brad King
6c5d4522bc INTERFACE_SOURCES: Fix per-config link libs on multi-config generators
In multi-config generators we memoize the computed set of source files
for a target to avoid repeating the computation when the set does not
depend on the configuration.  We already track whether generator
expressions in `SOURCES` or `INTERFACE_SOURCES` reference the
configuration (`$<CONFIG:...>`).  However, we previously forgot to track
whether the set of libraries whose `INTERFACE_SOURCES` are considered
depends on the configuration.  This caused multi-config generators to
use the first configuration's set of sources for all configurations
in cases such as

    target_link_libraries(tgt PRIVATE $<$<CONFIG:Debug>:iface_debug>)

where the `iface_debug` target has `INTERFACE_SOURCES`.

Fix this by also tracking config-dependence of the list of libraries for
evaluation of the list of source files.

Fixes: #20683
2020-05-12 12:44:32 -04:00
Brad King
9c9e66289a Tests: Enable ConfigSources test on every configuration
Revise the test itself to work in all configurations and verify that
certain sources are only built by whatever configuration is tested.
2019-10-04 10:39:00 -04:00
Stephen Kelly
bb5905bb13 cmTarget: Don't allow relative paths in INTERFACE_SOURCES
Follow the pattern of checks that are made for INTERFACE_INCLUDE_DIRECTORIES.
Existence is already checked by cmSourceFile::GetFullPath.  Add a check
to disallow relative paths in source directories. Otherwise code such as

 target_sources(lib1 INTERFACE foo.cpp)

would fail if consumed by a target in a different directory.

Unlike the INTERFACE_INCLUDE_DIRECTORIES behavior, we don't care whether
the entry comes from an IMPORTED target or not.  In the include directories
case, the directory for a non-imported target might not exist yet but
might be created.  In the sources case, a file which does not yet
exist in the filesystem must be explicitly marked with the GENERATED
property.

Adjust existing tests and add a new test for the error.
2014-11-29 12:24:59 +01:00
Stephen Kelly
3676fb4963 cmTarget: Allow transitive evaluation of SOURCES property.
Extend the cmGeneratorExpressionDAGChecker with an interface
returning the name of the top target.  Use that to determine
when there is a DAG violation, as required by the RunCMake.Languages
tests.
2014-04-02 23:14:02 +02:00
Stephen Kelly
e6971df6ab cmTarget: Make the source files depend on the config.
Disallow the use of config-specific source files with
the Visual Studio and Xcode generators. They don't have
any way to represent the condition currently.

Use the same common-config API in cmQtAutoGenerators. While
it accepts config-specific files, it doesn't have to support
multiple configurations yet.

Loop over the configs in cmTargetTraceDependencies
and cmGlobalGenerator::WriteSummary and consume all source
files.

Loop over the configs in cmComputeTargetDepends and compute the
object library dependencies for each config.
2014-04-02 23:14:02 +02:00