Commit Graph

254 Commits

Author SHA1 Message Date
Ben Boeckel
deb1c3cbd5 cmCoreTryCompile: forward module-related binutils variables 2023-07-31 11:59:50 -04:00
Ben Boeckel
b768d293c5 cmCoreTryCompile: use the source type context for source files
Also add a test to `RunCMake/CXXModules` to test `try_compile` with C++
modules.

Fixes: #25097
2023-07-31 11:59:47 -04:00
Ben Boeckel
c9ca5f6326 cmCoreTryCompile: parse SOURCES_TYPE argument
This will serve to add context for the source listing in order to
properly mark sources as `FILE_SET TYPE CXX_MODULES` in the generated
code.
2023-07-31 11:37:47 -04:00
Ben Boeckel
07551f35de cmCoreTryCompile: use target_sources for try_compile targets
In order to support using C++ module sources in `try_compile`,
`target_sources` will be required. To prepare, always use the command.
2023-07-31 11:37:47 -04:00
Ben Boeckel
aad9033b56 cmExperimental: support forwarding associated variables to try_compile
Other variables may be needed to make experimental features actually
work. List them with the experimental flag.
2023-07-31 11:37:47 -04:00
Ben Boeckel
f6cf433256 cmExperimental: only forward C++ module support to non-ABI checks
ABI checks never use modules, so don't forward the experimental status
through.
2023-07-31 11:37:47 -04:00
Ben Boeckel
1a538ae07c cmExperimental: use an enum for whether to forward to try_compile 2023-07-31 11:37:47 -04:00
Brad King
241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Ben Boeckel
884c477545 cmCoreTryCompile: combine strings where possible 2023-07-19 16:31:31 -04:00
Ben Boeckel
b8fd1cc8d9 cmCoreTryCompile: use single characters where possible 2023-07-19 16:30:27 -04:00
Ben Boeckel
0b74471d62 cmCoreTryCompile: use cmStrCat where possible 2023-07-19 16:30:27 -04:00
Kyle Edwards
d84681d8f0 try_compile(): Pass down CMAKE_EXPERIMENTAL_* feature flags 2023-07-17 16:53:52 -04: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
ede33f30cf Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
2023-03-01 12:23:28 +01: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
9ee57226bc clang-format: Add comments to suppress some formatting
Preserve manually-formatted blocks.
2023-01-18 16:19:27 -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
65ed5c2ca8 try_compile: Report underlying error when COPY_FILE fails 2023-01-16 16:58:49 -05:00
Craig Scott
ba981bb2ed TryCompileCode(): Prevent warning on return value
Some newer compilers warn in situations where the returned local
variable could be movable, but a C++11 defect meant older compilers
may still return a copy when a type conversion is involved. Adding
the suggested std::move prevents that warning on that compiler, but
creates a new warning on others. Constructing the actual return type
explicitly with the suggested std::move on the constructor argument
keeps both sets of compilers happy.
2022-12-30 10:42:55 +11: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
fdda4095a3 cmCoreTryCompile: Return more semantic information from compile step
Update the `TryCompileCode` signature to allow callers to distinguish
between administrative failures and a compilation failure.  Return
results in a structure to which more information can be added later.
2022-12-14 11:42:29 -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
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
Matthew Woehlke
09b3051524 try_compile: Add NO_CACHE option (also try_run)
Add NO_CACHE option to try_compile and try_run, which places the results
in regular, rather than cache, variables.

Issue: #22799
2022-09-28 13:41:11 -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
Brad King
3a1db0f3ad Merge topic 'try_run-no-project'
aac542f2f1 try_run: Remove PROJECT support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7702
2022-09-23 08:44:23 -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
Matthew Woehlke
aac542f2f1 try_run: Remove PROJECT support
Remove PROJECT support from try_run; it was never tested, has never been
documented, and it's unclear how it should even work (since CMake
wouldn't know what executable to run).
2022-09-21 15:38:06 -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
Matthew Woehlke
56ae40cc59 try_compile: Add PROJECT keyword-dispatched signature
Introduce a new signature for the project flavor of try_compile (and
try_run) which removes the `bindir` argument and adds a required PROJECT
tag. This is similar to the SOURCES flavor added by commit aa9220d3
(try_compile: Add keyword-dispatched signature, 2022-09-02).
2022-09-14 16:35:50 -04:00
Brad King
c3e68020d6 Merge topic 'MsvcDebugInformationFormatAbstraction'
a858466aac MSVC: Add test for debug information format
0e96a20478 MSVC: Add abstraction for debug information format
d4c8111da4 Clang/Windows: Clarify name of internal runtime library flags variables

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7606
2022-09-14 09:21:27 -04:00
Glen Chung
0e96a20478 MSVC: Add abstraction for debug information format
Replace our hard-coded default for `/Zi` with a first-class abstraction
to select the debug information format an enumeration of logical
names.  We've long hesitated to do this because the idea of "debug
information format" touches on related concepts on several platforms.
Avoid that scope creep by simply defining an abstraction that applies
only when targeting the MSVC ABI on Windows.

Removing the old default flag requires a policy because existing
projects may rely on string processing to edit them and choose a
runtime library under the old behavior.  Add policy CMP0141 to
provide compatibility.

Fixes: #10189
2022-09-14 09:12:47 -04:00
Robert Maynard
0c141b0393 try_compile: Record output location instead of reverse computing it
Fixes #23887, #23942, #20163, #18288
2022-09-07 15:08:41 -04:00
Matthew Woehlke
aa9220d3a0 try_compile: Add keyword-dispatched signature
Introduce a new signature for try_compile (and try_run) which removes
the `bindir` argument and requires the SOURCES tag. This will eventually
allow us to add other ways of providing sources, but also allows us to
change the behavior without breaking compatibility.

The old signature uses a special, but non-unique temporary location
inside the specified `bindir`, which conventionally is just the
project's build directory. The new signature unconditionally uses the a
unique temporary directory which is unconditionally within the project's
build directory (which is no longer separately specified). This ensures
that successive runs do not overwrite previous runs, will simplify
debugging, and should also, eventually, allow us to execute multiple
trials in parallel.
2022-09-05 13:19:59 -04:00
Matthew Woehlke
b976b844d2 try_compile: Don't accept try_run arguments
Modify cmCoreTryCompile to only recognize try_run arguments when
actually parsing try_run. (The old behavior was to recognize try_run
arguments for try_compile also and then complain.)

This has a small chance that a try_run keyword will be consumed as part
of a multi-valued keyword argument. However, this behavior is more
consistent with other commands, as we don't normally treat keywords as
universally reserved. Also, the code is noticeably simplified.
2022-08-17 15:44:35 -04:00
Matthew Woehlke
24c83bb35b try_compile: Fix quotes in reporting of unknown arguments
In commit 6b427d8da9 (cmCoreTryCompile: Port to cmArgumentParser,
2022-08-01) we inadvertently dropped a matching quote during refactoring
of reporting unknown arguments given to try_compile/try_run.  Add the
missing quote to match the old behavior and not have an imbalanced quote
in the warning.
2022-08-17 15:44:29 -04:00
Brad King
6b427d8da9 cmCoreTryCompile: Port to cmArgumentParser 2022-08-02 12:54:56 -04:00
Brad King
067ba3a2bd cmCoreTryCompile: Move target type selection logic to try_compile
This is specific to `try_compile` since `try_run` always needs an
executable.  Move the logic out of the common code path.
2022-08-02 08:04:21 -04:00
Brad King
781e1b191a cmCoreTryCompile: Simplify TryCompileCode return type
The return value is only used as a boolean, so use `bool`.
2022-08-02 08:04:20 -04:00
Brad King
7a5b1b6010 cmCoreTryCompile: Select source-file signature project/target names earlier 2022-07-26 15:09:48 -04:00
Brad King
8b0ee799e4 cmCoreTryCompile: Compute src-file signature build directory earlier 2022-07-26 15:09:48 -04:00
Brad King
7ba3a3290f try_compile: Refactor positional arg parsing 2022-07-26 14:44:42 -04:00
Brad King
31ee3cd49d try_compile: Fail earlier when bindir is not an absolute path
If the bindir is not an absolute path, other errors occur later.
Fail early with a clear error in this case.
2022-07-26 14:41:28 -04:00
Brad King
6940a67d47 Merge topic 'try_compile-cross-app-bundles'
81549baff4 try_compile: Fix COPY_FILE with app-bundles on non-macOS hosts

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7377
2022-06-17 11:31:38 -04:00