From f037b9b72644f150c136540b990774a3b32d39cf Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sat, 26 Oct 2013 23:38:38 +0200 Subject: Generators: don't append sources from utility targets to objectSources --- Source/cmGeneratorTarget.cxx | 9 ++++++++- Tests/CustomCommand/CMakeLists.txt | 7 +++++++ Tests/CustomCommand/source_in_custom_target.cpp | 0 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Tests/CustomCommand/source_in_custom_target.cpp diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 62ac263..511ae8a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -114,7 +114,10 @@ std::vector const& cmGeneratorTarget::GetSourceFiles() void cmGeneratorTarget::ClassifySources() { cmsys::RegularExpression header(CM_HEADER_REGEX); - bool isObjLib = this->Target->GetType() == cmTarget::OBJECT_LIBRARY; + + cmTarget::TargetType targetType = this->Target->GetType(); + bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; + std::vector badObjLib; std::vector const& sources = this->Target->GetSourceFiles(); for(std::vector::const_iterator si = sources.begin(); @@ -126,6 +129,10 @@ void cmGeneratorTarget::ClassifySources() { this->CustomCommands.push_back(sf); } + else if(targetType == cmTarget::UTILITY) + { + this->ExtraSources.push_back(sf); + } else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { this->HeaderSources.push_back(sf); diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 30daa7d..ff96add 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -449,3 +449,10 @@ set_property(SOURCE perconfig.out PROPERTY SYMBOLIC 1) add_custom_target(perconfig_target ALL COMMAND ${CMAKE_COMMAND} -E echo "perconfig=$" "config=$" DEPENDS perconfig.out) + +# Test SOURCES in add_custom_target() with COMPILE_DEFINITIONS +# which previously caused a crash in the makefile generators. +add_custom_target(source_in_custom_target SOURCES source_in_custom_target.cpp) +set_property(SOURCE source_in_custom_target + PROPERTY COMPILE_DEFINITIONS "TEST" +) diff --git a/Tests/CustomCommand/source_in_custom_target.cpp b/Tests/CustomCommand/source_in_custom_target.cpp new file mode 100644 index 0000000..e69de29 -- cgit v0.12