24 Commits
Author SHA1 Message Date
Matthew Woehlke 3209535fb3 Check*: Restore toleration of false-like requirements
Commit 7644d557df (Check*: Refactor variable handling, 2026-07-20,
v4.4.1~12^2~1) introduced a subtle regression in the handling of
`CMAKE_REQUIRED_LINK_OPTIONS` and `CMAKE_REQUIRED_LIBRARIES` which
resulted in an error if these were set to a 'false-like' value. This
could happen, for example, if the user passes `<name>_LIBS`, which
happens to have the value `<name>-NOTFOUND`. Previously, such values
would be ignored.

Fix it by separately checking for user- or module-provided link options
or link libraries. (We were already doing this for the other variables
used to propagate requirements into checks.)

Fixes: #28026
2026-08-07 14:14:52 -04:00
Josef Šimánek fd6f2555d4 Tests: Cover CMAKE_REQUIRED_FLAGS in Check* modules
Commit a72e241200 (Check*: Restore more toleration of `;-W...` in
CMAKE_REQUIRED_FLAGS, 2026-07-21) updated the Check* modules to share
required-flag handling without adding coverage for those paths.
Exercise each probe with required definitions followed by a warning
option.

Without the compatibility handling, CMake rejects the warning option.
Without the required definitions, all seven checks fail to find their
header, functions, prototype, or type.

Issue: #28001
2026-07-29 17:27:21 -04:00
Matthew Woehlke 763cfbcac8 Diagnostics: "Fix" policy warnings in modules
Introduce a mechanism (via the private and undocumented `ISSUE_WARNING`
option to the `cmake_policy` command) to allow built-in modules to issue
policy warnings. Update modules to use this.

This allows modules to issue policy warnings with the `CMD_POLICY`
diagnostic type, which is consistent with internally issued diagnostics.
This also tends to simplify the logic for issuing such warnings in much
the way the helpers introduced in the previous commit did for the C++
code.
2026-05-20 15:32:57 -04:00
Matthew Woehlke 92e0ca9046 Diagnostics: Show author message for all descendants
Tweak `cmMessenger` to also show the "warning is for project developers"
notice for all diagnostics that are descendants of the `CMD_AUTHOR`
category. When doing so, also show both command-line options which can
suppress the message.
2026-05-15 09:57:23 -04:00
Matthew Woehlke b0f9852990 Diagnostics: Update tests (automated)
Update expected test output to account for the new format of diagnostic
messages. These changes were applied entirely by `sed` using the
following commands:

  - `/Use -Wno-dev to suppress/s/-Wno-dev/-Wno-author/g`
  - `s/Warning [\\][(]dev[\\][)]/Warning \\(author\\)/g`
  - `s/CMake Deprecation Warning/CMake Warning \\(deprecated\\)/g`

This is not a complete fix, but covers a significant fraction of the
needed changes, and this commit is strictly automated changes.
2026-04-16 15:10:35 -04:00
AJIOB 5de7a09e77 Tests/RunCMake: Match dots more precisely, part 3 2025-10-20 14:45:24 -04:00
AJIOB 06ccd15457 Tests/RunCMake: Match xxx.cmake file name more precisely 2025-10-16 17:42:12 +03:00
Hanna Rusakovich 638cf8f194 Tests/RunCMake: Match CMakeLists.txt file name more precisely 2025-10-15 09:39:01 -04:00
Peter Kokot 1b9812f701 CheckTypeSize: Add check_type_size(RESULT_VARIABLE)
Changes:
- Added new `RESULT_VARIABLE` keyword to enable customizing the name of
  the internal cache variable, which contains the boolean result of the
  check.
- The macro check_type_size() changed to function for easier arguments
  handling.
- Documentation synced and extended to better understand the
  check_type_size() command. Some typos fixed in the initial example.
- CheckTypeSize tests adjusted so also C++ is tested.
- Error messages slightly adjusted when checking the LANGUAGE argument.

Closes: #27202
2025-09-24 00:14:19 +02:00
Peter Kokot 9a3ad6f663 CheckTypeSize: Move tests 2025-09-24 00:13:48 +02: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
Aliaksandr Averchanka 9e95bd49f2 Check*: Add option to pass link directories into checks 2024-09-09 17:06:33 +03:00
Brad King 04b0d5c862 codespell: Fix typos 2023-05-22 16:51:15 -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 2b218883cd Add deprecation warnings for policies CMP0075 and below
The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for policies
introduced in CMake 3.12 and below to encourage projects to port
away from setting policies to OLD.
2020-10-13 14:36:00 -04:00
Brad King 9b99b4bfc8 Tests/RunCMake: Update cmake_minimum_required versions
Use 3.3 or 2.8.12 where possible.
2020-06-18 09:52:05 -04:00
Brad King a61ae3fb80 CheckIncludeFiles: Honor CMAKE_REQUIRED_LIBRARIES
Other check modules honor this variable, so include file checks should
too.  Add policy `CMP0075` to enable the behavior in a compatible way.

This change was originally made by commit v3.11.0-rc1~108^2
(CheckIncludeFiles: Honor CMAKE_REQUIRED_LIBRARIES, 2017-12-24) but it
was reverted by commit v3.11.1~9^2 (Revert "CheckIncludeFiles: Honor
CMAKE_REQUIRED_LIBRARIES", 2018-04-04) because the behavior change could
affect checks in existing projects in an incompatible way.

Fixes: #9514
2018-04-18 08:09:56 -04:00
David Adam b31d5e1dfd CheckIncludeFiles: improve warning for missing argument 2017-11-24 15:54:00 +08:00
David Adam ea1bb90270 CheckIncludeFiles: add unit tests 2017-11-11 23:04:05 +08:00
Stephen Kelly 73ae888506 RunCMake: Expect empty output by default.
Expect tests to specify stderr content if it is present.

Fix the CMP0019 test, which has only been testing the WARN status
until now.  Specify in the CommandLine and FPHSA tests that content
is at least one character.

Set policies in the Language and CheckModules tests, which have empty
test output, modulo unrelated policies on some platforms.
2014-12-31 16:34:34 +01:00
Daniele E. Domenichelli 7f857775e2 CheckTypeSize: Add unit test to cover the no-C case 2014-03-17 17:36:14 +01:00
Brad King 78be324762 Tests: Speed up RunCMake.CheckModules test
Enable the C and CXX languages only in the test cases that really need
them.  In the failure cases we do not get far enough to really use the
languages, so skip enabling them.
2014-02-06 11:12:50 -05:00
Daniele E. Domenichelli e6cec64820 CheckTypeSize: Add unit tests 2013-10-21 16:39:04 +02:00
Daniele E. Domenichelli 73d28d2177 CheckStructHasMember: Add support for C++
Previously if headers required to check if a struct has a member can be
compiled with C++ compiler only, the check would fail because the C
compiler fails.  As a consequence, the result variable would be set to
false, even if the struct has that particular member.

Teach CHECK_STRUCT_HAS_MEMBER to accept a new optional argument LANGUAGE
that allows one to explicitly set the compiler to use.  The new
signature is therefore:

  CHECK_STRUCT_HAS_MEMBER (<struct> <member> <header> <variable>
                           [LANGUAGE <language>])
2013-10-08 09:43:06 -04:00