mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
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
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
enable_language(C)
|
||||
enable_language(CXX)
|
||||
|
||||
# Warning options after the first entry are ignored for compatibility.
|
||||
set(CMAKE_REQUIRED_FLAGS
|
||||
"-DCHECK_REQUIRED_FLAGS -Drequired_flag_function=memcpy -Drequired_flag_library=memcpy -Drequired_flag_type=int"
|
||||
"-Wseen-by-cmake")
|
||||
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckIncludeFileCXX)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckPrototypeDefinition)
|
||||
include(CheckTypeSize)
|
||||
|
||||
check_function_exists(required_flag_function CHECK_FUNCTION_EXISTS_RESULT)
|
||||
check_include_file(CheckRequiredFlags.h CHECK_INCLUDE_FILE_RESULT)
|
||||
check_include_file_cxx(CheckRequiredFlags.h CHECK_INCLUDE_FILE_CXX_RESULT)
|
||||
check_include_files("stddef.h;CheckRequiredFlags.h" CHECK_INCLUDE_FILES_RESULT)
|
||||
check_library_exists("" required_flag_library "" CHECK_LIBRARY_EXISTS_RESULT)
|
||||
check_prototype_definition(
|
||||
required_flag_prototype
|
||||
"int required_flag_prototype(int value)"
|
||||
"value"
|
||||
"CheckRequiredFlags.h"
|
||||
CHECK_PROTOTYPE_DEFINITION_RESULT
|
||||
)
|
||||
check_type_size(required_flag_type CHECK_TYPE_SIZE_RESULT)
|
||||
|
||||
foreach(result IN ITEMS
|
||||
CHECK_FUNCTION_EXISTS_RESULT
|
||||
CHECK_INCLUDE_FILE_RESULT
|
||||
CHECK_INCLUDE_FILE_CXX_RESULT
|
||||
CHECK_INCLUDE_FILES_RESULT
|
||||
CHECK_LIBRARY_EXISTS_RESULT
|
||||
CHECK_PROTOTYPE_DEFINITION_RESULT
|
||||
CHECK_TYPE_SIZE_RESULT
|
||||
)
|
||||
if(NOT ${result})
|
||||
message(SEND_ERROR "${result} did not honor CMAKE_REQUIRED_FLAGS")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef CHECK_REQUIRED_FLAGS
|
||||
# error "CMAKE_REQUIRED_FLAGS was not honored"
|
||||
#endif
|
||||
|
||||
int required_flag_prototype(int);
|
||||
@@ -34,6 +34,7 @@ run_cmake(CheckIncludeFilesOkNoC)
|
||||
run_cmake(CheckIncludeFilesMissingLanguage)
|
||||
run_cmake(CheckIncludeFilesUnknownArgument)
|
||||
run_cmake(CheckIncludeFilesUnknownLanguage)
|
||||
run_cmake(CheckRequiredFlags)
|
||||
|
||||
block()
|
||||
# Set common variables
|
||||
|
||||
Reference in New Issue
Block a user