[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3607-gc8fb49e
Stephen Kelly
steveire at gmail.com
Fri Aug 2 06:49:58 EDT 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via c8fb49ea5f1a9653e4e9e2eb5ed7fe23911ca909 (commit)
via 97159e9c5cf9e6cf7292b3cd1cb4a20f44610e3b (commit)
via 9cc97c427ab21c01c76b8e835d051aff06332f0b (commit)
via 9ee4acecfddc0d39c02fd75e69b664f36c509a25 (commit)
via 2f1e13e83ff8a62c4b0c05e5eff61ece65431479 (commit)
via 883288c9e2c19d640e9c845287193315cb7d0d65 (commit)
via 41050e29a0a6a25aa7e47f8acbd5f467acb0b7ba (commit)
via 1436e9e162f2e8fecee861e1aaad8bed9ac64e55 (commit)
via 5f10205ce4dda0a776a39f150c924502c0584772 (commit)
via 1eebeb3e6db64adbc0271efdf83cab494cc28d03 (commit)
via 7197f536c45b2ff1a64ee715225dc98caf92dd57 (commit)
from c74a3c226bc5f59b90729a0172affb78beffd1bd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c8fb49ea5f1a9653e4e9e2eb5ed7fe23911ca909
commit c8fb49ea5f1a9653e4e9e2eb5ed7fe23911ca909
Merge: c74a3c2 97159e9
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 06:49:51 2013 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Aug 2 06:49:51 2013 -0400
Merge topic 'ALIAS-targets' into next
97159e9 Test the behavior of $<TARGET_PROPERTY:Alias,NAME>
9cc97c4 Test that an OBJECT_LIBRARY ALIAS works.
9ee4ace Test that $<TARGET_FILE> works.
2f1e13e Test that add_test works with an ALIAS.
883288c Make sure add_custom_target works with an ALIAS.
41050e2 Test that add_custom_command with an ALIAS works.
1436e9e cmTarget: Add the ALIASED_TARGET target property
5f10205 Document that an ALIAS may not be installed or exported.
1eebeb3 Make sure the add_ commands can only handle appropriate target types.
7197f53 Add the ALIAS_LIBRARY target type.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97159e9c5cf9e6cf7292b3cd1cb4a20f44610e3b
commit 97159e9c5cf9e6cf7292b3cd1cb4a20f44610e3b
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 11:37:26 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:21 2013 +0200
Test the behavior of $<TARGET_PROPERTY:Alias,NAME>
The result is the name of the aliased target.
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index b57cb51..9ee4fc5 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -183,6 +183,7 @@ add_custom_target(check-part3 ALL
-Dtest_imported_minsizerel=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
-Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>>
-Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>>
+ -Dtest_alias_target_name=$<STREQUAL:$<TARGET_PROPERTY:Alias::SomeLib,NAME>,$<TARGET_PROPERTY:empty1,NAME>>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
VERBATIM
diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake
index c157701..5a6a441 100644
--- a/Tests/GeneratorExpression/check-part3.cmake
+++ b/Tests/GeneratorExpression/check-part3.cmake
@@ -23,3 +23,4 @@ endforeach()
check(test_alias_file_exe "1")
check(test_alias_file_lib "1")
+check(test_alias_target_name "1")
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9cc97c427ab21c01c76b8e835d051aff06332f0b
commit 9cc97c427ab21c01c76b8e835d051aff06332f0b
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 11:32:49 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:21 2013 +0200
Test that an OBJECT_LIBRARY ALIAS works.
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index 5a245b1..a5eb0f6 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -6,6 +6,9 @@ add_library(foo SHARED empty.cpp)
add_library(PREFIX::Foo ALIAS foo)
add_library(Another::Alias ALIAS foo)
+add_library(objects OBJECT object.cpp)
+add_library(Alias::Objects ALIAS objects)
+
target_compile_definitions(foo PUBLIC FOO_DEFINE)
add_library(bar SHARED empty.cpp)
@@ -13,7 +16,7 @@ target_compile_definitions(bar PUBLIC BAR_DEFINE)
target_link_libraries(foo LINK_PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:PREFIX::Foo,ALIASED_TARGET>,foo>:bar>)
-add_executable(AliasTarget commandgenerator.cpp)
+add_executable(AliasTarget commandgenerator.cpp $<TARGET_OBJECTS:Alias::Objects>)
add_executable(PREFIX::AliasTarget ALIAS AliasTarget)
add_executable(Generator::Command ALIAS AliasTarget)
diff --git a/Tests/AliasTarget/commandgenerator.cpp b/Tests/AliasTarget/commandgenerator.cpp
index 988db85..23560a4 100644
--- a/Tests/AliasTarget/commandgenerator.cpp
+++ b/Tests/AliasTarget/commandgenerator.cpp
@@ -1,6 +1,8 @@
#include <fstream>
+#include "object.h"
+
int main(int argc, char **argv)
{
std::fstream fout;
@@ -9,5 +11,5 @@ int main(int argc, char **argv)
return 1;
fout << "#define COMMANDOUTPUT_DEFINE\n";
fout.close();
- return 0;
+ return object();
}
diff --git a/Tests/AliasTarget/object.cpp b/Tests/AliasTarget/object.cpp
new file mode 100644
index 0000000..df09c20
--- /dev/null
+++ b/Tests/AliasTarget/object.cpp
@@ -0,0 +1,5 @@
+
+int object(void)
+{
+ return 0;
+}
diff --git a/Tests/AliasTarget/object.h b/Tests/AliasTarget/object.h
new file mode 100644
index 0000000..e935f14
--- /dev/null
+++ b/Tests/AliasTarget/object.h
@@ -0,0 +1,4 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int object(void);
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9ee4acecfddc0d39c02fd75e69b664f36c509a25
commit 9ee4acecfddc0d39c02fd75e69b664f36c509a25
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 11:27:02 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:21 2013 +0200
Test that $<TARGET_FILE> works.
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 7ac6ede..b57cb51 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -163,6 +163,11 @@ add_library(imported4 SHARED IMPORTED)
set_property(TARGET imported4 APPEND PROPERTY
INCLUDE_DIRECTORIES $<TARGET_PROPERTY:imported3,INTERFACE_INCLUDE_DIRECTORIES>)
+add_executable(someexe empty.cpp)
+add_executable(Alias::SomeExe ALIAS someexe)
+
+add_library(Alias::SomeLib ALIAS empty1)
+
add_custom_target(check-part3 ALL
COMMAND ${CMAKE_COMMAND}
-Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1>
@@ -176,6 +181,8 @@ add_custom_target(check-part3 ALL
-Dtest_imported_release=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
-Dtest_imported_relwithdebinfo=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
-Dtest_imported_minsizerel=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES>
+ -Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>>
+ -Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
VERBATIM
diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake
index af290a5..c157701 100644
--- a/Tests/GeneratorExpression/check-part3.cmake
+++ b/Tests/GeneratorExpression/check-part3.cmake
@@ -20,3 +20,6 @@ foreach(c debug release relwithdebinfo minsizerel)
endif()
endif()
endforeach()
+
+check(test_alias_file_exe "1")
+check(test_alias_file_lib "1")
diff --git a/Tests/GeneratorExpression/empty.cpp b/Tests/GeneratorExpression/empty.cpp
index c539901..f8732a4 100644
--- a/Tests/GeneratorExpression/empty.cpp
+++ b/Tests/GeneratorExpression/empty.cpp
@@ -1,2 +1,4 @@
-
-// empty
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int main() { return 0; }
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f1e13e83ff8a62c4b0c05e5eff61ece65431479
commit 2f1e13e83ff8a62c4b0c05e5eff61ece65431479
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 11:16:24 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:20 2013 +0200
Test that add_test works with an ALIAS.
diff --git a/Tests/CTestTestDepends/CMakeLists.txt b/Tests/CTestTestDepends/CMakeLists.txt
index 26367a6..5cd6d66 100644
--- a/Tests/CTestTestDepends/CMakeLists.txt
+++ b/Tests/CTestTestDepends/CMakeLists.txt
@@ -3,7 +3,8 @@ project(CTestTestDepends)
include(CTest)
add_executable (simple simple.cxx)
-add_test (one simple)
+add_executable (TestExe::Simple ALIAS simple)
+add_test (NAME one COMMAND TestExe::Simple)
add_test (two simple)
add_test (three simple)
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=883288c9e2c19d640e9c845287193315cb7d0d65
commit 883288c9e2c19d640e9c845287193315cb7d0d65
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 11:13:20 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:20 2013 +0200
Make sure add_custom_target works with an ALIAS.
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index b1b6aed..5a245b1 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -15,13 +15,20 @@ target_link_libraries(foo LINK_PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:PREFIX::Foo
add_executable(AliasTarget commandgenerator.cpp)
add_executable(PREFIX::AliasTarget ALIAS AliasTarget)
+add_executable(Generator::Command ALIAS AliasTarget)
-add_custom_command(OUTPUT commandoutput.h COMMAND PREFIX::AliasTarget)
+add_custom_command(OUTPUT commandoutput.h COMMAND Generator::Command)
add_library(bat SHARED bat.cpp "${CMAKE_CURRENT_BINARY_DIR}/commandoutput.h")
target_link_libraries(bat PREFIX::Foo)
target_include_directories(bat PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
+add_executable(targetgenerator targetgenerator.cpp)
+add_executable(Generator::Target ALIAS targetgenerator)
+
+add_custom_target(usealias Generator::Target)
+add_dependencies(bat usealias)
+
if (NOT TARGET Another::Alias)
message(SEND_ERROR "Another::Alias is not considered a target.")
endif()
diff --git a/Tests/AliasTarget/bat.cpp b/Tests/AliasTarget/bat.cpp
index 98830ec..a0b647b 100644
--- a/Tests/AliasTarget/bat.cpp
+++ b/Tests/AliasTarget/bat.cpp
@@ -13,6 +13,11 @@
#error Expected COMMANDOUTPUT_DEFINE
#endif
+#include "targetoutput.h"
+
+#ifndef TARGETOUTPUT_DEFINE
+#error Expected TARGETOUTPUT_DEFINE
+#endif
int bar()
{
diff --git a/Tests/AliasTarget/targetgenerator.cpp b/Tests/AliasTarget/targetgenerator.cpp
new file mode 100644
index 0000000..3362414
--- /dev/null
+++ b/Tests/AliasTarget/targetgenerator.cpp
@@ -0,0 +1,13 @@
+
+#include <fstream>
+
+int main(int argc, char **argv)
+{
+ std::fstream fout;
+ fout.open("targetoutput.h", std::ios::out);
+ if (!fout)
+ return 1;
+ fout << "#define TARGETOUTPUT_DEFINE\n";
+ fout.close();
+ return 0;
+}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41050e29a0a6a25aa7e47f8acbd5f467acb0b7ba
commit 41050e29a0a6a25aa7e47f8acbd5f467acb0b7ba
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 11:07:19 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:20 2013 +0200
Test that add_custom_command with an ALIAS works.
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index 8af4264..b1b6aed 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -13,11 +13,14 @@ target_compile_definitions(bar PUBLIC BAR_DEFINE)
target_link_libraries(foo LINK_PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:PREFIX::Foo,ALIASED_TARGET>,foo>:bar>)
-add_executable(AliasTarget empty.cpp)
+add_executable(AliasTarget commandgenerator.cpp)
add_executable(PREFIX::AliasTarget ALIAS AliasTarget)
-add_library(bat SHARED bat.cpp)
+add_custom_command(OUTPUT commandoutput.h COMMAND PREFIX::AliasTarget)
+
+add_library(bat SHARED bat.cpp "${CMAKE_CURRENT_BINARY_DIR}/commandoutput.h")
target_link_libraries(bat PREFIX::Foo)
+target_include_directories(bat PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
if (NOT TARGET Another::Alias)
message(SEND_ERROR "Another::Alias is not considered a target.")
diff --git a/Tests/AliasTarget/bat.cpp b/Tests/AliasTarget/bat.cpp
index 0f603bf..98830ec 100644
--- a/Tests/AliasTarget/bat.cpp
+++ b/Tests/AliasTarget/bat.cpp
@@ -7,6 +7,13 @@
#error Expected Bar_DEFINE
#endif
+#include "commandoutput.h"
+
+#ifndef COMMANDOUTPUT_DEFINE
+#error Expected COMMANDOUTPUT_DEFINE
+#endif
+
+
int bar()
{
return 0;
diff --git a/Tests/AliasTarget/commandgenerator.cpp b/Tests/AliasTarget/commandgenerator.cpp
new file mode 100644
index 0000000..988db85
--- /dev/null
+++ b/Tests/AliasTarget/commandgenerator.cpp
@@ -0,0 +1,13 @@
+
+#include <fstream>
+
+int main(int argc, char **argv)
+{
+ std::fstream fout;
+ fout.open("commandoutput.h", std::ios::out);
+ if (!fout)
+ return 1;
+ fout << "#define COMMANDOUTPUT_DEFINE\n";
+ fout.close();
+ return 0;
+}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1436e9e162f2e8fecee861e1aaad8bed9ac64e55
commit 1436e9e162f2e8fecee861e1aaad8bed9ac64e55
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 10:57:54 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:20 2013 +0200
cmTarget: Add the ALIASED_TARGET target property
If the target being read is an alias name, this returns the name
of the aliased target.
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index d0b6190..e0c8c9e 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -747,6 +747,18 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"Target name not supported.");
return std::string();
}
+ if(propertyName == "ALIASED_TARGET")
+ {
+ if(context->Makefile->IsAlias(targetName.c_str()))
+ {
+ if(cmTarget* tgt =
+ context->Makefile->FindTargetToUse(targetName.c_str()))
+ {
+ return tgt->GetName();
+ }
+ }
+ return "";
+ }
target = context->Makefile->FindTargetToUse(
targetName.c_str());
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 985dc50..faba7cd 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -288,6 +288,18 @@ bool cmGetPropertyCommand::HandleTargetMode()
return false;
}
+ if(this->PropertyName == "ALIASED_TARGET")
+ {
+ if(this->Makefile->IsAlias(this->Name.c_str()))
+ {
+ if(cmTarget* target =
+ this->Makefile->FindTargetToUse(this->Name.c_str()))
+ {
+ return this->StoreResult(target->GetName());
+ }
+ }
+ return false;
+ }
if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str()))
{
return this->StoreResult(target->GetProperty(this->PropertyName.c_str()));
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 1947139..02f00a5 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -22,17 +22,30 @@ bool cmGetTargetPropertyCommand
}
std::string var = args[0].c_str();
const char* targetName = args[1].c_str();
+ const char *prop = 0;
- if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
+ if(args[2] == "ALIASED_TARGET")
{
- cmTarget& target = *tgt;
- const char *prop = target.GetProperty(args[2].c_str());
- if (prop)
+ if(this->Makefile->IsAlias(targetName))
{
- this->Makefile->AddDefinition(var.c_str(), prop);
- return true;
+ if(cmTarget* target =
+ this->Makefile->FindTargetToUse(targetName))
+ {
+ prop = target->GetName();
+ }
}
}
+ else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
+ {
+ cmTarget& target = *tgt;
+ prop = target.GetProperty(args[2].c_str());
+ }
+
+ if (prop)
+ {
+ this->Makefile->AddDefinition(var.c_str(), prop);
+ return true;
+ }
this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());
return true;
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 667c685..13cd006 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -969,6 +969,12 @@ void cmTarget::DefineProperties(cmake *cm)
"This is the configuration-specific version of OUTPUT_NAME.");
cm->DefineProperty
+ ("ALIASED_TARGET", cmProperty::TARGET,
+ "Name of target aliased by this target.",
+ "If this is an ALIAS target, this property contains the name of the "
+ "target aliased.");
+
+ cm->DefineProperty
("<CONFIG>_OUTPUT_NAME", cmProperty::TARGET,
"Old per-configuration target file base name.",
"This is a configuration-specific version of OUTPUT_NAME. "
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index e7ef057..8af4264 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -11,7 +11,7 @@ target_compile_definitions(foo PUBLIC FOO_DEFINE)
add_library(bar SHARED empty.cpp)
target_compile_definitions(bar PUBLIC BAR_DEFINE)
-target_link_libraries(foo LINK_PUBLIC bar)
+target_link_libraries(foo LINK_PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:PREFIX::Foo,ALIASED_TARGET>,foo>:bar>)
add_executable(AliasTarget empty.cpp)
add_executable(PREFIX::AliasTarget ALIAS AliasTarget)
@@ -22,3 +22,13 @@ target_link_libraries(bat PREFIX::Foo)
if (NOT TARGET Another::Alias)
message(SEND_ERROR "Another::Alias is not considered a target.")
endif()
+
+get_target_property(_alt PREFIX::Foo ALIASED_TARGET)
+if (NOT ${_alt} STREQUAL foo)
+ message(SEND_ERROR "ALIASED_TARGET is not foo: ${_alt}")
+endif()
+
+get_property(_alt2 TARGET PREFIX::Foo PROPERTY ALIASED_TARGET)
+if (NOT ${_alt2} STREQUAL foo)
+ message(SEND_ERROR "ALIASED_TARGET is not foo.")
+endif()
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5f10205ce4dda0a776a39f150c924502c0584772
commit 5f10205ce4dda0a776a39f150c924502c0584772
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 10:32:58 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:20 2013 +0200
Document that an ALIAS may not be installed or exported.
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index 1067e56..3cd51fc 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -115,7 +115,8 @@ public:
"buildsystem as a make target. The <target> may not be an IMPORTED "
"target or an ALIAS. The <name> may not be used to modify properties "
"of <target>, that is, it may not be used as the operand of "
- "set_property, set_target_properties, target_link_libraries etc."
+ "set_property, set_target_properties, target_link_libraries etc. An "
+ "ALIAS target may not be installed of exported."
;
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1eebeb3e6db64adbc0271efdf83cab494cc28d03
commit 1eebeb3e6db64adbc0271efdf83cab494cc28d03
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 10:24:07 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:49:20 2013 +0200
Make sure the add_ commands can only handle appropriate target types.
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 1205bcc..5785259 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -115,8 +115,6 @@ bool cmAddExecutableCommand
}
const char *aliasedName = s->c_str();
- cmTarget *aliasedTarget =
- this->Makefile->FindTargetToUse(aliasedName, true);
if(this->Makefile->IsAlias(aliasedName))
{
cmOStringStream e;
@@ -125,6 +123,8 @@ bool cmAddExecutableCommand
this->SetError(e.str().c_str());
return false;
}
+ cmTarget *aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
if(!aliasedTarget)
{
cmOStringStream e;
@@ -134,6 +134,16 @@ bool cmAddExecutableCommand
this->SetError(e.str().c_str());
return false;
}
+ cmTarget::TargetType type = aliasedTarget->GetType();
+ if(type != cmTarget::EXECUTABLE)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" is not an "
+ "executable.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
if(aliasedTarget->IsImported())
{
cmOStringStream e;
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index a94ce90..cbc6ed1 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -128,8 +128,6 @@ bool cmAddLibraryCommand
}
const char *aliasedName = s->c_str();
- cmTarget *aliasedTarget =
- this->Makefile->FindTargetToUse(aliasedName, true);
if(this->Makefile->IsAlias(aliasedName))
{
cmOStringStream e;
@@ -138,6 +136,8 @@ bool cmAddLibraryCommand
this->SetError(e.str().c_str());
return false;
}
+ cmTarget *aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
if(!aliasedTarget)
{
cmOStringStream e;
@@ -147,6 +147,18 @@ bool cmAddLibraryCommand
this->SetError(e.str().c_str());
return false;
}
+ cmTarget::TargetType aliasedType = aliasedTarget->GetType();
+ if(aliasedType != cmTarget::SHARED_LIBRARY
+ && aliasedType != cmTarget::STATIC_LIBRARY
+ && aliasedType != cmTarget::MODULE_LIBRARY
+ && aliasedType != cmTarget::OBJECT_LIBRARY)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" is not a library.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
if(aliasedTarget->IsImported())
{
cmOStringStream e;
diff --git a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
index 5bcba53..9a5eaaf 100644
--- a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
@@ -16,3 +16,5 @@ run_cmake(export)
run_cmake(install-export)
run_cmake(name-conflict)
run_cmake(add_dependencies)
+run_cmake(add_executable-library)
+run_cmake(add_library-executable)
diff --git a/Tests/RunCMake/alias_targets/add_executable-library-result.txt b/Tests/RunCMake/alias_targets/add_executable-library-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_executable-library-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/add_executable-library-stderr.txt b/Tests/RunCMake/alias_targets/add_executable-library-stderr.txt
new file mode 100644
index 0000000..eb22b3d
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_executable-library-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at add_executable-library.cmake:6 \(add_executable\):
+ add_executable cannot create ALIAS target "alias" because target "foo" is
+ not an executable.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/add_executable-library.cmake b/Tests/RunCMake/alias_targets/add_executable-library.cmake
new file mode 100644
index 0000000..e30f112
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_executable-library.cmake
@@ -0,0 +1,6 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_executable(alias ALIAS foo)
diff --git a/Tests/RunCMake/alias_targets/add_library-executable-result.txt b/Tests/RunCMake/alias_targets/add_library-executable-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_library-executable-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/add_library-executable-stderr.txt b/Tests/RunCMake/alias_targets/add_library-executable-stderr.txt
new file mode 100644
index 0000000..ee290e4
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_library-executable-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at add_library-executable.cmake:6 \(add_library\):
+ add_library cannot create ALIAS target "alias" because target "foo" is not
+ a library.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/add_library-executable.cmake b/Tests/RunCMake/alias_targets/add_library-executable.cmake
new file mode 100644
index 0000000..22457a9
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_library-executable.cmake
@@ -0,0 +1,6 @@
+
+enable_language(CXX)
+
+add_executable(foo empty.cpp)
+
+add_library(alias ALIAS foo)
diff --git a/Tests/RunCMake/alias_targets/define_property-result.txt b/Tests/RunCMake/alias_targets/define_property-result.txt
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/alias_targets/define_property-stderr.txt b/Tests/RunCMake/alias_targets/define_property-stderr.txt
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/alias_targets/define_property.cmake b/Tests/RunCMake/alias_targets/define_property.cmake
new file mode 100644
index 0000000..9da59da
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/define_property.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+define_property(TARGET PROPERTY alias bar)
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7197f536c45b2ff1a64ee715225dc98caf92dd57
commit 7197f536c45b2ff1a64ee715225dc98caf92dd57
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Jul 12 09:14:31 2013 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Aug 2 12:48:34 2013 +0200
Add the ALIAS_LIBRARY target type.
* The ALIAS name must match a validity regex.
* Executables and libraries may be aliased.
* An ALIAS acts immutable. It can not be used as the lhs
of target_link_libraries or other commands.
* An ALIAS does not appear in the generated buildsystem. It
is kept separate from cmMakefile::Targets for that reason.
* A target may have multiple aliases.
* An ALIAS target may not itself have an alias.
* An IMPORTED target may not have an alias.
* An ALIAS may not be exported or imported.
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 04a304e..e4d7f7f 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -24,6 +24,13 @@ bool cmAddDependenciesCommand
}
std::string target_name = args[0];
+ if(this->Makefile->IsAlias(target_name.c_str()))
+ {
+ cmOStringStream e;
+ e << "Cannot add target-level dependencies to alias target \""
+ << target_name << "\".\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str()))
{
std::vector<std::string>::const_iterator s = args.begin();
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 6dd8e5c..1205bcc 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -30,6 +30,7 @@ bool cmAddExecutableCommand
bool excludeFromAll = false;
bool importTarget = false;
bool importGlobal = false;
+ bool isAlias = false;
while ( s != args.end() )
{
if (*s == "WIN32")
@@ -57,6 +58,11 @@ bool cmAddExecutableCommand
++s;
importGlobal = true;
}
+ else if(*s == "ALIAS")
+ {
+ ++s;
+ isAlias = true;
+ }
else
{
break;
@@ -83,6 +89,62 @@ bool cmAddExecutableCommand
}
return false;
}
+ if (isAlias)
+ {
+ if(!cmGeneratorExpression::IsValidTargetName(exename.c_str()))
+ {
+ this->SetError(("Invalid name for ALIAS: " + exename).c_str());
+ return false;
+ }
+ if(excludeFromAll)
+ {
+ this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
+ return false;
+ }
+ if(importTarget || importGlobal)
+ {
+ this->SetError("IMPORTED with ALIAS is not allowed.");
+ return false;
+ }
+ if(args.size() != 3)
+ {
+ cmOStringStream e;
+ e << "ALIAS requires exactly one target argument.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ const char *aliasedName = s->c_str();
+ cmTarget *aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
+ if(this->Makefile->IsAlias(aliasedName))
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ if(!aliasedTarget)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" does not already "
+ "exist.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ if(aliasedTarget->IsImported())
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << exename
+ << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ this->Makefile->AddAlias(exename.c_str(), aliasedTarget);
+ return true;
+ }
// Handle imported target creation.
if(importTarget)
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index 1e9f9b3..1067e56 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -107,6 +107,15 @@ public:
"(and its per-configuration version IMPORTED_LOCATION_<CONFIG>) "
"which specifies the location of the main executable file on disk. "
"See documentation of the IMPORTED_* properties for more information."
+ "\n"
+ "The signature\n"
+ " add_executable(<name> ALIAS <target>)\n"
+ "creates an alias, such that <name> can be used to refer to <target> "
+ "in subsequent commands. The <name> does not appear in the generated "
+ "buildsystem as a make target. The <target> may not be an IMPORTED "
+ "target or an ALIAS. The <name> may not be used to modify properties "
+ "of <target>, that is, it may not be used as the operand of "
+ "set_property, set_target_properties, target_link_libraries etc."
;
}
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index fd39eec..a94ce90 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -43,6 +43,7 @@ bool cmAddLibraryCommand
// the type of library. Otherwise, it is treated as a source or
// source list name. There may be two keyword arguments, check for them
bool haveSpecifiedType = false;
+ bool isAlias = false;
while ( s != args.end() )
{
std::string libType = *s;
@@ -76,6 +77,11 @@ bool cmAddLibraryCommand
type = cmTarget::UNKNOWN_LIBRARY;
haveSpecifiedType = true;
}
+ else if(libType == "ALIAS")
+ {
+ ++s;
+ isAlias = true;
+ }
else if(*s == "EXCLUDE_FROM_ALL")
{
++s;
@@ -96,6 +102,68 @@ bool cmAddLibraryCommand
break;
}
}
+ if (isAlias)
+ {
+ if(!cmGeneratorExpression::IsValidTargetName(libName.c_str()))
+ {
+ this->SetError(("Invalid name for ALIAS: " + libName).c_str());
+ return false;
+ }
+ if(excludeFromAll)
+ {
+ this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
+ return false;
+ }
+ if(importTarget || importGlobal)
+ {
+ this->SetError("IMPORTED with ALIAS is not allowed.");
+ return false;
+ }
+ if(args.size() != 3)
+ {
+ cmOStringStream e;
+ e << "ALIAS requires exactly one target argument.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ const char *aliasedName = s->c_str();
+ cmTarget *aliasedTarget =
+ this->Makefile->FindTargetToUse(aliasedName, true);
+ if(this->Makefile->IsAlias(aliasedName))
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ if(!aliasedTarget)
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" does not already "
+ "exist.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ if(aliasedTarget->IsImported())
+ {
+ cmOStringStream e;
+ e << "cannot create ALIAS target \"" << libName
+ << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ this->Makefile->AddAlias(libName.c_str(), aliasedTarget);
+ return true;
+ }
+
+ if(importTarget && excludeFromAll)
+ {
+ this->SetError("excludeFromAll with IMPORTED target makes no sense.");
+ return false;
+ }
/* ideally we should check whether for the linker language of the target
CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index e5f27cb..1ccb152 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -138,6 +138,15 @@ public:
"Some native build systems may not like targets that have only "
"object files, so consider adding at least one real source file "
"to any target that references $<TARGET_OBJECTS:objlib>."
+ "\n"
+ "The signature\n"
+ " add_library(<name> ALIAS <target>)\n"
+ "creates an alias, such that <name> can be used to refer to <target> "
+ "in subsequent commands. The <name> does not appear in the generated "
+ "buildsystem as a make target. The <target> may not be an IMPORTED "
+ "target or an ALIAS. The <name> may not be used to modify properties "
+ "of <target>, that is, it may not be used as the operand of "
+ "set_property, set_target_properties, target_link_libraries etc."
;
}
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 9c3f314..f059ceb 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -114,6 +114,15 @@ bool cmExportCommand
currentTarget != this->Targets.GetVector().end();
++currentTarget)
{
+ if (this->Makefile->IsAlias(currentTarget->c_str()))
+ {
+ cmOStringStream e;
+ e << "given ALIAS target \"" << *currentTarget
+ << "\" which may not be exported.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
if(cmTarget* target =
this->Makefile->GetLocalGenerator()->
GetGlobalGenerator()->FindTarget(0, currentTarget->c_str()))
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 9b6ac93..7f2b592 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1769,10 +1769,22 @@ cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir)
return 0;
}
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt)
+{
+ this->AliasTargets[name] = tgt;
+}
+
+//----------------------------------------------------------------------------
+bool cmGlobalGenerator::IsAlias(const char *name)
+{
+ return this->AliasTargets.find(name) != this->AliasTargets.end();
+}
//----------------------------------------------------------------------------
cmTarget*
-cmGlobalGenerator::FindTarget(const char* project, const char* name)
+cmGlobalGenerator::FindTarget(const char* project, const char* name,
+ bool excludeAliases)
{
// if project specific
if(project)
@@ -1780,7 +1792,8 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name)
std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project];
for(unsigned int i = 0; i < gens->size(); ++i)
{
- cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name);
+ cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name,
+ excludeAliases);
if(ret)
{
return ret;
@@ -1790,6 +1803,15 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name)
// if all projects/directories
else
{
+ if (!excludeAliases)
+ {
+ std::map<cmStdString, cmTarget*>::iterator ai
+ = this->AliasTargets.find(name);
+ if (ai != this->AliasTargets.end())
+ {
+ return ai->second;
+ }
+ }
std::map<cmStdString,cmTarget *>::iterator i =
this->TotalTargets.find ( name );
if ( i != this->TotalTargets.end() )
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 2fcdc43..18aba24 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -196,7 +196,11 @@ public:
void FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
- cmTarget* FindTarget(const char* project, const char* name);
+ cmTarget* FindTarget(const char* project, const char* name,
+ bool excludeAliases = false);
+
+ void AddAlias(const char *name, cmTarget *tgt);
+ bool IsAlias(const char *name);
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
@@ -347,6 +351,7 @@ protected:
// All targets in the entire project.
std::map<cmStdString,cmTarget *> TotalTargets;
+ std::map<cmStdString,cmTarget *> AliasTargets;
std::map<cmStdString,cmTarget *> ImportedTargets;
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 0faf1d4..3c76bd6 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -362,6 +362,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
targetIt!=targetList.GetVector().end();
++targetIt)
{
+
+ if (this->Makefile->IsAlias(targetIt->c_str()))
+ {
+ cmOStringStream e;
+ e << "TARGETS given target \"" << (*targetIt)
+ << "\" which is an alias.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
// Lookup this target in the current directory.
if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str()))
{
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1920cc0..aae92dd 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -41,6 +41,7 @@
#include <stack>
#include <ctype.h> // for isspace
+#include <assert.h>
class cmMakefile::Internals
{
@@ -1437,6 +1438,14 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
cmTargets::iterator i = this->Targets.find(target);
if ( i != this->Targets.end())
{
+ if(this->IsAlias(target))
+ {
+ cmOStringStream e;
+ e << "ALIAS target \"" << target << "\" "
+ << "may not be linked into another target.";
+ this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ return;
+ }
i->second.AddLinkDirectory( d );
}
else
@@ -1923,6 +1932,12 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
}
+void cmMakefile::AddAlias(const char* lname, cmTarget *tgt)
+{
+ this->AliasTargets[lname] = tgt;
+ this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
+}
+
cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll)
@@ -3758,8 +3773,17 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config)
return 0;
}
-cmTarget* cmMakefile::FindTarget(const char* name)
+cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases)
{
+ if (!excludeAliases)
+ {
+ std::map<std::string, cmTarget*>::iterator i
+ = this->AliasTargets.find(name);
+ if (i != this->AliasTargets.end())
+ {
+ return i->second;
+ }
+ }
cmTargets& tgts = this->GetTargets();
cmTargets::iterator i = tgts.find ( name );
@@ -4184,7 +4208,7 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
}
//----------------------------------------------------------------------------
-cmTarget* cmMakefile::FindTargetToUse(const char* name)
+cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases)
{
// Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique.
@@ -4196,15 +4220,25 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name)
}
// Look for a target built in this directory.
- if(cmTarget* t = this->FindTarget(name))
+ if(cmTarget* t = this->FindTarget(name, excludeAliases))
{
return t;
}
// Look for a target built in this project.
- return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name);
+ return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name,
+ excludeAliases);
}
+//----------------------------------------------------------------------------
+bool cmMakefile::IsAlias(const char *name)
+{
+ if (this->AliasTargets.find(name) != this->AliasTargets.end())
+ return true;
+ return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(name);
+}
+
+//----------------------------------------------------------------------------
cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
{
cmTarget *t = this->FindTargetToUse(name);
@@ -4215,6 +4249,14 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom)
{
+ if(this->IsAlias(name.c_str()))
+ {
+ cmOStringStream e;
+ e << "cannot create target \"" << name
+ << "\" because an alias with the same name already exists.";
+ msg = e.str();
+ return false;
+ }
if(cmTarget* existing = this->FindTargetToUse(name.c_str()))
{
// The name given conflicts with an existing target. Produce an
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 871fa1b..711a208 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -337,6 +337,7 @@ public:
cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll = false);
+ void AddAlias(const char *libname, cmTarget *tgt);
#if defined(CMAKE_BUILD_WITH_CMAKE)
/**
@@ -536,11 +537,12 @@ public:
this->GeneratorTargets = targets;
}
- cmTarget* FindTarget(const char* name);
+ cmTarget* FindTarget(const char* name, bool excludeAliases = false);
/** Find a target to use in place of the given name. The target
returned may be imported or built within the project. */
- cmTarget* FindTargetToUse(const char* name);
+ cmTarget* FindTargetToUse(const char* name, bool excludeAliases = false);
+ bool IsAlias(const char *name);
cmGeneratorTarget* FindGeneratorTargetToUse(const char* name);
/**
@@ -902,6 +904,7 @@ protected:
// libraries, classes, and executables
cmTargets Targets;
+ std::map<std::string, cmTarget*> AliasTargets;
cmGeneratorTargetsType GeneratorTargets;
std::vector<cmSourceFile*> SourceFiles;
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index b5e5225..4207860 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -244,6 +244,11 @@ bool cmSetPropertyCommand::HandleTargetMode()
for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
{
+ if (this->Makefile->IsAlias(ni->c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
if(cmTarget* target = this->Makefile->FindTargetToUse(ni->c_str()))
{
// Handle the current target.
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index a2b50a8..78ef393 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -72,6 +72,11 @@ bool cmSetTargetPropertiesCommand
int i;
for(i = 0; i < numFiles; ++i)
{
+ if (this->Makefile->IsAlias(args[i].c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
bool ret = cmSetTargetPropertiesCommand::SetOneTarget
(args[i].c_str(),propertyPairs,this->Makefile);
if (!ret)
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 0ee9420..863b391 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -31,6 +31,11 @@ bool cmTargetLinkLibrariesCommand
return false;
}
+ if (this->Makefile->IsAlias(args[0].c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
// Lookup the target for which libraries are specified.
this->Target =
this->Makefile->GetCMakeInstance()
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 37aa604..1862cb6 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -26,6 +26,11 @@ bool cmTargetPropCommandBase
}
// Lookup the target for which libraries are specified.
+ if (this->Makefile->IsAlias(args[0].c_str()))
+ {
+ this->SetError("can not be used on an ALIAS target.");
+ return false;
+ }
this->Target =
this->Makefile->GetCMakeInstance()
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
new file mode 100644
index 0000000..e7ef057
--- /dev/null
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -0,0 +1,24 @@
+
+cmake_minimum_required(VERSION 2.8.11)
+project(AliasTarget)
+
+add_library(foo SHARED empty.cpp)
+add_library(PREFIX::Foo ALIAS foo)
+add_library(Another::Alias ALIAS foo)
+
+target_compile_definitions(foo PUBLIC FOO_DEFINE)
+
+add_library(bar SHARED empty.cpp)
+target_compile_definitions(bar PUBLIC BAR_DEFINE)
+
+target_link_libraries(foo LINK_PUBLIC bar)
+
+add_executable(AliasTarget empty.cpp)
+add_executable(PREFIX::AliasTarget ALIAS AliasTarget)
+
+add_library(bat SHARED bat.cpp)
+target_link_libraries(bat PREFIX::Foo)
+
+if (NOT TARGET Another::Alias)
+ message(SEND_ERROR "Another::Alias is not considered a target.")
+endif()
diff --git a/Tests/AliasTarget/bat.cpp b/Tests/AliasTarget/bat.cpp
new file mode 100644
index 0000000..0f603bf
--- /dev/null
+++ b/Tests/AliasTarget/bat.cpp
@@ -0,0 +1,13 @@
+
+#ifndef FOO_DEFINE
+#error Expected FOO_DEFINE
+#endif
+
+#ifndef BAR_DEFINE
+#error Expected Bar_DEFINE
+#endif
+
+int bar()
+{
+ return 0;
+}
diff --git a/Tests/AliasTarget/empty.cpp b/Tests/AliasTarget/empty.cpp
new file mode 100644
index 0000000..b19427a
--- /dev/null
+++ b/Tests/AliasTarget/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 16693de..dc8d869 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -245,6 +245,7 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
ADD_TEST_MACRO(CompileOptions CompileOptions)
ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
+ ADD_TEST_MACRO(AliasTarget AliasTarget)
set_tests_properties(EmptyLibrary PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
ADD_TEST_MACRO(CrossCompile CrossCompile)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 6d1bca2..1b9c17b 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -98,6 +98,7 @@ add_RunCMake_test(try_compile)
add_RunCMake_test(variable_watch)
add_RunCMake_test(CMP0004)
add_RunCMake_test(TargetPolicies)
+add_RunCMake_test(alias_targets)
find_package(Qt4 QUIET)
find_package(Qt5Core QUIET)
diff --git a/Tests/RunCMake/alias_targets/CMakeLists.txt b/Tests/RunCMake/alias_targets/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
new file mode 100644
index 0000000..5bcba53
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
@@ -0,0 +1,18 @@
+include(RunCMake)
+
+run_cmake(no-targets)
+run_cmake(multiple-targets)
+run_cmake(exclude-from-all)
+run_cmake(imported)
+run_cmake(invalid-name)
+run_cmake(invalid-target)
+run_cmake(imported-target)
+run_cmake(alias-target)
+run_cmake(set_property)
+run_cmake(set_target_properties)
+run_cmake(target_link_libraries)
+run_cmake(target_include_directories)
+run_cmake(export)
+run_cmake(install-export)
+run_cmake(name-conflict)
+run_cmake(add_dependencies)
diff --git a/Tests/RunCMake/alias_targets/add_dependencies-result.txt b/Tests/RunCMake/alias_targets/add_dependencies-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_dependencies-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/add_dependencies-stderr.txt b/Tests/RunCMake/alias_targets/add_dependencies-stderr.txt
new file mode 100644
index 0000000..53f2487
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_dependencies-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at add_dependencies.cmake:9 \(add_dependencies\):
+ Cannot add target-level dependencies to alias target "alias".
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/add_dependencies.cmake b/Tests/RunCMake/alias_targets/add_dependencies.cmake
new file mode 100644
index 0000000..7436371
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/add_dependencies.cmake
@@ -0,0 +1,9 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+add_library(bar empty.cpp)
+
+add_library(alias ALIAS foo)
+
+add_dependencies(alias bar)
diff --git a/Tests/RunCMake/alias_targets/alias-target-result.txt b/Tests/RunCMake/alias_targets/alias-target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/alias-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/alias-target-stderr.txt b/Tests/RunCMake/alias_targets/alias-target-stderr.txt
new file mode 100644
index 0000000..eae227a
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/alias-target-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at alias-target.cmake:8 \(add_library\):
+ add_library cannot create ALIAS target "next_alias" because target "alias"
+ is itself an ALIAS.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/alias-target.cmake b/Tests/RunCMake/alias_targets/alias-target.cmake
new file mode 100644
index 0000000..0b8da60
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/alias-target.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+add_library(next_alias ALIAS alias)
diff --git a/Tests/RunCMake/alias_targets/empty.cpp b/Tests/RunCMake/alias_targets/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/alias_targets/exclude-from-all-result.txt b/Tests/RunCMake/alias_targets/exclude-from-all-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/exclude-from-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/exclude-from-all-stderr.txt b/Tests/RunCMake/alias_targets/exclude-from-all-stderr.txt
new file mode 100644
index 0000000..fce15d3
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/exclude-from-all-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at exclude-from-all.cmake:6 \(add_library\):
+ add_library EXCLUDE_FROM_ALL with ALIAS makes no sense.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/exclude-from-all.cmake b/Tests/RunCMake/alias_targets/exclude-from-all.cmake
new file mode 100644
index 0000000..0091918
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/exclude-from-all.cmake
@@ -0,0 +1,6 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS EXCLUDE_FROM_ALL foo)
diff --git a/Tests/RunCMake/alias_targets/export-result.txt b/Tests/RunCMake/alias_targets/export-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/export-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/export-stderr.txt b/Tests/RunCMake/alias_targets/export-stderr.txt
new file mode 100644
index 0000000..848b984
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/export-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at export.cmake:8 \(export\):
+ export given ALIAS target "alias" which may not be exported.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/export.cmake b/Tests/RunCMake/alias_targets/export.cmake
new file mode 100644
index 0000000..dd84a80
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/export.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+export(TARGETS alias FILE someFile.cmake)
diff --git a/Tests/RunCMake/alias_targets/imported-result.txt b/Tests/RunCMake/alias_targets/imported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/imported-stderr.txt b/Tests/RunCMake/alias_targets/imported-stderr.txt
new file mode 100644
index 0000000..b905847
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at imported.cmake:2 \(add_library\):
+ add_library IMPORTED with ALIAS is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/imported-target-result.txt b/Tests/RunCMake/alias_targets/imported-target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/imported-target-stderr.txt b/Tests/RunCMake/alias_targets/imported-target-stderr.txt
new file mode 100644
index 0000000..bbff29a
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-target-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at imported-target.cmake:6 \(add_library\):
+ add_library cannot create ALIAS target "alias" because target "foo" is
+ IMPORTED.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/imported-target.cmake b/Tests/RunCMake/alias_targets/imported-target.cmake
new file mode 100644
index 0000000..7259ab0
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-target.cmake
@@ -0,0 +1,6 @@
+
+enable_language(CXX)
+
+add_library(foo SHARED IMPORTED)
+
+add_library(alias ALIAS foo)
diff --git a/Tests/RunCMake/alias_targets/imported.cmake b/Tests/RunCMake/alias_targets/imported.cmake
new file mode 100644
index 0000000..6a60591
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported.cmake
@@ -0,0 +1,2 @@
+
+add_library(alias IMPORTED ALIAS)
diff --git a/Tests/RunCMake/alias_targets/install-export-result.txt b/Tests/RunCMake/alias_targets/install-export-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/install-export-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/install-export-stderr.txt b/Tests/RunCMake/alias_targets/install-export-stderr.txt
new file mode 100644
index 0000000..3c3c0ed
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/install-export-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at install-export.cmake:8 \(install\):
+ install TARGETS given target "alias" which is an alias.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/install-export.cmake b/Tests/RunCMake/alias_targets/install-export.cmake
new file mode 100644
index 0000000..b1c6a4f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/install-export.cmake
@@ -0,0 +1,9 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+install(TARGETS alias EXPORT theTargets DESTINATION prefix)
+install(EXPORT theTargets DESTINATION lib/cmake)
diff --git a/Tests/RunCMake/alias_targets/invalid-name-result.txt b/Tests/RunCMake/alias_targets/invalid-name-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/invalid-name-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/invalid-name-stderr.txt b/Tests/RunCMake/alias_targets/invalid-name-stderr.txt
new file mode 100644
index 0000000..d33b57c
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/invalid-name-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at invalid-name.cmake:6 \(add_library\):
+ add_library Invalid name for ALIAS: invalid\$name
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/invalid-name.cmake b/Tests/RunCMake/alias_targets/invalid-name.cmake
new file mode 100644
index 0000000..bbd39e3
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/invalid-name.cmake
@@ -0,0 +1,6 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(invalid$name ALIAS foo)
diff --git a/Tests/RunCMake/alias_targets/invalid-target-result.txt b/Tests/RunCMake/alias_targets/invalid-target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/invalid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/invalid-target-stderr.txt b/Tests/RunCMake/alias_targets/invalid-target-stderr.txt
new file mode 100644
index 0000000..342d488
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/invalid-target-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at invalid-target.cmake:2 \(add_library\):
+ add_library cannot create ALIAS target "alias" because target "foo" does
+ not already exist.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/invalid-target.cmake b/Tests/RunCMake/alias_targets/invalid-target.cmake
new file mode 100644
index 0000000..c43da61
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/invalid-target.cmake
@@ -0,0 +1,2 @@
+
+add_library(alias ALIAS foo)
diff --git a/Tests/RunCMake/alias_targets/multiple-targets-result.txt b/Tests/RunCMake/alias_targets/multiple-targets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/multiple-targets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/multiple-targets-stderr.txt b/Tests/RunCMake/alias_targets/multiple-targets-stderr.txt
new file mode 100644
index 0000000..596f404
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/multiple-targets-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at multiple-targets.cmake:7 \(add_library\):
+ add_library ALIAS requires exactly one target argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/multiple-targets.cmake b/Tests/RunCMake/alias_targets/multiple-targets.cmake
new file mode 100644
index 0000000..811eb7a
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/multiple-targets.cmake
@@ -0,0 +1,7 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+add_library(bar empty.cpp)
+
+add_library(alias ALIAS foo bar)
diff --git a/Tests/RunCMake/alias_targets/name-conflict-result.txt b/Tests/RunCMake/alias_targets/name-conflict-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/name-conflict-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/name-conflict-stderr.txt b/Tests/RunCMake/alias_targets/name-conflict-stderr.txt
new file mode 100644
index 0000000..3c0faa9
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/name-conflict-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at name-conflict.cmake:8 \(add_library\):
+ add_library cannot create target "bar" because an alias with the same name
+ already exists.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/name-conflict.cmake b/Tests/RunCMake/alias_targets/name-conflict.cmake
new file mode 100644
index 0000000..d21a092
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/name-conflict.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(bar ALIAS foo)
+
+add_library(bar empty.cpp)
diff --git a/Tests/RunCMake/alias_targets/no-targets-result.txt b/Tests/RunCMake/alias_targets/no-targets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/no-targets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/no-targets-stderr.txt b/Tests/RunCMake/alias_targets/no-targets-stderr.txt
new file mode 100644
index 0000000..cdf7e57
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/no-targets-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at no-targets.cmake:4 \(add_library\):
+ add_library ALIAS requires exactly one target argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/no-targets.cmake b/Tests/RunCMake/alias_targets/no-targets.cmake
new file mode 100644
index 0000000..a5c5ee5
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/no-targets.cmake
@@ -0,0 +1,4 @@
+
+enable_language(CXX)
+
+add_library(alias ALIAS)
diff --git a/Tests/RunCMake/alias_targets/set_property-result.txt b/Tests/RunCMake/alias_targets/set_property-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/set_property-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/set_property-stderr.txt b/Tests/RunCMake/alias_targets/set_property-stderr.txt
new file mode 100644
index 0000000..e85aa56
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/set_property-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at set_property.cmake:8 \(set_property\):
+ set_property can not be used on an ALIAS target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/set_property.cmake b/Tests/RunCMake/alias_targets/set_property.cmake
new file mode 100644
index 0000000..1f5e475
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/set_property.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+set_property(TARGET alias PROPERTY ANYTHING 1)
diff --git a/Tests/RunCMake/alias_targets/set_target_properties-result.txt b/Tests/RunCMake/alias_targets/set_target_properties-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/set_target_properties-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/set_target_properties-stderr.txt b/Tests/RunCMake/alias_targets/set_target_properties-stderr.txt
new file mode 100644
index 0000000..8922c0d
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/set_target_properties-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at set_target_properties.cmake:8 \(set_target_properties\):
+ set_target_properties can not be used on an ALIAS target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/set_target_properties.cmake b/Tests/RunCMake/alias_targets/set_target_properties.cmake
new file mode 100644
index 0000000..ee44d45
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/set_target_properties.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+set_target_properties(alias PROPERTIES ANYTHING 1)
diff --git a/Tests/RunCMake/alias_targets/target_include_directories-result.txt b/Tests/RunCMake/alias_targets/target_include_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/target_include_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/target_include_directories-stderr.txt b/Tests/RunCMake/alias_targets/target_include_directories-stderr.txt
new file mode 100644
index 0000000..b8903b2
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/target_include_directories-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at target_include_directories.cmake:8 \(target_include_directories\):
+ target_include_directories can not be used on an ALIAS target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/target_include_directories.cmake b/Tests/RunCMake/alias_targets/target_include_directories.cmake
new file mode 100644
index 0000000..c26830e
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/target_include_directories.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+
+add_library(alias ALIAS foo)
+
+target_include_directories(alias PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
diff --git a/Tests/RunCMake/alias_targets/target_link_libraries-result.txt b/Tests/RunCMake/alias_targets/target_link_libraries-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/target_link_libraries-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/alias_targets/target_link_libraries-stderr.txt b/Tests/RunCMake/alias_targets/target_link_libraries-stderr.txt
new file mode 100644
index 0000000..2d7ff20
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/target_link_libraries-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at target_link_libraries.cmake:9 \(target_link_libraries\):
+ target_link_libraries can not be used on an ALIAS target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/alias_targets/target_link_libraries.cmake b/Tests/RunCMake/alias_targets/target_link_libraries.cmake
new file mode 100644
index 0000000..b7b9e60
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/target_link_libraries.cmake
@@ -0,0 +1,9 @@
+
+enable_language(CXX)
+
+add_library(foo empty.cpp)
+add_library(bar empty.cpp)
+
+add_library(alias ALIAS foo)
+
+target_link_libraries(alias bar)
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list