CMP0017: Fix check when including from CMake source tree

When running CMake from the build tree the CMAKE_ROOT is the
entire source tree.  Fix the CMP0017 check to be specific to
the Modules/ directory under CMAKE_ROOT so that Tests/ does
not count.  Fix the FindPackageTest modules to include FPHSA
by full path from CMAKE_ROOT so that they do not include the
local FPHSA which reports an error meant to test that CMP0017
works.
This commit is contained in:
Brad King 2014-03-04 09:28:48 -05:00
parent 8982a4b301
commit 7e187eeacd
4 changed files with 5 additions and 4 deletions

View File

@ -3337,7 +3337,8 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0)) if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0))
{ {
const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile)) std::string mods = cmakeRoot + std::string("/Modules/");
if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0)
{ {
switch (this->GetPolicyStatus(cmPolicies::CMP0017)) switch (this->GetPolicyStatus(cmPolicies::CMP0017))
{ {

View File

@ -4,7 +4,7 @@ set(LotsOfComponents_AComp_FOUND TRUE)
set(LotsOfComponents_BComp_FOUND FALSE) set(LotsOfComponents_BComp_FOUND FALSE)
set(LotsOfComponents_CComp_FOUND TRUE) set(LotsOfComponents_CComp_FOUND TRUE)
include(FindPackageHandleStandardArgs) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO
HANDLE_COMPONENTS) HANDLE_COMPONENTS)

View File

@ -1,6 +1,6 @@
set(SOP_FOO TRUE) set(SOP_FOO TRUE)
include(FindPackageHandleStandardArgs) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(SomePackage REQUIRED_VARS SOP_FOO find_package_handle_standard_args(SomePackage REQUIRED_VARS SOP_FOO
FOUND_VAR SomePackage_FOUND ) FOUND_VAR SomePackage_FOUND )

View File

@ -1,6 +1,6 @@
set(UCP_FOO TRUE) set(UCP_FOO TRUE)
include(FindPackageHandleStandardArgs) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(UpperCasePackage REQUIRED_VARS UCP_FOO find_package_handle_standard_args(UpperCasePackage REQUIRED_VARS UCP_FOO
FOUND_VAR UPPERCASEPACKAGE_FOUND ) FOUND_VAR UPPERCASEPACKAGE_FOUND )