diff options
author | Brad King <brad.king@kitware.com> | 2018-04-19 12:23:05 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-19 12:23:08 (GMT) |
commit | 3c6388553aef091556b64daf9bcb6f64fbdcdba2 (patch) | |
tree | 66c10261df25155548db1db3d4568ad29157c80c | |
parent | 6c13ddd6cb0c51afd2789db34b41416b5706336b (diff) | |
parent | a61ae3fb8017a297bd3f3efc447a1f1f29619bdf (diff) | |
download | CMake-3c6388553aef091556b64daf9bcb6f64fbdcdba2.zip CMake-3c6388553aef091556b64daf9bcb6f64fbdcdba2.tar.gz CMake-3c6388553aef091556b64daf9bcb6f64fbdcdba2.tar.bz2 |
Merge topic 'CheckIncludeFile-required-libs'
a61ae3fb80 CheckIncludeFiles: Honor CMAKE_REQUIRED_LIBRARIES
391a5837ee cmake_policy: Add undocumented PARENT_SCOPE option to GET
3c47ac5b25 OpenWatcom: Add workaround for lack of error on missing library
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1978
-rw-r--r-- | Help/manual/cmake-policies.7.rst | 1 | ||||
-rw-r--r-- | Help/policy/CMP0075.rst | 26 | ||||
-rw-r--r-- | Help/release/dev/CheckIncludeFile-required-libs.rst | 14 | ||||
-rw-r--r-- | Modules/CheckIncludeFile.cmake | 27 | ||||
-rw-r--r-- | Modules/CheckIncludeFileCXX.cmake | 27 | ||||
-rw-r--r-- | Modules/CheckIncludeFiles.cmake | 27 | ||||
-rw-r--r-- | Source/cmCMakePolicyCommand.cxx | 9 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 6 | ||||
-rw-r--r-- | Source/cmMakefile.h | 3 | ||||
-rw-r--r-- | Source/cmPolicies.h | 5 | ||||
-rw-r--r-- | Source/cmStateSnapshot.cxx | 8 | ||||
-rw-r--r-- | Source/cmStateSnapshot.h | 3 | ||||
-rw-r--r-- | Tests/PolicyScope/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CheckModules/CMP0075-stderr.txt | 50 | ||||
-rw-r--r-- | Tests/RunCMake/CheckModules/CMP0075.cmake | 124 | ||||
-rw-r--r-- | Tests/RunCMake/CheckModules/RunCMakeTest.cmake | 2 |
17 files changed, 337 insertions, 10 deletions
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 7e2255d..631f75b 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.12 .. toctree:: :maxdepth: 1 + CMP0075: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. </policy/CMP0075> CMP0074: find_package uses PackageName_ROOT variables. </policy/CMP0074> CMP0073: Do not produce legacy _LIB_DEPENDS cache entries. </policy/CMP0073> diff --git a/Help/policy/CMP0075.rst b/Help/policy/CMP0075.rst new file mode 100644 index 0000000..aa5c3f7 --- /dev/null +++ b/Help/policy/CMP0075.rst @@ -0,0 +1,26 @@ +CMP0075 +------- + +Include file check macros honor ``CMAKE_REQUIRED_LIBRARIES``. + +In CMake 3.12 and above, the + +* ``check_include_file`` macro in the :module:`CheckIncludeFile` module, the +* ``check_include_file_cxx`` macro in the + :module:`CheckIncludeFileCXX` module, and the +* ``check_include_files`` macro in the :module:`CheckIncludeFiles` module + +now prefer to link the check executable to the libraries listed in the +``CMAKE_REQUIRED_LIBRARIES`` variable. This policy provides compatibility +with projects that have not been updated to expect this behavior. + +The ``OLD`` behavior for this policy is to ignore ``CMAKE_REQUIRED_LIBRARIES`` +in the include file check macros. The ``NEW`` behavior of this policy is to +honor ``CMAKE_REQUIRED_LIBRARIES`` in the include file check macros. + +This policy was introduced in CMake version 3.12. CMake version +|release| warns when the policy is not set and uses ``OLD`` behavior. +Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` +explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/CheckIncludeFile-required-libs.rst b/Help/release/dev/CheckIncludeFile-required-libs.rst new file mode 100644 index 0000000..6fb5c40 --- /dev/null +++ b/Help/release/dev/CheckIncludeFile-required-libs.rst @@ -0,0 +1,14 @@ +CheckIncludeFile-required-libs +------------------------------ + +* The :module:`CheckIncludeFile` module ``check_include_file`` macro + learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable. + See policy :policy:`CMP0075`. + +* The :module:`CheckIncludeFileCXX` module ``check_include_file_cxx`` macro + learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable. + See policy :policy:`CMP0075`. + +* The :module:`CheckIncludeFiles` module ``check_include_files`` macro + learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable. + See policy :policy:`CMP0075`. diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index e5554c4..24bc349 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -27,6 +27,8 @@ # list of macros to define (-DFOO=bar) # ``CMAKE_REQUIRED_INCLUDES`` # list of include directories +# ``CMAKE_REQUIRED_LIBRARIES`` +# A list of libraries to link. See policy :policy:`CMP0075`. # ``CMAKE_REQUIRED_QUIET`` # execute quietly without messages # @@ -55,14 +57,39 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) string(APPEND CMAKE_C_FLAGS " ${ARGV2}") endif() + set(_CIF_LINK_LIBRARIES "") + if(CMAKE_REQUIRED_LIBRARIES) + cmake_policy(GET CMP0075 _CIF_CMP0075 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) + if("x${_CIF_CMP0075}x" STREQUAL "xNEWx") + set(_CIF_LINK_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + elseif("x${_CIF_CMP0075}x" STREQUAL "xOLDx") + elseif(NOT _CIF_CMP0075_WARNED) + set(_CIF_CMP0075_WARNED 1) + message(AUTHOR_WARNING + "Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. " + "Run \"cmake --help-policy CMP0075\" for policy details. " + "Use the cmake_policy command to set the policy and suppress this warning." + "\n" + "CMAKE_REQUIRED_LIBRARIES is set to:\n" + " ${CMAKE_REQUIRED_LIBRARIES}\n" + "For compatibility with CMake 3.11 and below this check is ignoring it." + ) + endif() + unset(_CIF_CMP0075) + endif() + try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${_CIF_LINK_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) + unset(_CIF_LINK_LIBRARIES) if(${ARGC} EQUAL 3) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_SAVE}) diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index 7948bab..f13d983 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -27,6 +27,8 @@ # list of macros to define (-DFOO=bar) # ``CMAKE_REQUIRED_INCLUDES`` # list of include directories +# ``CMAKE_REQUIRED_LIBRARIES`` +# A list of libraries to link. See policy :policy:`CMP0075`. # ``CMAKE_REQUIRED_QUIET`` # execute quietly without messages # @@ -54,14 +56,39 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) string(APPEND CMAKE_CXX_FLAGS " ${ARGV2}") endif() + set(_CIF_LINK_LIBRARIES "") + if(CMAKE_REQUIRED_LIBRARIES) + cmake_policy(GET CMP0075 _CIF_CMP0075 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) + if("x${_CIF_CMP0075}x" STREQUAL "xNEWx") + set(_CIF_LINK_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + elseif("x${_CIF_CMP0075}x" STREQUAL "xOLDx") + elseif(NOT _CIF_CMP0075_WARNED) + set(_CIF_CMP0075_WARNED 1) + message(AUTHOR_WARNING + "Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. " + "Run \"cmake --help-policy CMP0075\" for policy details. " + "Use the cmake_policy command to set the policy and suppress this warning." + "\n" + "CMAKE_REQUIRED_LIBRARIES is set to:\n" + " ${CMAKE_REQUIRED_LIBRARIES}\n" + "For compatibility with CMake 3.11 and below this check is ignoring it." + ) + endif() + unset(_CIF_CMP0075) + endif() + try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${_CIF_LINK_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} "${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) + unset(_CIF_LINK_LIBRARIES) if(${ARGC} EQUAL 3) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE}) diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 59afdab..c689f05 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -33,6 +33,8 @@ # list of macros to define (-DFOO=bar) # ``CMAKE_REQUIRED_INCLUDES`` # list of include directories +# ``CMAKE_REQUIRED_LIBRARIES`` +# A list of libraries to link. See policy :policy:`CMP0075`. # ``CMAKE_REQUIRED_QUIET`` # execute quietly without messages # @@ -95,6 +97,29 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(_description "include file ${_INCLUDE}") endif() + set(_CIF_LINK_LIBRARIES "") + if(CMAKE_REQUIRED_LIBRARIES) + cmake_policy(GET CMP0075 _CIF_CMP0075 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) + if("x${_CIF_CMP0075}x" STREQUAL "xNEWx") + set(_CIF_LINK_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + elseif("x${_CIF_CMP0075}x" STREQUAL "xOLDx") + elseif(NOT _CIF_CMP0075_WARNED) + set(_CIF_CMP0075_WARNED 1) + message(AUTHOR_WARNING + "Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. " + "Run \"cmake --help-policy CMP0075\" for policy details. " + "Use the cmake_policy command to set the policy and suppress this warning." + "\n" + "CMAKE_REQUIRED_LIBRARIES is set to:\n" + " ${CMAKE_REQUIRED_LIBRARIES}\n" + "For compatibility with CMake 3.11 and below this check is ignoring it." + ) + endif() + unset(_CIF_CMP0075) + endif() + if(NOT CMAKE_REQUIRED_QUIET) message(STATUS "Looking for ${_description}") endif() @@ -102,10 +127,12 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) ${CMAKE_BINARY_DIR} ${src} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${_CIF_LINK_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILES_FLAGS} "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) + unset(_CIF_LINK_LIBRARIES) if(${VARIABLE}) if(NOT CMAKE_REQUIRED_QUIET) message(STATUS "Looking for ${_description} - found") diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index 7ca1cbc..adf9ef8 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -95,7 +95,11 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args) bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args) { - if (args.size() != 3) { + bool parent_scope = false; + if (args.size() == 4 && args[3] == "PARENT_SCOPE") { + // Undocumented PARENT_SCOPE option for use within CMake. + parent_scope = true; + } else if (args.size() != 3) { this->SetError("GET must be given exactly 2 additional arguments."); return false; } @@ -115,7 +119,8 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args) } // Lookup the policy setting. - cmPolicies::PolicyStatus status = this->Makefile->GetPolicyStatus(pid); + cmPolicies::PolicyStatus status = + this->Makefile->GetPolicyStatus(pid, parent_scope); switch (status) { case cmPolicies::OLD: // Report that the policy is set to OLD. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f9eb90f..cf277d5 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1893,6 +1893,13 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/, retVal = 1; } + // The OpenWatcom tools do not return an error code when a link + // library is not found! + if (this->CMakeInstance->GetState()->UseWatcomWMake() && retVal == 0 && + output.find("W1008: cannot open") != std::string::npos) { + retVal = 1; + } + return retVal; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9aeeb5c..490d516 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4089,10 +4089,10 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const return this->DefineFlagsOrig.c_str(); } -cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus( - cmPolicies::PolicyID id) const +cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id, + bool parent_scope) const { - return this->StateSnapshot.GetPolicy(id); + return this->StateSnapshot.GetPolicy(id, parent_scope); } bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index d2626cd..8589deb 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -284,7 +284,8 @@ public: */ bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); bool SetPolicy(const char* id, cmPolicies::PolicyStatus status); - cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const; + cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id, + bool parent_scope = false) const; bool SetPolicyVersion(std::string const& version_min, std::string const& version_max); void RecordPolicies(cmPolicies::PolicyMap& pm); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a21c778..9b9ef60 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -219,7 +219,10 @@ class cmMakefile; "Do not produce legacy _LIB_DEPENDS cache entries.", 3, 12, 0, \ cmPolicies::WARN) \ SELECT(POLICY, CMP0074, "find_package uses PackageName_ROOT variables.", 3, \ - 12, 0, cmPolicies::WARN) + 12, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0075, \ + "Include file check macros honor CMAKE_REQUIRED_LIBRARIES.", 3, 12, \ + 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 0d97c33..0229a77 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -160,8 +160,8 @@ void cmStateSnapshot::SetPolicy(cmPolicies::PolicyID id, } } -cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy( - cmPolicies::PolicyID id) const +cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(cmPolicies::PolicyID id, + bool parent_scope) const { cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); @@ -180,6 +180,10 @@ cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy( cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator root = dir->DirectoryEnd->PolicyRoot; for (; leaf != root; ++leaf) { + if (parent_scope) { + parent_scope = false; + continue; + } if (leaf->IsDefined(id)) { status = leaf->Get(id); return status; diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index 94d6274..af5653b 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -43,7 +43,8 @@ public: cmStateEnums::SnapshotType GetType() const; void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); - cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id, + bool parent_scope = false) const; bool HasDefinedPolicyCMP0011(); void PushPolicy(cmPolicies::PolicyMap const& entry, bool weak); bool PopPolicy(); diff --git a/Tests/PolicyScope/CMakeLists.txt b/Tests/PolicyScope/CMakeLists.txt index 413195a..353842b 100644 --- a/Tests/PolicyScope/CMakeLists.txt +++ b/Tests/PolicyScope/CMakeLists.txt @@ -52,6 +52,10 @@ if(1) # CMP0002 should be changed when this function is invoked cmake_policy(GET CMP0002 cmp) check(CMP0002 "OLD" "${cmp}") + + # The undocumented PARENT_SCOPE option sees the caller's setting. + cmake_policy(GET CMP0002 cmp PARENT_SCOPE) + check(CMP0002 "NEW" "${cmp}") endfunction() # Unset CMP0002 @@ -61,6 +65,10 @@ if(1) cmake_policy(GET CMP0002 cmp) check(CMP0002 "" "${cmp}") + # The undocumented PARENT_SCOPE option sees the caller's setting. + cmake_policy(GET CMP0002 cmp PARENT_SCOPE) + check(CMP0002 "NEW" "${cmp}") + # Setting the policy should work here and also in the caller. cmake_policy(SET CMP0002 OLD) cmake_policy(GET CMP0002 cmp) diff --git a/Tests/RunCMake/CheckModules/CMP0075-stderr.txt b/Tests/RunCMake/CheckModules/CMP0075-stderr.txt new file mode 100644 index 0000000..960fe94 --- /dev/null +++ b/Tests/RunCMake/CheckModules/CMP0075-stderr.txt @@ -0,0 +1,50 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/CheckIncludeFile.cmake:[0-9]+ \(message\): + Policy CMP0075 is not set: Include file check macros honor + CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + CMAKE_REQUIRED_LIBRARIES is set to: + + does_not_exist + + For compatibility with CMake 3.11 and below this check is ignoring it. +Call Stack \(most recent call first\): + CMP0075.cmake:11 \(check_include_file\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/CheckIncludeFileCXX.cmake:[0-9]+ \(message\): + Policy CMP0075 is not set: Include file check macros honor + CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + CMAKE_REQUIRED_LIBRARIES is set to: + + does_not_exist + + For compatibility with CMake 3.11 and below this check is ignoring it. +Call Stack \(most recent call first\): + CMP0075.cmake:26 \(check_include_file_cxx\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at [^ +]*/Modules/CheckIncludeFiles.cmake:[0-9]+ \(message\): + Policy CMP0075 is not set: Include file check macros honor + CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + CMAKE_REQUIRED_LIBRARIES is set to: + + does_not_exist + + For compatibility with CMake 3.11 and below this check is ignoring it. +Call Stack \(most recent call first\): + CMP0075.cmake:41 \(check_include_files\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CheckModules/CMP0075.cmake b/Tests/RunCMake/CheckModules/CMP0075.cmake new file mode 100644 index 0000000..4a3b720 --- /dev/null +++ b/Tests/RunCMake/CheckModules/CMP0075.cmake @@ -0,0 +1,124 @@ +enable_language(C) +enable_language(CXX) +include(CheckIncludeFile) +include(CheckIncludeFileCXX) +include(CheckIncludeFiles) + +set(CMAKE_REQUIRED_LIBRARIES does_not_exist) + +#============================================================================ + +check_include_file("stddef.h" HAVE_STDDEF_H_1) +if(NOT HAVE_STDDEF_H_1) + message(SEND_ERROR "HAVE_STDDEF_H_1 failed but should have passed.") +endif() +if(NOT _CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDDEF_H_1 did not warn but should have") +endif() +check_include_file("stddef.h" HAVE_STDDEF_H_2) # second does not warn +if(NOT HAVE_STDDEF_H_2) + message(SEND_ERROR "HAVE_STDDEF_H_2 failed but should have passed.") +endif() +unset(_CIF_CMP0075_WARNED) + +#---------------------------------------------------------------------------- + +check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_1) +if(NOT HAVE_STDDEF_H_CXX_1) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_1 failed but should have passed.") +endif() +if(NOT _CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_1 did not warn but should have") +endif() +check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_2) # second does not warn +if(NOT HAVE_STDDEF_H_CXX_2) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_2 failed but should have passed.") +endif() +unset(_CIF_CMP0075_WARNED) + +#---------------------------------------------------------------------------- + +check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_1) +if(NOT HAVE_STDLIB_H_1) + message(SEND_ERROR "HAVE_STDLIB_H_1 failed but should have passed.") +endif() +if(NOT _CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDLIB_H_1 did not warn but should have") +endif() +check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_2) # second does not warn +if(NOT HAVE_STDLIB_H_2) + message(SEND_ERROR "HAVE_STDLIB_H_2 failed but should have passed.") +endif() +unset(_CIF_CMP0075_WARNED) + +#============================================================================ +cmake_policy(SET CMP0075 OLD) +# These should not warn. +# These should pass the checks due to ignoring 'does_not_exist'. + +check_include_file("stddef.h" HAVE_STDDEF_H_3) +if(NOT HAVE_STDDEF_H_3) + message(SEND_ERROR "HAVE_STDDEF_H_3 failed but should have passed.") +endif() +if(_CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDDEF_H_3 warned but should not have") +endif() +unset(_CIF_CMP0075_WARNED) + +#---------------------------------------------------------------------------- + +check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_3) +if(NOT HAVE_STDDEF_H_CXX_3) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_3 failed but should have passed.") +endif() +if(_CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_3 warned but should not have") +endif() +unset(_CIF_CMP0075_WARNED) + +#---------------------------------------------------------------------------- + +check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_3) +if(NOT HAVE_STDLIB_H_3) + message(SEND_ERROR "HAVE_STDLIB_H_3 failed but should have passed.") +endif() +if(_CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDLIB_H_3 warned but should not have") +endif() +unset(_CIF_CMP0075_WARNED) + +#============================================================================ +cmake_policy(SET CMP0075 NEW) +# These should not warn. +# These should fail the checks due to requiring 'does_not_exist'. + +check_include_file("stddef.h" HAVE_STDDEF_H_4) +if(HAVE_STDDEF_H_4) + message(SEND_ERROR "HAVE_STDDEF_H_4 passed but should have failed.") +endif() +if(_CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDDEF_H_4 warned but should not have") +endif() +unset(_CIF_CMP0075_WARNED) + +#---------------------------------------------------------------------------- + +check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_4) +if(HAVE_STDDEF_H_CXX_4) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_4 passed but should have failed.") +endif() +if(_CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDDEF_H_CXX_4 warned but should not have") +endif() +unset(_CIF_CMP0075_WARNED) + +#---------------------------------------------------------------------------- + +check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_4) +if(HAVE_STDLIB_H_4) + message(SEND_ERROR "HAVE_STDLIB_H_4 passed but should have failed.") +endif() +if(_CIF_CMP0075_WARNED) + message(SEND_ERROR "HAVE_STDLIB_H_4 warned but should not have") +endif() +unset(_CIF_CMP0075_WARNED) diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake index c5aaa64..8a046e1 100644 --- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(CMP0075) + run_cmake(CheckStructHasMemberOk) run_cmake(CheckStructHasMemberUnknownLanguage) run_cmake(CheckStructHasMemberMissingLanguage) |