summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-03-12 16:59:36 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-03-12 17:01:26 (GMT)
commitd83245a34f870c373c6db8de94792608f133be58 (patch)
tree4b02cb53b78e063e7d5823e05510db863ff576e1
parent7534967b65b03be558940e1a112918ee28d38c20 (diff)
downloadCMake-d83245a34f870c373c6db8de94792608f133be58.zip
CMake-d83245a34f870c373c6db8de94792608f133be58.tar.gz
CMake-d83245a34f870c373c6db8de94792608f133be58.tar.bz2
cmTarget: Don't create duplicate backtraces in CMP0046 warning
-rw-r--r--Source/cmTarget.cxx7
-rw-r--r--Tests/RunCMake/CMP0046/CMP0046-Duplicate-result.txt1
-rw-r--r--Tests/RunCMake/CMP0046/CMP0046-Duplicate-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0046/CMP0046-Duplicate.cmake9
-rw-r--r--Tests/RunCMake/CMP0046/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CMP0046/empty.cpp7
6 files changed, 31 insertions, 4 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 84a9a7c..3fb79d8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -403,11 +403,10 @@ void cmTarget::SetMakefile(cmMakefile* mf)
//----------------------------------------------------------------------------
void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
{
- this->Utilities.insert(u);
- if(makefile)
- {
+ if(this->Utilities.insert(u).second && makefile)
+ {
makefile->GetBacktrace(UtilityBacktraces[u]);
- }
+ }
}
//----------------------------------------------------------------------------
diff --git a/Tests/RunCMake/CMP0046/CMP0046-Duplicate-result.txt b/Tests/RunCMake/CMP0046/CMP0046-Duplicate-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0046/CMP0046-Duplicate-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0046/CMP0046-Duplicate-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-Duplicate-stderr.txt
new file mode 100644
index 0000000..fb31d6d
--- /dev/null
+++ b/Tests/RunCMake/CMP0046/CMP0046-Duplicate-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning \(dev\) at CMP0046-Duplicate.cmake:5 \(add_dependencies\):
+ Policy CMP0046 is not set: Error on non-existent dependency in
+ add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ The dependency target "ctgt_no_exist" of target "dummy" does not exist.
+Call Stack \(most recent call first\):
+ CMP0046-Duplicate.cmake:8 \(add_dep\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0046/CMP0046-Duplicate.cmake b/Tests/RunCMake/CMP0046/CMP0046-Duplicate.cmake
new file mode 100644
index 0000000..26e640b
--- /dev/null
+++ b/Tests/RunCMake/CMP0046/CMP0046-Duplicate.cmake
@@ -0,0 +1,9 @@
+
+add_library(dummy empty.cpp)
+
+macro(add_dep)
+ add_dependencies(dummy ctgt_no_exist)
+endmacro()
+
+add_dep()
+add_dep()
diff --git a/Tests/RunCMake/CMP0046/RunCMakeTest.cmake b/Tests/RunCMake/CMP0046/RunCMakeTest.cmake
index 5131e5b..0a39c76 100644
--- a/Tests/RunCMake/CMP0046/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0046/RunCMakeTest.cmake
@@ -6,3 +6,4 @@ run_cmake(CMP0046-WARN-missing-dependency)
run_cmake(CMP0046-OLD-existing-dependency)
run_cmake(CMP0046-NEW-existing-dependency)
+run_cmake(CMP0046-Duplicate)
diff --git a/Tests/RunCMake/CMP0046/empty.cpp b/Tests/RunCMake/CMP0046/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CMP0046/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}