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

271 Commits

Author SHA1 Message Date
Craig Scott
4cb5bb014d
try_compile: Propagating top level includes into whole-project calls
Fixes: #24151
2024-05-30 19:01:03 +10:00
Brad King
899af83755 Merge topic 'linker-vars-propagate-try_compile'
98cc86e265 try_compile(): Include languages with _ or - when passing linker vars

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9361
2024-03-24 14:33:31 -04: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
b814641444 VS: Add [CMAKE_]VS_USE_DEBUG_LIBRARIES options to control UseDebugLibraries
This indicates to MSBuild which configurations are considered debug
configurations.  This is useful for reference both by humans and tools.

Issue: #25327
2024-02-19 10:40:41 -05:00
Brad King
d101cb07ec Merge topic 'cmFileCopier-error-loss'
a820877d03 errors: avoid constructing a stream before getting the last error
5cf7018af6 cmFileCopier: remember error statuses and get their strings
0639a32d3a cmFileTimes: return status codes from APIs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9023
2023-12-05 09:23:49 -05:00
Ben Boeckel
a820877d03 errors: avoid constructing a stream before getting the last error
Constructing a stream may involve operations that change the global
error state. Avoid the streams by using `cmStrCat` instead.
2023-12-01 22:58:05 -05:00
Evan Wilde
c1d787e473 Swift: Add abstraction for compilation mode
Add a `CMAKE_Swift_COMPILATION_MODE` variable and corresponding
`Swift_COMPILATION_MODE` target property to control the compilation
mode.  Select among `wholemodule`, `singlefile`, and `incremental`.

Add policy CMP0157 to remove the default `-wmo` flags in favor of the
abstract setting.

Issue: #25366
2023-11-17 08:43:21 -05:00
Brad King
dd78592ba1 Merge topic 'try_compile-alias-targets'
8f9f371668 try_compile: Add support for using ALIAS targets
9f8aa94192 Add missing `OUTPUT` in ExportImport test

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8877
2023-10-17 10:22:54 -04:00
Brad King
c672e51bd3 Merge topic 'try_compile-linker-language'
0f37000304 try_{compile,run}: add LINKER_LANGUAGE option
dc0dbffb0f Tests: Remove redundant policy setting from RunCMake.try_{compile,run} cases

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8871
2023-10-17 10:18:56 -04:00
Cristian Le
8f9f371668 try_compile: Add support for using ALIAS targets
Fixes: #25337
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2023-10-16 20:22:23 +02:00
scivision
0f37000304 try_{compile,run}: add LINKER_LANGUAGE option
Fixes: #25326
2023-10-16 11:30:17 -04:00
Marc Chevrier
96a953b1ed Add options to specify linker tool
Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as
the target property `LINKER_TYPE` to specify which linker must be used.

The implementation of this capability is specified by variables specific
to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`.
Some definitions are provided as part of `CMake`.

For example, to select the `LLVM` linker rather than the standard one,
the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`.
And, on `Apple`, `Linux` and some environments on `Windows`, the variable
`CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows`
environments  based on `MSVC`, where the linker is used directly, the tool
`lld-link.exe` will be used rather than `link.exe`.

Fixes: #19174, #24254, #24990
2023-10-13 11:52:35 +02:00
Brad King
fd81024e80 cxxmodules: Honor CMAKE_CXX_SCAN_FOR_MODULES in try_compile
Under CMP0155's NEW behavior, projects that explicitly enable C++20
support with `set(CMAKE_CXX_STANDARD 20)` may also explicitly
disable scanning with `set(CMAKE_CXX_SCAN_FOR_MODULES OFF)`.
We already propagate `CMAKE_CXX_STANDARD` into `try_compile` test
projects, so propagate `CMAKE_CXX_SCAN_FOR_MODULES` too.

Fixes: #25313
2023-10-10 11:25:21 -04:00
Ben Boeckel
437280b127 cxxmodules: scan C++ sources for imports by default
Existing projects are not using C++ modules in their sources,
so introduce policy CMP0155 to enable scanning by default.
2023-10-02 10:17:31 -04:00
Ben Boeckel
0c07f39006 cmExperimental: remove the flag for C++ modules
All the major compilers now have scheduled releases with support for
scanning, so remove the experimental gate.

Fixes: #18355
2023-10-02 10:17:31 -04:00
Brad King
e43918b4ca HIP: Fix linking mixed-lang binary with CXX compiler and Makefile generators
Following commit 6377a43814 (CUDA: Support response files with nvcc,
2022-06-01, v3.25.0-rc1~636^2), while determining the compiler ABI, do
not use response files, so that we can extract implicit link flags.

Fixes: #25272
2023-09-25 16:06:36 -04:00
Brad King
127b6fa06b HIP: Add CMAKE_HIP_PLATFORM variable to specify GPU platform
For now, require the value to be `amd`, since that is the only
platform we currently support.
2023-09-21 15:34:37 -04:00
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