summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-05-28 12:52:57 (GMT)
committerBrad King <brad.king@kitware.com>2020-05-28 16:56:59 (GMT)
commit1eca5993e21eeefa8a0c8d4e41b559c1d32c495a (patch)
tree224acb0649ebc5e8198b311950f7f30da4c606f0 /Tests/RunCMake
parent04b9b2b5f363d792719238046a18aac867be3254 (diff)
downloadCMake-1eca5993e21eeefa8a0c8d4e41b559c1d32c495a.zip
CMake-1eca5993e21eeefa8a0c8d4e41b559c1d32c495a.tar.gz
CMake-1eca5993e21eeefa8a0c8d4e41b559c1d32c495a.tar.bz2
ALIAS target: cannot overwrite an existing target
Fixes: #19616
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/alias_targets/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-result.txt1
-rw-r--r--Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-stderr.txt30
-rw-r--r--Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW.cmake4
-rw-r--r--Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD.cmake4
-rw-r--r--Tests/RunCMake/alias_targets/duplicate-target.cmake20
6 files changed, 61 insertions, 0 deletions
diff --git a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
index dded248..676de08 100644
--- a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
@@ -2,6 +2,8 @@ include(RunCMake)
run_cmake(no-targets)
run_cmake(multiple-targets)
+run_cmake(duplicate-target-CMP0107-OLD)
+run_cmake(duplicate-target-CMP0107-NEW)
run_cmake(exclude-from-all)
run_cmake(imported)
run_cmake(invalid-name)
diff --git a/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-result.txt b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-stderr.txt b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-stderr.txt
new file mode 100644
index 0000000..03ba5a6
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW-stderr.txt
@@ -0,0 +1,30 @@
+CMake Error at duplicate-target.cmake:[0-9]+ \(add_library\):
+ add_library cannot create ALIAS target "alias1" because another target with
+ the same name already exists.
+Call Stack \(most recent call first\):
+ duplicate-target-CMP0107-NEW.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at duplicate-target.cmake:[0-9]+ \(add_library\):
+ add_library cannot create ALIAS target "alias1" because another target with
+ the same name already exists.
+Call Stack \(most recent call first\):
+ duplicate-target-CMP0107-NEW.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at duplicate-target.cmake:[0-9]+ \(add_library\):
+ add_library cannot create ALIAS target "alias2" because another target with
+ the same name already exists.
+Call Stack \(most recent call first\):
+ duplicate-target-CMP0107-NEW.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at duplicate-target.cmake:[0-9]+ \(add_library\):
+ add_library cannot create ALIAS target "alias2" because another target with
+ the same name already exists.
+Call Stack \(most recent call first\):
+ duplicate-target-CMP0107-NEW.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW.cmake b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW.cmake
new file mode 100644
index 0000000..609857f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-NEW.cmake
@@ -0,0 +1,4 @@
+
+cmake_policy (SET CMP0107 NEW)
+
+include (duplicate-target.cmake)
diff --git a/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD.cmake b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD.cmake
new file mode 100644
index 0000000..d5bc998
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD.cmake
@@ -0,0 +1,4 @@
+
+cmake_policy (SET CMP0107 OLD)
+
+include (duplicate-target.cmake)
diff --git a/Tests/RunCMake/alias_targets/duplicate-target.cmake b/Tests/RunCMake/alias_targets/duplicate-target.cmake
new file mode 100644
index 0000000..f81921b
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/duplicate-target.cmake
@@ -0,0 +1,20 @@
+
+add_library (foo1 INTERFACE)
+add_library (foo2 INTERFACE)
+
+add_library (imp1 SHARED IMPORTED GLOBAL)
+add_library (imp2 SHARED IMPORTED GLOBAL)
+
+
+add_library (alias1 ALIAS foo1)
+# same alias to different library
+add_library (alias1 ALIAS foo2)
+# same alias to different imported library
+add_library (alias1 ALIAS imp1)
+
+
+add_library (alias2 ALIAS imp1)
+# same alias to different imported library
+add_library (alias2 ALIAS imp2)
+# same alias to different library
+add_library (alias2 ALIAS foo1)