Commit Graph

102 Commits

Author SHA1 Message Date
Ben Boeckel
a3f273b657 cmFindBase: Create find-v1 configure log events
Record `find_` command events in the configure log, except
`find_package` as it is far more complicated (and will have its own
event kind).

Note that testing only generates the events of interest, there is no
verification. Also note that testing that the "found" to "notfound"
transition causes an event is not testable because a truthy value in the
variable skips any kind of verification or other logic beyond
normalization.

Co-Authored-by: Ryan Krattiger <ryan.krattiger@kitware.com>
See: #24833
2025-04-28 13:55:36 +02:00
Marc Chevrier
3d2709c1ae Linker configuration: rely now on CMAKE_<LANG>_LINK_MODE variable.
CMake now provides the CMAKE_<LANG>_LINK_MODE variable which specify how
the link step is done. So, the CMAKE_<LANG>_USING_LINKER_MODE variable
is no longer needed.
2025-01-26 14:45:21 +01:00
Brad King
cbe7fc4b81 CMP0056: Remove support for OLD behavior 2025-01-21 09:44:05 -05:00
Brad King
4c4f173876 Clarify advice given by compatibility deprecation message for CMake < 3.10
Since commit 84db8506ff (Deprecate compatibility with CMake versions older
than 3.10, 2024-10-03, v3.31.0-rc1~23^2) the `cmake_minimum_required` and
`cmake_policy` commands warn if the project does not enable policies as
of 3.10 or higher.  Clarify the advice given in the warning message about
how to update the version specification, particularly without actually
requiring a newer minimum version of CMake.
2024-11-14 09:40:01 -05:00
Brad King
84db8506ff Deprecate compatibility with CMake versions older than 3.10
Issue a deprecation warning on calls to `cmake_minimum_required` or
`cmake_policy` that set policies based on versions older than 3.10.
Note that the effective policy version includes `...<max>` treatment.
Update the check from commit 3a4791548d (Deprecate compatibility with
CMake versions older than 3.5, 2023-02-09, v3.27.0-rc1~508^2).
2024-10-03 14:18:26 -04:00
Brad King
f4aa34daa7 Tests/RunCMake: Update cmake_minimum_required versions to 3.10
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.10 where possible.
2024-10-03 11:52:22 -04:00
Brad King
1d38d52995 Tests/RunCMake: Match diagnostic line numbers more robustly 2024-10-03 10:23:37 -04:00
Craig Scott
4cb5bb014d try_compile: Propagating top level includes into whole-project calls
Fixes: #24151
2024-05-30 19:01:03 +10:00
Craig Scott
98cc86e265 try_compile(): Include languages with _ or - when passing linker vars
Fixes: #25809
2024-03-22 21:35:51 +11:00
Brad King
04727ba21c Merge topic 'ninja-dev'
101ac06b28 Tests: Update for changes to upstream ninja development version

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !9053
2023-12-09 08:09:38 -05:00
Brad King
101ac06b28 Tests: Update for changes to upstream ninja development version
Account for:

* commit `8f47d5aa33` (Remove `-w dupbuild` completely, always error
                       on duplicate edges, 2023-11-29)
* commit `4d98903d4c` (Improve misleading error message when an output
                       is defined multiple times, 2023-12-06)
2023-12-08 09:04:44 -05:00
Brad King
264dcae5e4 Tests: Fix clang -Wstrict-prototypes warnings 2023-10-26 09:20:45 -04:00
Brad King
dc0dbffb0f Tests: Remove redundant policy setting from RunCMake.try_{compile,run} cases
Since commit 1edf138506 (Tests/RunCMake: Update cmake_minimum_required
versions, 2023-02-06, v3.27.0-rc1~508^2~1) policy CMP0054 is
automatically set to NEW in these tests.
2023-10-16 11:30:17 -04:00
Brad King
1edf138506 Tests/RunCMake: Update cmake_minimum_required versions
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.5 where possible.

Also, remove `cmake_minimum_required()` and `project()` calls from
individual cases where they are handled by `CMakeLists.txt`.
2023-02-11 06:24:22 -05:00
Brad King
5252c88569 try_compile: Record propagated CMake variables in configure log
These provide more detailed information about how the test project was
configured.

Issue: #23200
2023-02-01 09:32:42 -05:00
Brad King
7db4df2e8c Tests: Match configure log try_compile directories more precisely
Do not accept a double-quote in the `try_compile` work directory to
ensure we do not match more than the field value.
2023-01-24 15:25:10 -05:00
Brad King
f4d604f77f Merge topic 'try_compile-verbose'
faa950a155 try_compile: Run native build tool with verbose output

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8095
2023-01-23 10:34:37 -05:00
Brad King
526b2db5d3 Merge topic 'print-configure-generate-time'
5f0c5ec49b cmake: Print configure/generate time

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !8083
2023-01-20 09:32:45 -05:00
Brad King
faa950a155 try_compile: Run native build tool with verbose output
Make the compiler command lines visible in the configure log.

Issue: #23200
2023-01-20 09:17:51 -05:00
Kyle Edwards
5f0c5ec49b cmake: Print configure/generate time 2023-01-19 09:51:07 -05:00
Brad King
f6ed2585e5 Modules: Record system inspection steps in the configure log
Replace old-style `file(APPEND .../CMake{Output,Error}.log)` logging
with calls to `message(CONFIGURE_LOG)` to record the steps in the
`CMakeConfigureLog.yaml` configure log instead.

Issue: #23200
2023-01-18 17:59:10 -05:00
Brad King
95976514f6 Tests: Avoid using CMake{Output,Error}.log files
These log files will soon go away, so avoid using them in tests.
2023-01-18 16:40:19 -05:00
Brad King
48292c8624 try_compile: Record stack of in-progess checks in configure log
Many `try_compile` and `try_run` calls occur inside check modules
between `message(CHECK_START)` and `message(CHECK_{PASS,FAIL})` pairs.
Add a field to configure log entries to report this context.

Issue: #23200
2023-01-16 17:18:07 -05:00
Brad King
d4bf7d80c6 try_compile: Add a NO_LOG option to skip recording in the configure log 2023-01-16 17:16:12 -05:00
Brad King
9d9e8450a8 try_compile: Add optional LOG_DESCRIPTION to record in configure log
Issue: #23200
2023-01-16 16:58:50 -05:00
Brad King
0418efb7ad Tests: Add explicit ConfigureLog case to RunCMake.try_compile 2023-01-16 16:58:49 -05:00
Brad King
6c40e0b25e ConfigureLog: Version individual events instead of the whole log
In order to support multiple log versions without buffering the
entire log, move versioning to the level of individual events.
Multiple versions of an event may then be logged consecutively.

Issue: #23200
2022-12-16 10:12:25 -05:00
Matthew Woehlke
048a02d5bb ConfigureLog: Log try_compile and try_run checks
Add configure log events for `try_compile` and `try_run` results.

Issue: #23200
2022-12-16 10:12:25 -05:00
Brad King
af937d2933 Merge topic 'try_compile-copy-config'
80fc564dd7 try_compile: Restore COPY_FILE with CMAKE_TRY_COMPILE_CONFIGURATION

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Robert Maynard <robertjmaynard@gmail.com>
Merge-request: !7948
2022-11-23 07:09:10 -05:00
Brad King
80fc564dd7 try_compile: Restore COPY_FILE with CMAKE_TRY_COMPILE_CONFIGURATION
Since commit 0c141b0393 (try_compile: Record output location instead of
reverse computing it, 2022-08-31, v3.25.0-rc1~154^2) we always look for
the "Debug" configuration's output binary from the test project.
Restore looking for the `CMAKE_TRY_COMPILE_CONFIGURATION`.

Fixes: #24180
2022-11-22 11:26:28 -05:00
Brad King
bb2370842f Tests: Simplify RunCMake.try_compile compiler inspection
Detect the compiler id, version, and default standard level
in the test's inspection step rather than passing it all in
from the host CMake build's results.  This avoids repeating
details not known to older versions of CMake, and shortens
the code.
2022-10-31 13:04:28 -04:00
Brad King
1abcb094a7 Tests: Fix logic to enable RunCMake.try_compile OBJC/OBJCXX cases
CMake itself does not enable the OBJC/OBJCXX languages, so the
`CMAKE_OBJ{C,CXX}_STANDARD_DEFAULT` variables are never defined.
Detect them inside the test instead.
2022-10-31 13:01:51 -04:00
Brad King
eab9ddb744 Merge topic 'try_compile-CMP0128'
90287792b6 Tests: Avoid running C++11 test on GNU < 4.7

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7821
2022-10-25 14:26:18 -04:00
Brad King
883798edc4 Merge topic 'try_compile-CMP0128' into release-3.25
90287792b6 Tests: Avoid running C++11 test on GNU < 4.7

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7821
2022-10-25 14:26:17 -04:00
Brad King
90287792b6 Tests: Avoid running C++11 test on GNU < 4.7
The test added in commit 50e90e2828 (try_compile: Honor CMP0128 setting
in test project, 2022-10-18, v3.25.0-rc2~4^2) requires that the compiler
support C++11 mode, so do not run it on GNU compilers that are too old.
2022-10-24 12:04:57 -04:00
Brad King
188305800e Merge topic 'try_compile-CMP0128'
50e90e2828 try_compile: Honor CMP0128 setting in test project

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !7803
2022-10-19 09:57:09 -04:00
Brad King
177c56e3fa Merge topic 'try_compile-CMP0128' into release-3.25
50e90e2828 try_compile: Honor CMP0128 setting in test project

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !7803
2022-10-19 09:57:08 -04:00
Brad King
50e90e2828 try_compile: Honor CMP0128 setting in test project
Some projects pass a raw `-std=` flag to the compiler in the
`try_compile` project.  If they do not set CMP0128 to NEW,
we should not append a `-std=` flag where we did not before
the policy was added.

Fixes: #24063
2022-10-18 13:38:00 -04:00
Matthew Woehlke
7e6b2a92a0 try_compile: Report build dir with --debug-trycompile
When `--debug-trycompile` is enabled, issue a log (with trace) for every
`try_compile` noting what directory is being used for the compilation.
This will make it easier to find the corresponding artifacts.

Closes: #24022
2022-10-06 08:13:03 -04:00
Matthew Woehlke
0f28653ba9 try_compile: Rename SOURCE_FROM_ARG -> SOURCE_FROM_CONTENT
Change the SOURCE_FROM_ARG keyword to try_compile to SOURCE_FROM_CONTENT
(which we can do because it was recently added and hasn't been in a
release yet). The new name should be clearer as to what it does, and
also more consistent with the CONTENT arguments to some other commands.

Also, fix a typo in an error message.
2022-09-30 14:50:25 -04:00
Brad King
98aef0929f Merge topic 'try_compile-source-from'
611d801790 try_compile: Add SOURCE_FROM_FILE
a04eaf6742 Tests: Clean up and simplify TryCompile tests
cb14ae2b87 try_compile: Add SOURCE_FROM_{ARG,VAR}

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7700
2022-09-23 08:52:13 -04:00
Matthew Woehlke
611d801790 try_compile: Add SOURCE_FROM_FILE
Add ability to copy try_compile (and try_run) source files from
arbitrary locations into the operation directory. This is included for
the sake of completion and consolidation, although use cases which
actually require this may be rare.
2022-09-22 14:56:50 -04:00
Matthew Woehlke
cb14ae2b87 try_compile: Add SOURCE_FROM_{ARG,VAR}
Add ability to "feed" try_compile (and try_run) sources more directly,
either from literal content, or from a CMake variable which contains
literal content. This saves the user from needing a separate step to
write the content to a file, and allows for the sources to only exist in
the scratch directory.
2022-09-22 13:33:27 -04:00
Brad King
b15ddc766c Merge topic 'try_compile-more-consistent-errors'
30a234d275 try_compile: Improve error message consistency

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7696
2022-09-20 08:54:22 -04:00
Brad King
ea792d5812 Merge topic 'add-try_compile-test-documentation'
e933fccc7e Tests: document try_{compile,run} old/new signature testing

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7681
2022-09-19 10:18:04 -04:00
Brad King
33f314764d Merge topic 'improve-try_compile-arg-error'
f976800577 try_compile: More useful error if insufficient arguments

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7682
2022-09-19 10:17:02 -04:00
Matthew Woehlke
30a234d275 try_compile: Improve error message consistency
Tweak some error messages from try_compile (and try_run) to be more
consistent with each other.
2022-09-16 15:29:35 -04:00
Brad King
3436858697 Merge topic 'try_compile-new-project-signature'
56ae40cc59 try_compile: Add PROJECT keyword-dispatched signature

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7677
2022-09-16 10:26:27 -04:00
Matthew Woehlke
f976800577 try_compile: More useful error if insufficient arguments
Tweak try_compile and try_run to give a more informative error (rather
than "unknown error") when given an insufficient number of arguments.
2022-09-15 13:34:30 -04:00
Matthew Woehlke
e933fccc7e Tests: document try_{compile,run} old/new signature testing
Add a brief documentation blurb to the try_compile and try_run test sets
on writing tests for both "old" and "new" signatures.
2022-09-15 12:32:38 -04:00