summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/policy/CMP0126.rst3
-rw-r--r--Modules/FindGLUT.cmake2
-rw-r--r--Modules/FindGSL.cmake2
-rw-r--r--Modules/GoogleTestAddTests.cmake7
-rw-r--r--Source/cmGeneratorTarget.cxx111
-rw-r--r--Source/cmGeneratorTarget.h11
-rw-r--r--Source/cmGlobalGenerator.cxx15
-rw-r--r--Source/cmGlobalGenerator.h1
-rw-r--r--Source/cmLocalGenerator.h5
-rw-r--r--Tests/FindGLUT/Test/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt16
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt16
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt16
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt16
-rw-r--r--Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt14
-rw-r--r--Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt32
17 files changed, 201 insertions, 70 deletions
diff --git a/Help/policy/CMP0126.rst b/Help/policy/CMP0126.rst
index 1b69957..a389512 100644
--- a/Help/policy/CMP0126.rst
+++ b/Help/policy/CMP0126.rst
@@ -14,6 +14,9 @@ current scope in the following situations:
This can occur when the variable was set on the command line using a form
like ``cmake -DMYVAR=blah`` instead of ``cmake -DMYVAR:STRING=blah``.
+* The ``FORCE`` or ``INTERNAL`` keywords were used when setting the cache
+ variable.
+
Note that the ``NEW`` behavior has an important difference to the similar
``NEW`` behavior of policy :policy:`CMP0077`. The :command:`set(CACHE)`
command always sets the cache variable if it did not exist previously,
diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake
index dd0975d..636f1ea 100644
--- a/Modules/FindGLUT.cmake
+++ b/Modules/FindGLUT.cmake
@@ -71,6 +71,8 @@ find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(GLUT glut)
if(GLUT_FOUND)
+ # In the non-pkg-config code path we only provide GLUT_INCLUDE_DIR.
+ set(GLUT_INCLUDE_DIR "${GLUT_INCLUDE_DIRS}")
_add_glut_target_simple()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_FOUND)
return()
diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake
index 3d4e7f9..485735a 100644
--- a/Modules/FindGSL.cmake
+++ b/Modules/FindGSL.cmake
@@ -139,7 +139,7 @@ if( NOT GSL_VERSION )
# 2. If gsl-config is not available, try looking in gsl/gsl_version.h
if( NOT GSL_VERSION AND EXISTS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" )
file( STRINGS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" gsl_version_h_contents REGEX "define GSL_VERSION" )
- string( REGEX REPLACE ".*([0-9]\\.[0-9][0-9]?).*" "\\1" GSL_VERSION ${gsl_version_h_contents} )
+ string( REGEX REPLACE ".*define[ ]+GSL_VERSION[ ]+\"([^\"]*)\".*" "\\1" GSL_VERSION ${gsl_version_h_contents} )
endif()
# might also try scraping the directory name for a regex match "gsl-X.X"
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index 6b3bf34..dffbc46 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -80,9 +80,14 @@ function(gtest_discover_tests_impl)
)
if(NOT ${result} EQUAL 0)
string(REPLACE "\n" "\n " output "${output}")
+ if(_TEST_EXECUTOR)
+ set(path "${_TEST_EXECUTOR} ${_TEST_EXECUTABLE}")
+ else()
+ set(path "${_TEST_EXECUTABLE}")
+ endif()
message(FATAL_ERROR
"Error running test executable.\n"
- " Path: '${_TEST_EXECUTABLE}'\n"
+ " Path: '${path}'\n"
" Result: ${result}\n"
" Output:\n"
" ${output}\n"
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 1493f24..e370472 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2687,7 +2687,6 @@ public:
: Config(std::move(config))
, Languages(languages)
, HeadTarget(head)
- , Target(target)
, SecondPass(secondPass)
{
this->Visited.insert(target);
@@ -2696,36 +2695,6 @@ public:
void Visit(cmLinkItem const& item)
{
if (!item.Target) {
- if (item.AsStr().find("::") != std::string::npos) {
- bool noMessage = false;
- MessageType messageType = MessageType::FATAL_ERROR;
- std::ostringstream e;
- switch (this->Target->GetLocalGenerator()->GetPolicyStatus(
- cmPolicies::CMP0028)) {
- case cmPolicies::WARN: {
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n";
- messageType = MessageType::AUTHOR_WARNING;
- } break;
- case cmPolicies::OLD:
- noMessage = true;
- break;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- // Issue the fatal message.
- break;
- }
-
- if (!noMessage) {
- e << "Target \"" << this->Target->GetName()
- << "\" links to target \"" << item.AsStr()
- << "\" but the target was not found. Perhaps a find_package() "
- "call is missing for an IMPORTED target, or an ALIAS target is "
- "missing?";
- this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
- messageType, e.str(), this->Target->GetBacktrace());
- }
- }
return;
}
if (!this->Visited.insert(item.Target).second) {
@@ -2758,7 +2727,6 @@ private:
std::string Config;
std::unordered_set<std::string>& Languages;
cmGeneratorTarget const* HeadTarget;
- const cmGeneratorTarget* Target;
std::set<cmGeneratorTarget const*> Visited;
bool SecondPass;
bool HadLinkLanguageSensitiveCondition = false;
@@ -6277,6 +6245,84 @@ cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(
return i->second.get();
}
+void cmGeneratorTarget::CheckLinkLibraries() const
+{
+ // Check link the implementation for each generated configuration.
+ for (auto const& hmp : this->LinkImplMap) {
+ HeadToLinkImplementationMap const& hm = hmp.second;
+ // There could be several entries used when computing the pre-CMP0022
+ // default link interface. Check only the entry for our own link impl.
+ auto const hmi = hm.find(this);
+ if (hmi == hm.end() || !hmi->second.LibrariesDone) {
+ continue;
+ }
+ for (cmLinkImplItem const& item : hmi->second.Libraries) {
+ if (!this->VerifyLinkItemColons(LinkItemRole::Implementation, item)) {
+ return;
+ }
+ }
+ }
+
+ // Check link the interface for each generated combination of
+ // configuration and consuming head target. We should not need to
+ // consider LinkInterfaceUsageRequirementsOnlyMap because its entries
+ // should be a subset of LinkInterfaceMap (with LINK_ONLY left out).
+ for (auto const& hmp : this->LinkInterfaceMap) {
+ for (auto const& hmi : hmp.second) {
+ if (!hmi.second.LibrariesDone) {
+ continue;
+ }
+ for (cmLinkItem const& item : hmi.second.Libraries) {
+ if (!this->VerifyLinkItemColons(LinkItemRole::Interface, item)) {
+ return;
+ }
+ }
+ }
+ }
+}
+
+bool cmGeneratorTarget::VerifyLinkItemColons(LinkItemRole role,
+ cmLinkItem const& item) const
+{
+ if (item.Target || item.AsStr().find("::") == std::string::npos) {
+ return true;
+ }
+ MessageType messageType = MessageType::FATAL_ERROR;
+ std::string e;
+ switch (this->GetLocalGenerator()->GetPolicyStatus(cmPolicies::CMP0028)) {
+ case cmPolicies::WARN: {
+ e = cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0028), "\n");
+ messageType = MessageType::AUTHOR_WARNING;
+ } break;
+ case cmPolicies::OLD:
+ return true;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Issue the fatal message.
+ break;
+ }
+
+ if (role == LinkItemRole::Implementation) {
+ e = cmStrCat(e, "Target \"", this->GetName(), "\" links to");
+ } else {
+ e = cmStrCat(e, "The link interface of target \"", this->GetName(),
+ "\" contains");
+ }
+ e = cmStrCat(e, ":\n ", item.AsStr(), "\n",
+ "but the target was not found. Possible reasons include:\n"
+ " * There is a typo in the target name.\n"
+ " * A find_package call is missing for an IMPORTED target.\n"
+ " * An ALIAS target is missing.\n");
+ cmListFileBacktrace backtrace = item.Backtrace;
+ if (backtrace.Empty()) {
+ backtrace = this->GetBacktrace();
+ }
+ this->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(messageType, e,
+ backtrace);
+ return false;
+}
+
void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const
{
int patch;
@@ -7284,6 +7330,7 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
cmOptionalLinkInterface& iface = hm[headTarget];
if (!iface.AllDone) {
iface.AllDone = true;
+ iface.LibrariesDone = true;
iface.Multiplicity = info->Multiplicity;
cmExpandList(info->Languages, iface.Languages);
this->ExpandLinkItems(info->LibrariesProp, cmMakeRange(info->Libraries),
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 110af43..096e2ea 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -84,6 +84,10 @@ public:
cmComputeLinkInformation* GetLinkInformation(
const std::string& config) const;
+ // Perform validation checks on memoized link structures.
+ // Call this after generation is complete.
+ void CheckLinkLibraries() const;
+
cmStateEnums::TargetType GetType() const;
const std::string& GetName() const;
std::string GetExportName() const;
@@ -973,6 +977,13 @@ private:
cmLinkImplementation const* GetLinkImplementation(const std::string& config,
bool secondPass) const;
+ enum class LinkItemRole
+ {
+ Implementation,
+ Interface,
+ };
+ bool VerifyLinkItemColons(LinkItemRole role, cmLinkItem const& item) const;
+
// Cache import information from properties for each configuration.
struct ImportInfo
{
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 0a2e7b5..6433681 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -328,6 +328,18 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
return failed;
}
+void cmGlobalGenerator::CheckTargetLinkLibraries() const
+{
+ for (const auto& generator : this->LocalGenerators) {
+ for (const auto& gt : generator->GetGeneratorTargets()) {
+ gt->CheckLinkLibraries();
+ }
+ for (const auto& gt : generator->GetOwnedImportedGeneratorTargets()) {
+ gt->CheckLinkLibraries();
+ }
+ }
+}
+
bool cmGlobalGenerator::CheckTargetsForType() const
{
if (!this->GetLanguageEnabled("Swift")) {
@@ -1606,6 +1618,9 @@ void cmGlobalGenerator::Generate()
this->ExtraGenerator->Generate();
}
+ // Perform validation checks on memoized link structures.
+ this->CheckTargetLinkLibraries();
+
if (!this->CMP0042WarnTargets.empty()) {
std::ostringstream w;
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 96696aa..2406798 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -684,6 +684,7 @@ private:
virtual void ForceLinkerLanguages();
+ void CheckTargetLinkLibraries() const;
bool CheckTargetsForMissingSources() const;
bool CheckTargetsForType() const;
bool CheckTargetsForPchCompilePdb() const;
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index c73cd62..115a54a 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -193,6 +193,11 @@ public:
return this->GeneratorTargets;
}
+ const GeneratorTargetVector& GetOwnedImportedGeneratorTargets() const
+ {
+ return this->OwnedImportedGeneratorTargets;
+ }
+
void AddGeneratorTarget(std::unique_ptr<cmGeneratorTarget> gt);
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
void AddOwnedImportedGeneratorTarget(std::unique_ptr<cmGeneratorTarget> gt);
diff --git a/Tests/FindGLUT/Test/CMakeLists.txt b/Tests/FindGLUT/Test/CMakeLists.txt
index 0f4e536..f6440b2 100644
--- a/Tests/FindGLUT/Test/CMakeLists.txt
+++ b/Tests/FindGLUT/Test/CMakeLists.txt
@@ -9,7 +9,7 @@ target_link_libraries(testglut_tgt GLUT::GLUT)
add_test(NAME testglut_tgt COMMAND testglut_tgt)
add_executable(testglut_var main.c)
-target_include_directories(testglut_var PRIVATE ${GLUT_INCLUDE_DIRS})
+target_include_directories(testglut_var PRIVATE ${GLUT_INCLUDE_DIR})
target_link_libraries(testglut_var PRIVATE ${GLUT_LIBRARIES})
add_test(NAME testglut_var COMMAND testglut_var)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt
index e2108f4..111d1f0 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt
+++ b/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt
@@ -1,6 +1,12 @@
-CMake Error at CMP0028-NEW-iface.cmake:6 \(add_library\):
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+CMake Error at CMP0028-NEW-iface\.cmake:5 \(target_link_libraries\):
+ The link interface of target "iface" contains:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
index 711ad0e..17b25de 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
+++ b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
@@ -1,6 +1,12 @@
-CMake Error at CMP0028-NEW.cmake:4 \(add_library\):
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+CMake Error at CMP0028-NEW\.cmake:5 \(target_link_libraries\):
+ Target "foo" links to:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt
index 0c5c653..bb6a16e 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt
+++ b/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt
@@ -1,11 +1,17 @@
-CMake Warning \(dev\) at CMP0028-WARN-iface.cmake:4 \(add_library\):
+CMake Warning \(dev\) at CMP0028-WARN-iface\.cmake:3 \(target_link_libraries\):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake --help-policy CMP0028" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+ The link interface of target "iface" contains:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
index 41d7560..c0cb5b0 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
@@ -1,11 +1,17 @@
-CMake Warning \(dev\) at CMP0028-WARN.cmake:2 \(add_library\):
+CMake Warning \(dev\) at CMP0028-WARN\.cmake:3 \(target_link_libraries\):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake --help-policy CMP0028" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+ Target "foo" links to:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt b/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt
index 25fa3bf..cfcb448 100644
--- a/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt
+++ b/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt
@@ -1,2 +1,2 @@
-- CMAKE_VS_PLATFORM_NAME='[^']+'
--- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+'
+-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+|Intel[^']+C\+\+ Compiler[^']*'
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
index 9e38bec..488ae8d 100644
--- a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
@@ -1,6 +1,12 @@
-^CMake Error at CMP0079-link-NEW-bogus.cmake:[0-9]+ \(add_executable\):
- Target "top" links to target "::@\(0xdeadbeef\)" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+^CMake Error at CMP0079-link-NEW-bogus\.cmake:6 \(set_property\):
+ Target "top" links to:
+
+ ::@\(0xdeadbeef\)
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt b/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt
index 953c972..ad48fd0 100644
--- a/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt
@@ -1,13 +1,25 @@
-^CMake Error at ConfigCase.cmake:[0-9]+ \(add_library\):
- Target "impl" links to target "config::impl-Debug" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+^CMake Error at ConfigCase\.cmake:4 \(target_link_libraries\):
+ The link interface of target "iface" contains:
+
+ config::iface-Debug
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
-CMake Error at ConfigCase.cmake:[0-9]+ \(add_library\):
- Target "impl" links to target "config::iface-Debug" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+CMake Error at ConfigCase\.cmake:6 \(target_link_libraries\):
+ Target "impl" links to:
+
+ config::impl-Debug
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)