[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3592-g0c1a35e
Stephen Kelly
steveire at gmail.com
Fri Aug 2 06:01:09 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 0c1a35e1dca13ad5547dfae722c3dffd339a501d (commit)
via b5673a7cebe3faf4d56cebc73d181e48f29bb9e2 (commit)
via 1e920b668ca71bed35495ef2613173ef3c31fbfd (commit)
via 775e9ff677c3c416143c82aae686664926f8aad3 (commit)
via 80a10f04d9be14a130a3e2cc50079b84d6ae3ecc (commit)
via 556233f7cf7c14bba6cdd2fec8e03c9960cdd691 (commit)
via 17c80f022ff4bdbc3b1dd97faf22b60a497cdac4 (commit)
via a18bb5999a14349dc10e8c21d406b9a07411ec81 (commit)
via c5802c8b9e3076050e87361065627a1670de2a7c (commit)
via e9f8f655b517ed3ae5270342ddce8d3d7fc90499 (commit)
from 66ce77585b9de2443b77e37d793886dc11717a43 (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=0c1a35e1dca13ad5547dfae722c3dffd339a501d
commit 0c1a35e1dca13ad5547dfae722c3dffd339a501d
Merge: 66ce775 b5673a7
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Aug 2 06:01:05 2013 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Aug 2 06:01:05 2013 -0400
Merge topic 'ALIAS-targets' into next
b5673a7 Test the behavior of $<TARGET_PROPERTY:Alias,NAME>
1e920b6 Test that an OBJECT_LIBRARY ALIAS works.
775e9ff Test that $<TARGET_FILE> works.
80a10f0 Test that add_test works with an ALIAS.
556233f Make sure add_custom_target works with an ALIAS.
17c80f0 Test that add_custom_command with an ALIAS works.
a18bb59 cmTarget: Add the ALIASED_TARGET target property
c5802c8 Document that an ALIAS may not be installed or exported.
e9f8f65 Make sure the add_ commands can only handle appropriate target types.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5673a7cebe3faf4d56cebc73d181e48f29bb9e2
commit b5673a7cebe3faf4d56cebc73d181e48f29bb9e2
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:00:31 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=1e920b668ca71bed35495ef2613173ef3c31fbfd
commit 1e920b668ca71bed35495ef2613173ef3c31fbfd
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:00:31 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();
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=775e9ff677c3c416143c82aae686664926f8aad3
commit 775e9ff677c3c416143c82aae686664926f8aad3
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:00:31 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=80a10f04d9be14a130a3e2cc50079b84d6ae3ecc
commit 80a10f04d9be14a130a3e2cc50079b84d6ae3ecc
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:00:31 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=556233f7cf7c14bba6cdd2fec8e03c9960cdd691
commit 556233f7cf7c14bba6cdd2fec8e03c9960cdd691
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:00:31 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=17c80f022ff4bdbc3b1dd97faf22b60a497cdac4
commit 17c80f022ff4bdbc3b1dd97faf22b60a497cdac4
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:00:31 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=a18bb5999a14349dc10e8c21d406b9a07411ec81
commit a18bb5999a14349dc10e8c21d406b9a07411ec81
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:00:31 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=c5802c8b9e3076050e87361065627a1670de2a7c
commit c5802c8b9e3076050e87361065627a1670de2a7c
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:00:30 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=e9f8f655b517ed3ae5270342ddce8d3d7fc90499
commit e9f8f655b517ed3ae5270342ddce8d3d7fc90499
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:00:10 2013 +0200
Make sure the add_ commands can only handle appropriate target types.
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 8537276..049f999 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 c6071b1..1f5fe46 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 type = aliasedTarget->GetType();
+ if(type != cmTarget::SHARED_LIBRARY
+ && type != cmTarget::STATIC_LIBRARY
+ && type != cmTarget::MODULE_LIBRARY
+ && type != 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)
-----------------------------------------------------------------------
Summary of changes:
Source/cmAddExecutableCommand.cxx | 14 ++++++++-
Source/cmAddExecutableCommand.h | 3 +-
Source/cmAddLibraryCommand.cxx | 16 +++++++++-
Source/cmGeneratorExpressionEvaluator.cxx | 12 ++++++++
Source/cmGetPropertyCommand.cxx | 12 ++++++++
Source/cmGetTargetPropertyCommand.cxx | 25 +++++++++++++----
Source/cmTarget.cxx | 6 ++++
Tests/AliasTarget/CMakeLists.txt | 29 +++++++++++++++++--
Tests/AliasTarget/bat.cpp | 12 ++++++++
Tests/AliasTarget/commandgenerator.cpp | 15 ++++++++++
Tests/AliasTarget/targetgenerator.cpp | 13 +++++++++
Tests/CTestTestDepends/CMakeLists.txt | 3 +-
Tests/GeneratorExpression/CMakeLists.txt | 8 +++++
Tests/GeneratorExpression/check-part3.cmake | 4 +++
Tests/GeneratorExpression/empty.cpp | 6 +++-
Tests/RunCMake/alias_targets/RunCMakeTest.cmake | 2 +
.../add_executable-library-result.txt} | 0
.../add_executable-library-stderr.txt | 5 +++
...lid-name.cmake => add_executable-library.cmake} | 2 +-
.../add_library-executable-result.txt} | 0
...tderr.txt => add_library-executable-stderr.txt} | 6 ++--
...d-target.cmake => add_library-executable.cmake} | 2 +-
.../alias_targets/define_property-result.txt | 0
.../alias_targets/define_property-stderr.txt | 0
.../{alias-target.cmake => define_property.cmake} | 2 +-
25 files changed, 174 insertions(+), 23 deletions(-)
create mode 100644 Tests/AliasTarget/commandgenerator.cpp
create mode 100644 Tests/AliasTarget/targetgenerator.cpp
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => alias_targets/add_executable-library-result.txt} (100%)
create mode 100644 Tests/RunCMake/alias_targets/add_executable-library-stderr.txt
copy Tests/RunCMake/alias_targets/{invalid-name.cmake => add_executable-library.cmake} (58%)
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => alias_targets/add_library-executable-result.txt} (100%)
copy Tests/RunCMake/alias_targets/{imported-target-stderr.txt => add_library-executable-stderr.txt} (60%)
copy Tests/RunCMake/alias_targets/{imported-target.cmake => add_library-executable.cmake} (61%)
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/alias_targets/define_property-result.txt (100%)
copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/alias_targets/define_property-stderr.txt (100%)
copy Tests/RunCMake/alias_targets/{alias-target.cmake => define_property.cmake} (65%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list