From cf3faacad2aff9ac3c9f2d407b1823a75939160e Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Fri, 11 Jan 2013 12:42:34 +0400 Subject: [PATCH 01/94] Automoc: Fix automoc for OBJECT libraries. Before this patch, add_library(obj OBJECT helper.cpp) add_executable(tgt $) didn't run automoc on helper.cpp. --- Source/cmGlobalGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d030aa7bae..b43170599d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1075,7 +1075,8 @@ void cmGlobalGenerator::CreateAutomocTargets() if(target.GetType() == cmTarget::EXECUTABLE || target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::OBJECT_LIBRARY) { if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) { From 0e35cac3d06bb89faa89ed4bf425f0978e828321 Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Fri, 11 Jan 2013 13:40:13 +0400 Subject: [PATCH 02/94] Automoc: add OBJECT library to QtAutomoc test --- Tests/QtAutomoc/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index 5e3686dbc7..855fcf0f5b 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -13,11 +13,14 @@ add_definitions(-DFOO -DSomeDefine="Barx") # enable relaxed mode so automoc can handle all the special cases: set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) -# create an executable and a library target, both requiring automoc: +# create an executable and two library targets, each requiring automoc: add_library(codeeditorLib STATIC codeeditor.cpp) -add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp private_slot.cpp) +add_library(privateSlot OBJECT private_slot.cpp) -set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) +add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp + xyz.cpp yaf.cpp $) + +set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} ) From c0f1af926feb3494ada1a311441ea144926157a2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Jan 2013 09:10:48 -0500 Subject: [PATCH 03/94] ExternalProject: Allow DEPENDS on normal targets (#13849) The ExternalProject_Add DEPENDS option adds two types of dependencies. It adds a target-level build order dependency between the external project target and the named targets. It also adds a file-level dependency on the "done" stamp file of the named external project targets. Targets not created by ExternalProject_Add have no such stamp file and no _EP_STAMP_DIR property. Prior to commit d14c0243 (Refactor repeated code into function, 2012-04-26) we unconditionally accepted an empty stamp dir and generated a dependency on a non-existent file. After that commit we generate an error that no stamp dir is set. Skip the file-level dependency when the named dependency is not an external project target in order to allow this use case. Teach the ExternalProject test to cover the case. --- Modules/ExternalProject.cmake | 7 +++++-- Tests/ExternalProject/CMakeLists.txt | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 2355dac478..ed7fd7c239 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1558,8 +1558,11 @@ function(_ep_add_configure_command name) set(file_deps) get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) foreach(dep IN LISTS deps) - _ep_get_step_stampfile(${dep} "done" done_stamp_file) - list(APPEND file_deps ${done_stamp_file}) + get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT) + if(is_ep) + _ep_get_step_stampfile(${dep} "done" done_stamp_file) + list(APPEND file_deps ${done_stamp_file}) + endif() endforeach() get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index e24a979c57..602ff0f65e 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -50,6 +50,8 @@ if(NOT DEFINED can_build_tutorial_step5) endif() endif() +add_custom_target(NonExternalProjectTarget + COMMAND ${CMAKE_COMMAND} -E echo NonExternalProjectTarget) # Empty projects that test all the known ExternalProject_Add argument key words: # @@ -94,7 +96,7 @@ ExternalProject_Add(${proj} CVS_REPOSITORY "" CVS_MODULE "" CVS_TAG "" - DEPENDS "MinimalNoOpProject" + DEPENDS "MinimalNoOpProject" NonExternalProjectTarget DOWNLOAD_COMMAND "" INSTALL_COMMAND "" PATCH_COMMAND "" From bc65b74fa64bdd736eb67b6e579aa1db347f7790 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Jan 2013 16:00:57 -0500 Subject: [PATCH 04/94] VS11: Fix VSExternalInclude test Set CMAKE_SUPPRESS_REGENERATION in the Lib1 and Lib2 projects so that their .vcxproj files do not contain references to ZERO_CHECK. Such references do not make sense when using the files in another .sln file. This does not reduce the effectiveness of the test because real projects that use include_external_msproject will have their own .vcxproj files not generated by CMake anyway. --- Tests/VSExternalInclude/Lib1/CMakeLists.txt | 1 + Tests/VSExternalInclude/Lib2/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/Tests/VSExternalInclude/Lib1/CMakeLists.txt b/Tests/VSExternalInclude/Lib1/CMakeLists.txt index 1cb01c5dd0..9dfac8616e 100644 --- a/Tests/VSExternalInclude/Lib1/CMakeLists.txt +++ b/Tests/VSExternalInclude/Lib1/CMakeLists.txt @@ -1,3 +1,4 @@ +set(CMAKE_SUPPRESS_REGENERATION 1) project(LIB1) set(SOURCES lib1.cpp) diff --git a/Tests/VSExternalInclude/Lib2/CMakeLists.txt b/Tests/VSExternalInclude/Lib2/CMakeLists.txt index f726c3f8bb..f4513548dd 100644 --- a/Tests/VSExternalInclude/Lib2/CMakeLists.txt +++ b/Tests/VSExternalInclude/Lib2/CMakeLists.txt @@ -1,3 +1,4 @@ +set(CMAKE_SUPPRESS_REGENERATION 1) project(VSEXTERNAL_LIB2) include_directories(${VSEXTERNAL_LIB2_SOURCE_DIR}/../Lib1) From 24dcf0c0072d6e0ca5a1203a54b574d1db9e5a7d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 22:16:46 +0100 Subject: [PATCH 05/94] Make sure generator expressions can be used with target_include_directories. Handle the case that a generator expression is used before treating a non-target as an error. --- Source/cmTargetPropCommandBase.cxx | 12 ++++++++++++ .../target_include_directories/CMakeLists.txt | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 69aaf17772..7f15dcb64b 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -65,6 +65,14 @@ bool cmTargetPropCommandBase return true; } +//---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + //---------------------------------------------------------------------------- bool cmTargetPropCommandBase ::ProcessContentArgs(std::vector const& args, @@ -105,6 +113,10 @@ bool cmTargetPropCommandBase content += sep + "$Property + ">"; } + else if(isGeneratorExpression(args[i])) + { + content += sep + args[i]; + } else if (!this->HandleNonTargetArg(content, sep, args[i], args[0])) { return false; diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a0f2ee08ce..8fa2eae758 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -33,7 +33,12 @@ target_include_directories(target_include_directories PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/poison" ) target_include_directories(target_include_directories - BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" + BEFORE PUBLIC "$<$:${CMAKE_CURRENT_BINARY_DIR}/cure>" +) + +# Has no effect because the target is not defined: +target_include_directories(target_include_directories + BEFORE PUBLIC "$<$:${CMAKE_CURRENT_BINARY_DIR}/poison>" ) add_library(importedlib UNKNOWN IMPORTED) From 1800f702a056b2eb25eb35daf9ed8d6474ecd0f9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 17:54:30 +0100 Subject: [PATCH 06/94] Populate the link information cache before checking dependent properties. The dependent properties check can require the link information. --- Source/cmTarget.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 815da408c4..45862fb930 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5422,14 +5422,14 @@ cmTarget::GetLinkInformation(const char* config, cmTarget *head) info = 0; } + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + if (info) { this->CheckPropertyCompatibility(info, config); } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; } return i->second; } From 6c8d8afe344aa2e0ba0c5c881d397a28a559dcbd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 16:42:39 +0100 Subject: [PATCH 07/94] Add the $ expression This new expression allows checking how a policy was set when a target was created. That information is only recorded for a subset of policies, so a whitelist is used. --- Source/cmDocumentGeneratorExpressions.h | 4 + Source/cmGeneratorExpressionEvaluator.cxx | 98 +++++++++++++++++++ Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt | 1 + Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt | 2 + Tests/RunCMake/CMP0004/CMP0004-NEW.cmake | 9 ++ Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt | 1 + Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt | 2 + Tests/RunCMake/CMP0004/CMP0004-OLD.cmake | 21 ++++ .../RunCMake/CMP0004/CMP0004-WARN-stderr.txt | 0 .../CMP0004/CMP0004-policy-genex-result.txt | 1 + .../CMP0004/CMP0004-policy-genex-stderr.txt | 2 + .../CMP0004/CMP0004-policy-genex.cmake | 14 +++ Tests/RunCMake/CMP0004/CMakeLists.txt | 3 + Tests/RunCMake/CMP0004/RunCMakeTest.cmake | 5 + Tests/RunCMake/CMP0004/empty.cpp | 0 Tests/RunCMake/CMakeLists.txt | 1 + 16 files changed, 164 insertions(+) create mode 100644 Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-NEW.cmake create mode 100644 Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-OLD.cmake create mode 100644 Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake create mode 100644 Tests/RunCMake/CMP0004/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0004/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CMP0004/empty.cpp diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index fa21907177..c2bf423ca6 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -50,6 +50,10 @@ " $ = The value of the property prop\n" \ "on the target tgt. Note that tgt is not added as a dependency of\n" \ "the target this expression is evaluated on.\n" \ + " $ = '1' if the policy was NEW when " \ + "the 'head' target was created, else '0'. If the policy was not " \ + "set, the warning message for the policy will be emitted. This " \ + "generator expression only works for a subset of policies.\n" \ "Boolean expressions:\n" \ " $ = '1' if all '?' are '1', else '0'\n" \ " $ = '0' if all '?' are '0', else '1'\n" \ diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 8e40815af7..2ddc058abf 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -487,6 +487,102 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode } targetNameNode; +//---------------------------------------------------------------------------- +static const char* targetPolicyWhitelist[] = { + "CMP0003" + , "CMP0004" + , "CMP0008" +}; + +cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) +{ +#define RETURN_POLICY(POLICY) \ + if (strcmp(policy, #POLICY) == 0) \ + { \ + return tgt->GetPolicyStatus ## POLICY (); \ + } \ + + RETURN_POLICY(CMP0003) + RETURN_POLICY(CMP0004) + RETURN_POLICY(CMP0008) + +#undef RETURN_POLICY + + assert("!Unreachable code. Not a valid policy"); + return cmPolicies::WARN; +} + +cmPolicies::PolicyID policyForString(const char *policy_id) +{ +#define RETURN_POLICY_ID(POLICY_ID) \ + if (strcmp(policy_id, #POLICY_ID) == 0) \ + { \ + return cmPolicies:: POLICY_ID; \ + } \ + + RETURN_POLICY_ID(CMP0003) + RETURN_POLICY_ID(CMP0004) + RETURN_POLICY_ID(CMP0008) + +#undef RETURN_POLICY_ID + + assert("!Unreachable code. Not a valid policy"); + return cmPolicies::CMP0002; +} + +//---------------------------------------------------------------------------- +static const struct TargetPolicyNode : public cmGeneratorExpressionNode +{ + TargetPolicyNode() {} + + virtual int NumExpectedParameters() const { return 1; } + + std::string Evaluate(const std::vector ¶meters, + cmGeneratorExpressionContext *context , + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *) const + { + if (!context->HeadTarget) + { + reportError(context, content->GetOriginalExpression(), + "$ may only be used with targets. It may not " + "be used with add_custom_command."); + return std::string(); + } + for (size_t i = 0; + i < (sizeof(targetPolicyWhitelist) / + sizeof(*targetPolicyWhitelist)); + ++i) + { + const char *policy = targetPolicyWhitelist[i]; + if (parameters.front() == policy) + { + cmMakefile *mf = context->HeadTarget->GetMakefile(); + switch(statusForTarget(context->HeadTarget, policy)) + { + case cmPolicies::WARN: + mf->IssueMessage(cmake::AUTHOR_WARNING, + mf->GetPolicies()-> + GetPolicyWarning(policyForString(policy))); + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::OLD: + return "0"; + case cmPolicies::NEW: + return "1"; + } + } + } + reportError(context, content->GetOriginalExpression(), + "$ may only be used with a limited number of " + "policies. Currently it may be used with policies CMP0003, CMP0004 " + "and CMP0008." + ); + return std::string(); + } + +} targetPolicyNode; + //---------------------------------------------------------------------------- template struct TargetFilesystemArtifactResultCreator @@ -714,6 +810,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &targetPropertyNode; else if (identifier == "TARGET_NAME") return &targetNameNode; + else if (identifier == "TARGET_POLICY") + return &targetPolicyNode; else if (identifier == "BUILD_INTERFACE") return &buildInterfaceNode; else if (identifier == "INSTALL_INTERFACE") diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt b/Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt new file mode 100644 index 0000000000..a21cb6ae3a --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt @@ -0,0 +1,2 @@ + Target "foo" links to item " bar " which has leading or trailing + whitespace. This is now an error according to policy CMP0004. diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake b/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake new file mode 100644 index 0000000000..7c61961f52 --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake @@ -0,0 +1,9 @@ + +cmake_minimum_required(VERSION 2.8) + +cmake_policy(SET CMP0004 NEW) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) + +target_link_libraries(foo "$<1: bar >") diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt b/Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt new file mode 100644 index 0000000000..782e45c577 --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt @@ -0,0 +1,2 @@ + Target "bat" links to item " bar " which has leading or trailing + whitespace. This is now an error according to policy CMP0004. diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake b/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake new file mode 100644 index 0000000000..d6ed72c79f --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake @@ -0,0 +1,21 @@ + +cmake_minimum_required(VERSION 2.8) + +cmake_policy(SET CMP0004 OLD) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +add_library(bing SHARED empty.cpp) +add_library(bung SHARED empty.cpp) + +cmake_policy(SET CMP0004 NEW) + +add_library(bat SHARED empty.cpp) + +target_link_libraries(foo "$<1: bar >") +target_link_libraries(bing "$<$>: bar >") +target_link_libraries(bung "$<$: bar >") + +# The line below causes the error because the policy is NEW when bat +# is created. +target_link_libraries(bat "$<1: bar >") diff --git a/Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt new file mode 100644 index 0000000000..eed53e7f46 --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt @@ -0,0 +1,2 @@ + Target "foo" links to item " bat " which has leading or trailing + whitespace. This is now an error according to policy CMP0004. diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake b/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake new file mode 100644 index 0000000000..eab680a92c --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 2.8) + +cmake_policy(SET CMP0004 NEW) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +add_library(bat SHARED empty.cpp) + +# The negation here avoids the error. +target_link_libraries(foo "$<$>: bar >") + +# The below line causes the error. +target_link_libraries(foo "$<$: bat >") diff --git a/Tests/RunCMake/CMP0004/CMakeLists.txt b/Tests/RunCMake/CMP0004/CMakeLists.txt new file mode 100644 index 0000000000..e8db6b05be --- /dev/null +++ b/Tests/RunCMake/CMP0004/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/CMP0004/RunCMakeTest.cmake b/Tests/RunCMake/CMP0004/RunCMakeTest.cmake new file mode 100644 index 0000000000..950d0edbd4 --- /dev/null +++ b/Tests/RunCMake/CMP0004/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0004-OLD) +run_cmake(CMP0004-NEW) +run_cmake(CMP0004-policy-genex) diff --git a/Tests/RunCMake/CMP0004/empty.cpp b/Tests/RunCMake/CMP0004/empty.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9b133b2994..8822200d5d 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -59,6 +59,7 @@ add_RunCMake_test(find_package) add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(list) +add_RunCMake_test(CMP0004) if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) From d9afacced34b2ef17a6c3ca2f66975272cf8473f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 18 Jan 2013 16:10:20 +0100 Subject: [PATCH 08/94] Exit early if we find an inconsistent property. Further messages about inconsistency are distracting. --- Source/cmTarget.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 45862fb930..7a2ead34c5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4533,6 +4533,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, "INTERFACE_" << p << " property requirement\nof " "dependency \"" << li->Target->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); + break; } else { @@ -4559,6 +4560,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, "INTERFACE_" << p << " property on\ndependency \"" << li->Target->GetName() << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); + break; } else { @@ -4586,6 +4588,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, "of " << p << " already determined\nfor \"" << this->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); + break; } else { From 5e572619c67c5ba38a68179111f7dea9648690ab Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 19 Jan 2013 00:01:19 -0500 Subject: [PATCH 09/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 73e99dff2f..487d456acd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130118) +set(CMake_VERSION_TWEAK 20130119) #set(CMake_VERSION_RC 1) From 35fbe4e4bc0f75d7034b60e28bac85e85e6569ed Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 20 Jan 2013 00:01:25 -0500 Subject: [PATCH 10/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 487d456acd..3d9ab41c57 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130119) +set(CMake_VERSION_TWEAK 20130120) #set(CMake_VERSION_RC 1) From d7f15209385e17580d911bcc10f78c921bd8c3fd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 11:25:35 +0100 Subject: [PATCH 11/94] Don't wrap all targets in LINK_LIBRARIES in a TARGET_NAME genex. It is not necessary and the current state is unintentional. Before this patch, target_link_libraries(foo bar) causes the LINK_LIBRARIES property of foo to contain $ instead of just bar --- Source/cmTarget.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 815da408c4..077eeecbe8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2269,8 +2269,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, cmTarget *tgt = this->Makefile->FindTargetToUse(lib); const bool isNonImportedTarget = tgt && !tgt->IsImported(); - std::string libName = isNonImportedTarget ? targetNameGenex(lib) - : std::string(lib); + const std::string libName = (isNonImportedTarget && llt != GENERAL) + ? targetNameGenex(lib) + : std::string(lib); this->AppendProperty("LINK_LIBRARIES", this->GetDebugGeneratorExpressions(libName, llt).c_str()); From e98799105bdb296e8d9f5b3ef5cf99bcebcafc40 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 19 Jan 2013 11:21:14 +0100 Subject: [PATCH 12/94] Make INTERFACE determined properties readable in generator expressions. The properties are evaluated as link-dependent interface properties when evaluating the generator expressions. --- Source/cmGeneratorExpressionDAGChecker.cxx | 13 +++++ Source/cmGeneratorExpressionDAGChecker.h | 3 ++ Source/cmGeneratorExpressionEvaluator.cxx | 21 +++++++++ Source/cmTarget.cxx | 47 +++++++++++++++++++ Source/cmTarget.h | 2 + Tests/CMakeLists.txt | 1 + Tests/CompatibleInterface/CMakeLists.txt | 28 +++++++++++ Tests/CompatibleInterface/empty.cpp | 1 + Tests/CompatibleInterface/main.cpp | 17 +++++++ Tests/ExportImport/Import/A/CMakeLists.txt | 7 ++- .../Import/A/deps_shared_iface.cpp | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + .../CompatibleInterface/CMakeLists.txt | 3 ++ .../InterfaceBool-builtin-prop-result.txt | 1 + .../InterfaceBool-builtin-prop-stderr.txt | 5 ++ .../InterfaceBool-builtin-prop.cmake | 11 +++++ ...erfaceBool-mismatch-depend-self-result.txt | 1 + ...erfaceBool-mismatch-depend-self-stderr.txt | 3 ++ .../InterfaceBool-mismatch-depend-self.cmake | 11 +++++ .../InterfaceBool-mismatch-depends-result.txt | 1 + .../InterfaceBool-mismatch-depends-stderr.txt | 3 ++ .../InterfaceBool-mismatch-depends.cmake | 10 ++++ .../InterfaceBool-mismatched-use-result.txt | 1 + .../InterfaceBool-mismatched-use-stderr.txt | 4 ++ .../InterfaceBool-mismatched-use.cmake | 9 ++++ .../CompatibleInterface/RunCMakeTest.cmake | 6 +++ Tests/RunCMake/CompatibleInterface/main.cpp | 5 ++ 27 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 Tests/CompatibleInterface/CMakeLists.txt create mode 100644 Tests/CompatibleInterface/empty.cpp create mode 100644 Tests/CompatibleInterface/main.cpp create mode 100644 Tests/RunCMake/CompatibleInterface/CMakeLists.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/main.cpp diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 2e5b5ae11f..057f4c3d55 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -106,3 +106,16 @@ cmGeneratorExpressionDAGChecker::checkGraph() const } return DAG; } + +//---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries() +{ + const cmGeneratorExpressionDAGChecker *top = this; + const cmGeneratorExpressionDAGChecker *parent = this->Parent; + while (parent) + { + parent = parent->Parent; + top = parent; + } + return top->Property == "LINK_LIBRARIES"; +} diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 48f26ed38f..31692910da 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -35,6 +35,9 @@ struct cmGeneratorExpressionDAGChecker void reportError(cmGeneratorExpressionContext *context, const std::string &expr); + + bool EvaluatingLinkLibraries(); + private: Result checkGraph() const; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 8e40815af7..e84288016e 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -442,6 +442,27 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode const char *prop = target->GetProperty(propertyName.c_str()); if (!prop) { + if (target->IsImported()) + { + return std::string(); + } + if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) + { + return std::string(); + } + if (propertyName == "POSITION_INDEPENDENT_CODE") + { + return target->GetLinkInterfaceDependentBoolProperty( + "POSITION_INDEPENDENT_CODE", context->Config) ? "1" : "0"; + } + if (target->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) + { + return target->GetLinkInterfaceDependentBoolProperty( + propertyName, + context->Config) ? "1" : "0"; + } + return std::string(); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7a2ead34c5..c1c484b1e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4612,6 +4612,53 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, return propContent; } +//---------------------------------------------------------------------------- +bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, + const char *interfaceProperty, + const char *config) +{ + cmComputeLinkInformation *info = tgt->GetLinkInformation(config); + + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + const char *prop = li->Target->GetProperty(interfaceProperty); + if (!prop) + { + continue; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + if (*pi == p) + { + return true; + } + } + } + + return false; +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, + const char *config) +{ + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_BOOL", + config); +} + //---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 69a00c14c1..b3e17b2426 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -495,6 +495,8 @@ public: void GetLinkDependentTargetsForProperty(const std::string &p, std::set &targets); bool IsNullImpliedByLinkLibraries(const std::string &p); + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const char *config); void AddLinkDependentTargetsForProperties( const std::map &map); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2f7df01cf5..0c75892384 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -216,6 +216,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(PolicyScope PolicyScope) ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) ADD_TEST_MACRO(CompileDefinitions CompileDefinitions) + ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) 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/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt new file mode 100644 index 0000000000..d0eb60f258 --- /dev/null +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -0,0 +1,28 @@ + +cmake_minimum_required(VERSION 2.8) + +project(CompatibleInterface) + +add_library(iface1 empty.cpp) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL + BOOL_PROP1 + BOOL_PROP2 + BOOL_PROP3 +) + +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) + +add_executable(CompatibleInterface main.cpp) +target_link_libraries(CompatibleInterface iface1) + +set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) +set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) + +target_compile_definitions(CompatibleInterface + PRIVATE + $<$>:BOOL_PROP1> + $<$>:BOOL_PROP2> + $<$>:BOOL_PROP3> +) diff --git a/Tests/CompatibleInterface/empty.cpp b/Tests/CompatibleInterface/empty.cpp new file mode 100644 index 0000000000..00323299cb --- /dev/null +++ b/Tests/CompatibleInterface/empty.cpp @@ -0,0 +1 @@ +// no content diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp new file mode 100644 index 0000000000..b7c66386c4 --- /dev/null +++ b/Tests/CompatibleInterface/main.cpp @@ -0,0 +1,17 @@ + +#ifndef BOOL_PROP1 +#error Expected BOOL_PROP1 +#endif + +#ifndef BOOL_PROP2 +#error Expected BOOL_PROP2 +#endif + +#ifndef BOOL_PROP3 +#error Expected BOOL_PROP3 +#endif + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 4812e7e1f1..83331cfcb3 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -165,7 +165,11 @@ target_compile_definitions(deps_iface PRIVATE testLibDepends) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends) -target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends) +target_compile_definitions(deps_shared_iface + PRIVATE + testSharedLibDepends + $<$>:PIC_PROPERTY_IS_ON> +) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") include(CheckCXXCompilerFlag) @@ -194,4 +198,5 @@ target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends bld_subdirlib) target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB + $<$>:PIC_PROPERTY_IS_ON> ) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 43f832a1e1..8ed032e153 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -8,6 +8,10 @@ #endif #endif +#ifndef PIC_PROPERTY_IS_ON +#error Expected PIC_PROPERTY_IS_ON +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9b133b2994..fc1960fbd0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -53,6 +53,7 @@ add_RunCMake_test(ObjectLibrary) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) endif() +add_RunCMake_test(CompatibleInterface) add_RunCMake_test(build_command) add_RunCMake_test(find_package) diff --git a/Tests/RunCMake/CompatibleInterface/CMakeLists.txt b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt new file mode 100644 index 0000000000..68dd8d6a1c --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt new file mode 100644 index 0000000000..1a925b602d --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Target "foo" has property "INCLUDE_DIRECTORIES" listed in its + COMPATIBLE_INTERFACE_BOOL property. This is not allowed. Only + user-defined properties may appear listed in the COMPATIBLE_INTERFACE_BOOL + property. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake new file mode 100644 index 0000000000..5feb4d5cc2 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL INCLUDE_DIRECTORIES) +set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES ON) +set_property(TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES ON) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES OFF) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt new file mode 100644 index 0000000000..0476da97d2 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: Property SOMEPROP on target "user" does +not match the INTERFACE_SOMEPROP property requirement +of dependency "foo". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake new file mode 100644 index 0000000000..90543e8d3f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP ON) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP ON) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY SOMEPROP OFF) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt new file mode 100644 index 0000000000..d885c09d95 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: The INTERFACE_SOMEPROP property of "bar" does +not agree with the value of SOMEPROP already determined +for "user". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake new file mode 100644 index 0000000000..69be796327 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake @@ -0,0 +1,10 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP ON) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP OFF) + +add_executable(user main.cpp) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt new file mode 100644 index 0000000000..8556ee0b66 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: Property SOMEPROP on target "user" is +implied to be FALSE because it was used to determine the link libraries +already. The INTERFACE_SOMEPROP property on +dependency "foo" is in conflict. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake new file mode 100644 index 0000000000..ccfad0ac74 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP ON) + +add_executable(user main.cpp) +target_link_libraries(user foo $<$,prop>:bar>) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake new file mode 100644 index 0000000000..ba8917b865 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(InterfaceBool-mismatch-depends) +run_cmake(InterfaceBool-mismatch-depend-self) +run_cmake(InterfaceBool-mismatched-use) +run_cmake(InterfaceBool-builtin-prop) diff --git a/Tests/RunCMake/CompatibleInterface/main.cpp b/Tests/RunCMake/CompatibleInterface/main.cpp new file mode 100644 index 0000000000..65eddcf847 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/main.cpp @@ -0,0 +1,5 @@ + +int main(int argc, char **argv) +{ + return 0; +} From 02d4e53f48574820423ec5f0a99e96da2b9fe857 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 18:02:13 +0100 Subject: [PATCH 13/94] Generate new-style cmake code during export. Use empty end*() commands and lowercase commands. --- Source/cmExportFileGenerator.cxx | 122 ++++++++++++------------ Source/cmExportInstallFileGenerator.cxx | 22 ++--- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4a7c6f929f..88c4876732 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -81,16 +81,16 @@ bool cmExportFileGenerator::GenerateImportFile() // Protect that file against use with older CMake versions. os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n"; - os << "IF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n" - << " MESSAGE(FATAL_ERROR \"CMake >= 2.6.0 required\")\n" - << "ENDIF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"; + os << "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n" + << " message(FATAL_ERROR \"CMake >= 2.6.0 required\")\n" + << "endif()\n"; // Isolate the file policy level. // We use 2.6 here instead of the current version because newer // versions of CMake should be able to export files imported by 2.6 // until the import format changes. - os << "CMAKE_POLICY(PUSH)\n" - << "CMAKE_POLICY(VERSION 2.6)\n"; + os << "cmake_policy(PUSH)\n" + << "cmake_policy(VERSION 2.6)\n"; // Start with the import file header. this->GenerateImportHeaderCode(os); @@ -100,7 +100,7 @@ bool cmExportFileGenerator::GenerateImportFile() // End with the import file footer. this->GenerateImportFooterCode(os); - os << "CMAKE_POLICY(POP)\n"; + os << "cmake_policy(POP)\n"; return result; } @@ -186,7 +186,7 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, { std::string targetName = this->Namespace; targetName += target->GetName(); - os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n"; + os << "set_target_properties(" << targetName << " PROPERTIES\n"; for(ImportPropertyMap::const_iterator pi = properties.begin(); pi != properties.end(); ++pi) { @@ -536,7 +536,7 @@ void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os, void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os) { os << "# Commands beyond this point should not need to know the version.\n" - << "SET(CMAKE_IMPORT_FILE_VERSION)\n"; + << "set(CMAKE_IMPORT_FILE_VERSION)\n"; } //---------------------------------------------------------------------------- @@ -545,7 +545,7 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os) // Store an import file format version. This will let us change the // format later while still allowing old import files to work. os << "# Commands may need to know the format version.\n" - << "SET(CMAKE_IMPORT_FILE_VERSION 1)\n" + << "set(CMAKE_IMPORT_FILE_VERSION 1)\n" << "\n"; } @@ -553,31 +553,31 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os) void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, const std::string &expectedTargets) { - os << "SET(_targetsDefined)\n" - "SET(_targetsNotDefined)\n" - "SET(_expectedTargets)\n" - "FOREACH(_expectedTarget " << expectedTargets << ")\n" - " LIST(APPEND _expectedTargets ${_expectedTarget})\n" - " IF(NOT TARGET ${_expectedTarget})\n" - " LIST(APPEND _targetsNotDefined ${_expectedTarget})\n" - " ENDIF(NOT TARGET ${_expectedTarget})\n" - " IF(TARGET ${_expectedTarget})\n" - " LIST(APPEND _targetsDefined ${_expectedTarget})\n" - " ENDIF(TARGET ${_expectedTarget})\n" - "ENDFOREACH(_expectedTarget)\n" - "IF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" - " SET(CMAKE_IMPORT_FILE_VERSION)\n" - " CMAKE_POLICY(POP)\n" - " RETURN()\n" - "ENDIF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" - "IF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" - " MESSAGE(FATAL_ERROR \"Some (but not all) targets in this export " + os << "set(_targetsDefined)\n" + "set(_targetsNotDefined)\n" + "set(_expectedTargets)\n" + "foreach(_expectedTarget " << expectedTargets << ")\n" + " list(APPEND _expectedTargets ${_expectedTarget})\n" + " if(NOT TARGET ${_expectedTarget})\n" + " list(APPEND _targetsNotDefined ${_expectedTarget})\n" + " endif()\n" + " if(TARGET ${_expectedTarget})\n" + " list(APPEND _targetsDefined ${_expectedTarget})\n" + " endif()\n" + "endforeach()\n" + "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" + " set(CMAKE_IMPORT_FILE_VERSION)\n" + " cmake_policy(POP)\n" + " return()\n" + "endif()\n" + "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" + " message(FATAL_ERROR \"Some (but not all) targets in this export " "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n" "Targets not yet defined: ${_targetsNotDefined}\\n\")\n" - "ENDIF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" - "UNSET(_targetsDefined)\n" - "UNSET(_targetsNotDefined)\n" - "UNSET(_expectedTargets)\n" + "endif()\n" + "unset(_targetsDefined)\n" + "unset(_targetsNotDefined)\n" + "unset(_expectedTargets)\n" "\n\n"; } //---------------------------------------------------------------------------- @@ -594,16 +594,16 @@ cmExportFileGenerator switch(target->GetType()) { case cmTarget::EXECUTABLE: - os << "ADD_EXECUTABLE(" << targetName << " IMPORTED)\n"; + os << "add_executable(" << targetName << " IMPORTED)\n"; break; case cmTarget::STATIC_LIBRARY: - os << "ADD_LIBRARY(" << targetName << " STATIC IMPORTED)\n"; + os << "add_library(" << targetName << " STATIC IMPORTED)\n"; break; case cmTarget::SHARED_LIBRARY: - os << "ADD_LIBRARY(" << targetName << " SHARED IMPORTED)\n"; + os << "add_library(" << targetName << " SHARED IMPORTED)\n"; break; case cmTarget::MODULE_LIBRARY: - os << "ADD_LIBRARY(" << targetName << " MODULE IMPORTED)\n"; + os << "add_library(" << targetName << " MODULE IMPORTED)\n"; break; default: // should never happen break; @@ -612,27 +612,27 @@ cmExportFileGenerator // Mark the imported executable if it has exports. if(target->IsExecutableWithExports()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY ENABLE_EXPORTS 1)\n"; } // Mark the imported library if it is a framework. if(target->IsFrameworkOnApple()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY FRAMEWORK 1)\n"; } // Mark the imported executable if it is an application bundle. if(target->IsAppBundleOnApple()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY MACOSX_BUNDLE 1)\n"; } if (target->IsCFBundleOnApple()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY BUNDLE 1)\n"; } os << "\n"; @@ -652,7 +652,7 @@ cmExportFileGenerator // Set the import properties. os << "# Import target \"" << targetName << "\" for configuration \"" << config << "\"\n"; - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " APPEND PROPERTY IMPORTED_CONFIGURATIONS "; if(config && *config) { @@ -663,7 +663,7 @@ cmExportFileGenerator os << "NOCONFIG"; } os << ")\n"; - os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n"; + os << "set_target_properties(" << targetName << " PROPERTIES\n"; for(ImportPropertyMap::const_iterator pi = properties.begin(); pi != properties.end(); ++pi) { @@ -689,17 +689,17 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os, { if (emitted.insert(missingTargets[i]).second) { - os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n" - << " IF(CMAKE_FIND_PACKAGE_NAME)\n" - << " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" - << " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " + os << "if(NOT TARGET \"" << missingTargets[i] << "\" )\n" + << " if(CMAKE_FIND_PACKAGE_NAME)\n" + << " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" + << " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " << "\"Required imported target \\\"" << missingTargets[i] << "\\\" not found ! \")\n" - << " ELSE()\n" - << " MESSAGE(FATAL_ERROR \"Required imported target \\\"" + << " else()\n" + << " message(FATAL_ERROR \"Required imported target \\\"" << missingTargets[i] << "\\\" not found ! \")\n" - << " ENDIF()\n" - << "ENDIF()\n"; + << " endif()\n" + << "endif()\n"; } } os << "\n"; @@ -718,10 +718,10 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) // on SUSE with a mysql pkg-config file, which claimed everything is fine, // but the development package was not installed.). os << "# Loop over all imported files and verify that they actually exist\n" - "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n" - " FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" - " IF(NOT EXISTS \"${file}\" )\n" - " MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\"" + "foreach(target ${_IMPORT_CHECK_TARGETS} )\n" + " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" + " if(NOT EXISTS \"${file}\" )\n" + " message(FATAL_ERROR \"The imported target \\\"${target}\\\"" " references the file\n" " \\\"${file}\\\"\n" "but this file does not exist. Possible reasons include:\n" @@ -731,11 +731,11 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" "but not all the files it references.\n" "\")\n" - " ENDIF()\n" - " ENDFOREACH()\n" - " UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n" - "ENDFOREACH()\n" - "UNSET(_IMPORT_CHECK_TARGETS)\n" + " endif()\n" + " endforeach()\n" + " unset(_IMPORT_CHECK_FILES_FOR_${target})\n" + "endforeach()\n" + "unset(_IMPORT_CHECK_TARGETS)\n" "\n"; } @@ -751,8 +751,8 @@ cmExportFileGenerator std::string targetName = this->Namespace; targetName += target->GetName(); - os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" - "LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; + os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" + "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; for(std::set::const_iterator li = importedLocations.begin(); li != importedLocations.end(); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 965f63d097..c5ddfad777 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -57,7 +57,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) else { cmOStringStream e; - e << "INSTALL(EXPORT \"" + e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() << "\" ...) " << "includes target \"" << te->Target->GetName() << "\" more than once in the export set."; @@ -98,12 +98,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) // Now load per-configuration properties for them. os << "# Load information for each installed configuration.\n" - << "GET_FILENAME_COMPONENT(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n" - << "FILE(GLOB CONFIG_FILES \"${_DIR}/" + << "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n" + << "file(GLOB CONFIG_FILES \"${_DIR}/" << this->GetConfigImportFileGlob() << "\")\n" - << "FOREACH(f ${CONFIG_FILES})\n" - << " INCLUDE(${f})\n" - << "ENDFOREACH(f)\n" + << "foreach(f ${CONFIG_FILES})\n" + << " include(${f})\n" + << "endforeach()\n" << "\n"; this->GenerateImportedFileCheckLoop(os); @@ -193,12 +193,12 @@ cmExportInstallFileGenerator { std::string dest = installDest; os << "# Compute the installation prefix relative to this file.\n" - << "GET_FILENAME_COMPONENT(_IMPORT_PREFIX " + << "get_filename_component(_IMPORT_PREFIX " << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; while(!dest.empty()) { os << - "GET_FILENAME_COMPONENT(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; dest = cmSystemTools::GetFilenamePath(dest); } os << "\n"; @@ -257,7 +257,7 @@ cmExportInstallFileGenerator if(!this->ImportPrefix.empty()) { os << "# Cleanup temporary variables.\n" - << "SET(_IMPORT_PREFIX)\n" + << "set(_IMPORT_PREFIX)\n" << "\n"; } } @@ -427,7 +427,7 @@ cmExportInstallFileGenerator { const char* installDest = this->IEGen->GetDestination(); cmOStringStream e; - e << "INSTALL(EXPORT \"" + e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() << "\") given absolute " << "DESTINATION \"" << installDest << "\" but the export " @@ -445,7 +445,7 @@ cmExportInstallFileGenerator int occurrences) { cmOStringStream e; - e << "INSTALL(EXPORT \"" + e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() << "\" ...) " << "includes target \"" << depender->GetName() From 3ded614e31e9dcc4afa3ee9885dadf830a05dd21 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 21 Jan 2013 00:01:20 -0500 Subject: [PATCH 14/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3d9ab41c57..45fc936b1e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130120) +set(CMake_VERSION_TWEAK 20130121) #set(CMake_VERSION_RC 1) From bd82bb4787410a0bdd6120b8c449f5d31ecc4c28 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 17:18:23 +0100 Subject: [PATCH 15/94] Clear the link information in ClearLinkMaps. The cache here needs to be cleared if GetLinkInformation is called at configure-time, such as during an export(). The next commit does exactly that, and without this patch, the LinkLanguage test would fail. --- Source/cmTarget.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c1c484b1e4..2600db5c4b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1520,6 +1520,13 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkClosureMap.clear(); + for (cmTargetLinkInformationMap::const_iterator it + = this->LinkInformation.begin(); + it != this->LinkInformation.end(); ++it) + { + delete it->second; + } + this->LinkInformation.clear(); } //---------------------------------------------------------------------------- From 830246e841d24cc9513c857859a4327ffb1d3da5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 17:09:29 +0100 Subject: [PATCH 16/94] Export the COMPATIBLE_INTERFACE_BOOL content properties --- Source/cmExportBuildFileGenerator.cxx | 1 + Source/cmExportFileGenerator.cxx | 74 +++++++++++++++++++ Source/cmExportFileGenerator.h | 2 + Source/cmExportInstallFileGenerator.cxx | 1 + Tests/ExportImport/Export/CMakeLists.txt | 9 +++ Tests/ExportImport/Import/A/CMakeLists.txt | 2 + .../Import/A/deps_shared_iface.cpp | 4 + 7 files changed, 93 insertions(+) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 61e130d521..7147f86be8 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -74,6 +74,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); + this->PopulateCompatibleInterfaceProperties(te, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4a7c6f929f..3a6294ad90 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -21,6 +21,7 @@ #include "cmTarget.h" #include "cmTargetExport.h" #include "cmVersion.h" +#include "cmComputeLinkInformation.h" #include @@ -177,6 +178,79 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, properties, missingTargets); } + +//---------------------------------------------------------------------------- +void getPropertyContents(cmTarget *tgt, const char *prop, + std::set &ifaceProperties) +{ + const char *p = tgt->GetProperty(prop); + if (!p) + { + return; + } + std::vector content; + cmSystemTools::ExpandListArgument(p, content); + for (std::vector::const_iterator ci = content.begin(); + ci != content.end(); ++ci) + { + ifaceProperties.insert(*ci); + } +} + +//---------------------------------------------------------------------------- +void getCompatibleInterfaceProperties(cmTarget *target, + std::set &ifaceProperties, + const char *config) +{ + cmComputeLinkInformation *info = target->GetLinkInformation(config); + + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_BOOL", + ifaceProperties); + } +} + +//---------------------------------------------------------------------------- +void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( + cmTarget *target, + ImportPropertyMap &properties) +{ + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", + target, properties); + + std::set ifaceProperties; + + getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + + getCompatibleInterfaceProperties(target, ifaceProperties, 0); + + std::vector configNames; + target->GetMakefile()->GetConfigurations(configNames); + + for (std::vector::const_iterator ci = configNames.begin(); + ci != configNames.end(); ++ci) + { + getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + } + + for (std::set::const_iterator it = ifaceProperties.begin(); + it != ifaceProperties.end(); ++it) + { + this->PopulateInterfaceProperty(("INTERFACE_" + *it).c_str(), + target, properties); + } +} + //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, std::ostream& os, diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index eb3f3c34ca..b39df0f8b1 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -103,6 +103,8 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const char *propName, cmTarget *target, ImportPropertyMap &properties); + void PopulateCompatibleInterfaceProperties(cmTarget *target, + ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 965f63d097..526a6bea3f 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -91,6 +91,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); + this->PopulateCompatibleInterfaceProperties(te, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index dd615d1354..599229340d 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -173,6 +173,15 @@ set_property(TARGET testSharedLibRequired APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" ) +set_property(TARGET testSharedLibRequired + APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL CUSTOM_PROP +) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_CUSTOM_PROP ON +) + add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) set_property(TARGET testSharedLibDepends APPEND PROPERTY diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 83331cfcb3..4df57715b4 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -169,6 +169,7 @@ target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends $<$>:PIC_PROPERTY_IS_ON> + $<$>:CUSTOM_PROPERTY_IS_ON> ) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -199,4 +200,5 @@ target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends b target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB $<$>:PIC_PROPERTY_IS_ON> + $<$>:CUSTOM_PROPERTY_IS_ON> ) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 8ed032e153..a33f200ecd 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -12,6 +12,10 @@ #error Expected PIC_PROPERTY_IS_ON #endif +#ifndef CUSTOM_PROPERTY_IS_ON +#error Expected CUSTOM_PROPERTY_IS_ON +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif From 0d46e9a0297d78dabc9988604a15c0096c702855 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 12:28:59 +0100 Subject: [PATCH 17/94] Store includes from the same include_directories call together. Otherwise, we get a separate IncludeDirectoriesEntry for each include, and that causes unnecessary and confusing splitting in the output when debugging the INCLUDE_DIRECTORIES property. --- Source/cmFLTKWrapUICommand.cxx | 6 +- Source/cmIncludeDirectoryCommand.cxx | 96 ++++++++++++------- Source/cmIncludeDirectoryCommand.h | 3 +- Source/cmMakefile.cxx | 30 ++++-- Source/cmMakefile.h | 5 +- .../DebugIncludes-stderr.txt | 7 -- 6 files changed, 93 insertions(+), 54 deletions(-) diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index a4aa75a7db..b08c335ac8 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -37,9 +37,13 @@ bool cmFLTKWrapUICommand // get the list of GUI files from which .cxx and .h will be generated std::string outputDirectory = this->Makefile->GetCurrentOutputDirectory(); + { // Some of the generated files are *.h so the directory "GUI" // where they are created have to be added to the include path - this->Makefile->AddIncludeDirectory( outputDirectory.c_str() ); + std::vector outputDirectories; + outputDirectories.push_back(outputDirectory); + this->Makefile->AddIncludeDirectories( outputDirectories ); + } for(std::vector::iterator i = (newArgs.begin() + 1); i != newArgs.end(); i++) diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index ba81849898..671e09f258 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -36,6 +36,10 @@ bool cmIncludeDirectoryCommand ++i; } + std::vector beforeIncludes; + std::vector afterIncludes; + std::set systemIncludes; + for(; i != args.end(); ++i) { if(*i == "SYSTEM") @@ -49,9 +53,37 @@ bool cmIncludeDirectoryCommand return false; } - this->AddDirectory(i->c_str(),before,system); + std::vector includes; + GetIncludes(*i, includes); + + if (before) + { + beforeIncludes.insert(beforeIncludes.end(), + includes.begin(), + includes.end()); + } + else + { + afterIncludes.insert(afterIncludes.end(), + includes.begin(), + includes.end()); + } + if (system) + { + for (std::vector::const_iterator li = includes.begin(); + li != includes.end(); ++li) + { + systemIncludes.insert(*li); + } + } } + std::reverse(beforeIncludes.begin(), beforeIncludes.end()); + + this->Makefile->AddIncludeDirectories(afterIncludes); + this->Makefile->AddIncludeDirectories(beforeIncludes, before); + this->Makefile->AddSystemIncludeDirectories(systemIncludes); + return true; } @@ -72,57 +104,49 @@ static bool StartsWithGeneratorExpression(const std::string &input) // output from a program and passing it into a command the cleanup doesn't // always happen // -void cmIncludeDirectoryCommand::AddDirectory(const char *i, - bool before, - bool system) +void cmIncludeDirectoryCommand::GetIncludes(const std::string &arg, + std::vector &incs) { // break apart any line feed arguments - std::string ret = i; std::string::size_type pos = 0; - if((pos = ret.find('\n', pos)) != std::string::npos) + std::string::size_type lastPos = 0; + while((pos = arg.find('\n', lastPos)) != std::string::npos) { if (pos) { - this->AddDirectory(ret.substr(0,pos).c_str(), before, system); + std::string inc = arg.substr(lastPos,pos); + NormalizeInclude(inc); + incs.push_back(inc); } - if (ret.size()-pos-1) - { - this->AddDirectory(ret.substr(pos+1,ret.size()-pos-1).c_str(), - before, system); - } - return; + lastPos = pos + 1; + } + std::string inc = arg.substr(lastPos); + NormalizeInclude(inc); + incs.push_back(inc); +} + +void cmIncludeDirectoryCommand::NormalizeInclude(std::string &inc) +{ + std::string::size_type b = inc.find_first_not_of(" \r"); + std::string::size_type e = inc.find_last_not_of(" \r"); + if ((b!=inc.npos) && (e!=inc.npos)) + { + inc.assign(inc, b, 1+e-b); // copy the remaining substring } - // remove any leading or trailing spaces and \r - std::string::size_type b = ret.find_first_not_of(" \r"); - std::string::size_type e = ret.find_last_not_of(" \r"); - if ((b!=ret.npos) && (e!=ret.npos)) + if (!cmSystemTools::IsOff(inc.c_str())) { - ret.assign(ret, b, 1+e-b); // copy the remaining substring - } - else - { - return; // if we get here, we had only whitespace in the string - } + cmSystemTools::ConvertToUnixSlashes(inc); - if (!cmSystemTools::IsOff(ret.c_str())) - { - cmSystemTools::ConvertToUnixSlashes(ret); - if(!cmSystemTools::FileIsFullPath(ret.c_str())) + if(!cmSystemTools::FileIsFullPath(inc.c_str())) { - if(!StartsWithGeneratorExpression(ret)) + if(!StartsWithGeneratorExpression(inc)) { std::string tmp = this->Makefile->GetStartDirectory(); tmp += "/"; - tmp += ret; - ret = tmp; + tmp += inc; + inc = tmp; } } } - this->Makefile->AddIncludeDirectory(ret.c_str(), before); - if(system) - { - this->Makefile->AddSystemIncludeDirectory(ret.c_str()); - } } - diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index dd37b82d07..a32fc77594 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -84,7 +84,8 @@ public: protected: // used internally - void AddDirectory(const char *arg, bool before, bool system); + void GetIncludes(const std::string &arg, std::vector &incs); + void NormalizeInclude(std::string &inc); }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b432986a82..7e7766407d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1616,20 +1616,31 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, } //---------------------------------------------------------------------------- -void cmMakefile::AddIncludeDirectory(const char* inc, bool before) +void cmMakefile::AddIncludeDirectories(const std::vector &incs, + bool before) { - if (!inc) + if (incs.empty()) { return; } + std::string incString; + std::string sep; + + for(std::vector::const_iterator li = incs.begin(); + li != incs.end(); ++li) + { + incString += sep + *li; + sep = ";"; + } + std::vector::iterator position = - before ? this->IncludeDirectoriesEntries.begin() - : this->IncludeDirectoriesEntries.end(); + before ? this->IncludeDirectoriesEntries.begin() + : this->IncludeDirectoriesEntries.end(); cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); - IncludeDirectoriesEntry entry(inc, lfbt); + IncludeDirectoriesEntry entry(incString, lfbt); this->IncludeDirectoriesEntries.insert(position, entry); // Property on each target: @@ -1642,9 +1653,14 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before) } //---------------------------------------------------------------------------- -void cmMakefile::AddSystemIncludeDirectory(const char* dir) +void +cmMakefile::AddSystemIncludeDirectories(const std::set &incs) { - this->SystemIncludeDirectories.insert(dir); + for(std::set::const_iterator li = incs.begin(); + li != incs.end(); ++li) + { + this->SystemIncludeDirectories.insert(*li); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a85015fe67..bb161b16c0 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -287,7 +287,8 @@ public: /** * Add an include directory to the build. */ - void AddIncludeDirectory(const char*, bool before = false); + void AddIncludeDirectories(const std::vector &incs, + bool before = false); /** * Add a variable definition to the build. This variable @@ -545,7 +546,7 @@ public: /** * Mark include directories as system directories. */ - void AddSystemIncludeDirectory(const char* dir); + void AddSystemIncludeDirectories(const std::set &incs); bool IsSystemIncludeDirectory(const char* dir); /** Expand out any arguements in the vector that have ; separated diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index 948def117f..ab99784efa 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -2,13 +2,6 @@ CMake Warning at DebugIncludes.cmake:8 \(include_directories\): Used includes: \* .*/Tests/RunCMake/include_directories/one - -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Warning at DebugIncludes.cmake:8 \(include_directories\): - Used includes: - \* .*/Tests/RunCMake/include_directories/two Call Stack \(most recent call first\): From d70204a86aa3e454e73049efda3e1ccea8c60720 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 12:50:53 +0100 Subject: [PATCH 18/94] Only output includes once after the start of 'generate-time' when debugging. During configure-time, GetIncludeDirectories may be called too, for example if using the export() command. As the content can be different, it should be output each time then. --- Source/cmGlobalGenerator.cxx | 1 + Source/cmMakefile.cxx | 1 + Source/cmMakefile.h | 6 ++++++ Source/cmTarget.cxx | 9 ++++++++- Source/cmTarget.h | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d2baf535c5..f28bd6c399 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -980,6 +980,7 @@ void cmGlobalGenerator::Generate() // Generate project files for (i = 0; i < this->LocalGenerators.size(); ++i) { + this->LocalGenerators[i]->GetMakefile()->SetGeneratingBuildSystem(); this->SetCurrentLocalGenerator(this->LocalGenerators[i]); this->LocalGenerators[i]->Generate(); this->LocalGenerators[i]->GenerateInstallRules(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7e7766407d..4721e4c038 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -99,6 +99,7 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->AddDefaultDefinitions(); this->Initialize(); this->PreOrder = false; + this->GeneratingBuildSystem = false; } cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bb161b16c0..a2783f2964 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -870,6 +870,9 @@ public: return this->IncludeDirectoriesEntries; } + bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } + void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const char* name, cmTarget& target); @@ -1019,6 +1022,9 @@ private: // Enforce rules about CMakeLists.txt files. void EnforceDirectoryLevelRules(); + + bool GeneratingBuildSystem; + }; //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 815da408c4..fb99b4a3f3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -151,6 +151,7 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; + this->DebugIncludesDone = false; } //---------------------------------------------------------------------------- @@ -2739,11 +2740,17 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) cmSystemTools::ExpandListArgument(debugProp, debugProperties); } - bool debugIncludes = std::find(debugProperties.begin(), + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), debugProperties.end(), "INCLUDE_DIRECTORIES") != debugProperties.end(); + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugIncludesDone = true; + } + for (std::vector::const_iterator it = this->Internal->IncludeDirectoriesEntries.begin(), end = this->Internal->IncludeDirectoriesEntries.end(); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 69a00c14c1..47ec528d3d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -610,6 +610,7 @@ private: bool DLLPlatform; bool IsApple; bool IsImportedTarget; + bool DebugIncludesDone; mutable std::map > LinkDependentProperties; mutable std::set LinkImplicitNullProperties; From aa6674831c3ea3bf3cca7c9f667d2e5c75873a3d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 12:57:25 +0100 Subject: [PATCH 19/94] Specify the target whose includes are being listed. --- Source/cmTarget.cxx | 4 ++-- .../RunCMake/include_directories/DebugIncludes-stderr.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb99b4a3f3..6c9ed1bf47 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2785,8 +2785,8 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) if (!usedIncludes.empty()) { this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, - "Used includes:\n" + usedIncludes, - (*it)->ge->GetBacktrace()); + "Used includes for target " + this->Name + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); } } return includes; diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index ab99784efa..379174aa84 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -1,5 +1,5 @@ CMake Warning at DebugIncludes.cmake:8 \(include_directories\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/one \* .*/Tests/RunCMake/include_directories/two @@ -8,7 +8,7 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Warning at DebugIncludes.cmake:13 \(set_property\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/three @@ -16,7 +16,7 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Warning at DebugIncludes.cmake:18 \(include_directories\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/four @@ -24,7 +24,7 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Warning at DebugIncludes.cmake:25 \(set_property\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/five \* .*/Tests/RunCMake/include_directories/six From 6063fef226d35aad0629d7098f72afa650e7a149 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 13:07:31 +0100 Subject: [PATCH 20/94] Output include directories as LOG messages, not warnings. --- Source/cmake.cxx | 4 ++++ .../RunCMake/include_directories/DebugIncludes-stderr.txt | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2eecfbac2e..932c9961e2 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -4394,6 +4394,10 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, isError = true; msg << "CMake Internal Error (please report a bug)"; } + else if(t == cmake::LOG) + { + msg << "CMake Debug Log"; + } else { msg << "CMake Warning"; diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index 379174aa84..736fe6967f 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning at DebugIncludes.cmake:8 \(include_directories\): +CMake Debug Log at DebugIncludes.cmake:8 \(include_directories\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/one @@ -7,7 +7,7 @@ CMake Warning at DebugIncludes.cmake:8 \(include_directories\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Warning at DebugIncludes.cmake:13 \(set_property\): +CMake Debug Log at DebugIncludes.cmake:13 \(set_property\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/three @@ -15,7 +15,7 @@ CMake Warning at DebugIncludes.cmake:13 \(set_property\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Warning at DebugIncludes.cmake:18 \(include_directories\): +CMake Debug Log at DebugIncludes.cmake:18 \(include_directories\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/four @@ -23,7 +23,7 @@ CMake Warning at DebugIncludes.cmake:18 \(include_directories\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Warning at DebugIncludes.cmake:25 \(set_property\): +CMake Debug Log at DebugIncludes.cmake:25 \(set_property\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/five From 48a4cf21825c9ed5f53ac25d5f4577baaf92d1f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 21 Jan 2013 12:05:01 +0100 Subject: [PATCH 21/94] Revert "Allow target_link_libraries with IMPORTED targets." This reverts commit 9cfe4f1b769597bd9ba179eba46572a9df27f64c. It turns out that correctly adding the content to the IMPORTED_LINK_INTERFACE_LIBARIES_ of an upstream target from the buildsystem of a downstream project is not simple. If upstream had added the INTERFACE content, the config-specific properties would be determined by the DEBUG_CONFIGURATIONS of upstream. As downstream, we don't have any information about what the DEBUG_CONFIGURATIONS of upstream were, so we can't determine which configuration-specific properties to populate. The best we can do is add it to all of them or add it to the ones downstream considers to be DEBUG_CONFIGURATIONS, neither of which is a good solution. So, removing the porcelain API for that is the best approach. A human can still determine which properties to populate and use the set_property API to populate the desired properies. Another solution to this would be for upstream targets to publish what they consider DEBUG_CONFIGURATIONS, but that can be added in a future release. --- Source/cmTargetLinkLibrariesCommand.cxx | 14 -------------- .../target_link_libraries/CMakeLists.txt | 3 --- 2 files changed, 17 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 0705fb4d66..f42b0f6874 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -33,10 +33,6 @@ bool cmTargetLinkLibrariesCommand this->Target = this->Makefile->GetCMakeInstance() ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); - if(!this->Target) - { - this->Target = this->Makefile->FindTargetToUse(args[0].c_str()); - } if(!this->Target) { cmake::MessageType t = cmake::FATAL_ERROR; // fail by default @@ -261,16 +257,6 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, // Handle normal case first. if(this->CurrentProcessingState != ProcessingLinkInterface) { - if (this->Target->IsImported()) - { - cmOStringStream e; - e << "Imported targets may only be used with the " - "LINK_INTERFACE_LIBRARIES specifier to target_link_libraries."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - - this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); if (this->CurrentProcessingState != ProcessingPublicInterface) diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index 1551c5055c..1d0e342f3b 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -29,9 +29,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(depA SHARED depA.cpp) generate_export_header(depA) -add_library(importedlib UNKNOWN IMPORTED) -target_link_libraries(importedlib LINK_INTERFACE_LIBRARIES depA) - add_library(depB SHARED depB.cpp) generate_export_header(depB) From b98d14d40016efee420bee26b9795880fdf6a5f8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 21 Jan 2013 12:28:27 +0100 Subject: [PATCH 22/94] Disallow porcelain to populate includes and defines of IMPORTED targets. With similar reasoning to the parent commit, as downstreams, we can't determine what $ generator expressions would be appropriate. Upstream would have populated the INTERFACE_INCLUDE_DIRECTORIES with config-specific generator expressions, possibly appropriate for their DEBUG_CONFIGURATIONS. In theory, if we would add include directories for a DEBUG intent, we would have to match the upstream configurations for that. Rather than attempting to discover the appropriate configurations at this time, simplify the feature instead. The use of IMPORTED targets with these commands could still be added in the future if targets would export their DEBUG_CONFIGURATIONS somehow. --- Source/cmTargetCompileDefinitionsCommand.cxx | 8 +++----- Source/cmTargetCompileDefinitionsCommand.h | 5 ++--- Source/cmTargetIncludeDirectoriesCommand.cxx | 8 +++----- Source/cmTargetIncludeDirectoriesCommand.h | 5 ++--- Source/cmTargetPropCommandBase.cxx | 4 ++-- Source/cmTargetPropCommandBase.h | 3 +-- .../target_compile_definitions/CMakeLists.txt | 7 +------ .../target_compile_definitions/consumer.cpp | 4 ---- .../target_include_directories/CMakeLists.txt | 10 +--------- .../target_include_directories/consumer.cpp | 5 ----- 10 files changed, 15 insertions(+), 44 deletions(-) diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 492a1b7d02..683eff62a4 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -20,13 +20,11 @@ bool cmTargetCompileDefinitionsCommand } void cmTargetCompileDefinitionsCommand -::HandleImportedTargetInvalidScope(const std::string &scope, - const std::string &tgt) +::HandleImportedTarget(const std::string &tgt) { cmOStringStream e; - e << "Cannot specify " << scope << " compile definitions for imported " - "target \"" << tgt << "\". Compile definitions can only be " - "specified for an imported target in the INTERFACE mode."; + e << "Cannot specify compile definitions for imported target \"" + << tgt << "\"."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 4b066b7a01..d49b9e8ee6 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -59,7 +59,7 @@ public: "Specify compile definitions or targets to use when compiling a given " "target. " "The named must have been created by a command such as " - "add_executable or add_library. " + "add_executable or add_library and must not be an IMPORTED target. " "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " "the scope of the following arguments. PRIVATE and PUBLIC items will " "populate the COMPILE_DEFINITIONS property of . PUBLIC and " @@ -78,8 +78,7 @@ public: cmTypeMacro(cmTargetCompileDefinitionsCommand, cmCommand); private: - virtual void HandleImportedTargetInvalidScope(const std::string &scope, - const std::string &tgt); + virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); virtual bool HandleNonTargetArg(std::string &content, diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 18e2cba4e4..aeba4686a1 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -22,13 +22,11 @@ bool cmTargetIncludeDirectoriesCommand //---------------------------------------------------------------------------- void cmTargetIncludeDirectoriesCommand -::HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope) +::HandleImportedTarget(const std::string &tgt) { cmOStringStream e; - e << "Cannot specify " << scope << " include directories for imported " - "target \"" << tgt << "\". Include directories can only be " - "specified for an imported target in the INTERFACE mode."; + e << "Cannot specify include directories for imported target \"" + << tgt << "\"."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 90e039c4d1..5a5f859fd3 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -60,7 +60,7 @@ public: "Specify include directories or targets to use when compiling a given " "target. " "The named must have been created by a command such as " - "add_executable or add_library.\n" + "add_executable or add_library and must not be an IMPORTED target.\n" "If BEFORE is specified, the content will be prepended to the property " "instead of being appended.\n" "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " @@ -82,8 +82,7 @@ public: cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmCommand); private: - virtual void HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope); + virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); virtual bool HandleNonTargetArg(std::string &content, diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 69aaf17772..c79c16ff7b 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -80,9 +80,9 @@ bool cmTargetPropCommandBase return false; } - if(this->Target->IsImported() && scope != "INTERFACE") + if(this->Target->IsImported()) { - this->HandleImportedTargetInvalidScope(args[0], scope); + this->HandleImportedTarget(args[0]); return false; } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index e757f9da12..15a78c9a6d 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -32,8 +32,7 @@ public: const char *prop, ArgumentFlags flags = NO_FLAGS); private: - virtual void HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope) = 0; + virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; virtual bool HandleNonTargetArg(std::string &content, diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index a37c59708a..3eca7fc78a 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -12,11 +12,6 @@ target_compile_definitions(target_compile_definitions INTERFACE MY_INTERFACE_DEFINE ) -add_library(importedlib UNKNOWN IMPORTED) -target_compile_definitions(importedlib - INTERFACE MY_IMPORTEDINTERFACE_DEFINE -) - add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) @@ -24,5 +19,5 @@ add_executable(consumer target_compile_definitions(consumer PRIVATE target_compile_definitions importedlib $<$:SHOULD_NOT_BE_DEFINED> - $<$:SHOULD_BE_DEFINED> + $<$:SHOULD_BE_DEFINED> ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index 1ef657d5ae..f835b6cf5c 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -11,10 +11,6 @@ #error Expected MY_INTERFACE_DEFINE #endif -#ifndef MY_IMPORTEDINTERFACE_DEFINE -#error Expected MY_IMPORTEDINTERFACE_DEFINE -#endif - #ifdef SHOULD_NOT_BE_DEFINED #error Unexpected SHOULD_NOT_BE_DEFINED #endif diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a0f2ee08ce..486bca0af3 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -11,9 +11,6 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicinclude/publicinclude.h" "#define file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude/interfaceinclude.h" "#define INTERFACEINCLUDE_DEFINE\n") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude/importedinterfaceinclude.h" "#define IMPORTEDINTERFACEINCLUDE_DEFINE\n") - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/poison") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n") @@ -36,15 +33,10 @@ target_include_directories(target_include_directories BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" ) -add_library(importedlib UNKNOWN IMPORTED) -target_include_directories(importedlib - INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude" -) - add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) target_include_directories(consumer - PRIVATE target_include_directories importedlib + PRIVATE target_include_directories ) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 6fd61d5b77..5d88488b56 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -2,7 +2,6 @@ #include "common.h" #include "publicinclude.h" #include "interfaceinclude.h" -#include "importedinterfaceinclude.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -16,10 +15,6 @@ #error Expected INTERFACEINCLUDE_DEFINE #endif -#ifndef IMPORTEDINTERFACEINCLUDE_DEFINE -#error Expected IMPORTEDINTERFACEINCLUDE_DEFINE -#endif - #ifndef CURE_DEFINE #error Expected CURE_DEFINE #endif From 2db9b0b06638ee9386391369823c204ea691576e Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 22 Jan 2013 00:01:18 -0500 Subject: [PATCH 23/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 45fc936b1e..f56e89481b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130121) +set(CMake_VERSION_TWEAK 20130122) #set(CMake_VERSION_RC 1) From a40c4261e6e9eef4fae5266b14a3790ee76f4612 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 23 Jan 2013 00:01:06 -0500 Subject: [PATCH 24/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f56e89481b..623b7081e3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130122) +set(CMake_VERSION_TWEAK 20130123) #set(CMake_VERSION_RC 1) From 3853a6c3a7210c29f82fd27f9d2f6e99eb18e1ba Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Tue, 22 Jan 2013 06:44:08 +0400 Subject: [PATCH 25/94] spell: fix a few typos in comments --- Source/cmMakefile.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b432986a82..d1dc5a2876 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2243,7 +2243,7 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) { return true; } - // If we are doing an in-source build, than the test will always fail + // If we are doing an in-source build, then the test will always fail if ( cmSystemTools::SameFile(this->GetHomeDirectory(), this->GetHomeOutputDirectory()) ) { @@ -2254,8 +2254,8 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) return true; } - // Check if this is subdirectory of the source tree but not a - // subdirectory of a build tree + // Check if this is a subdirectory of the source tree but not a + // subdirectory of the build tree if ( cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) && !cmSystemTools::IsSubDirectory(fileName, From e3b5eb6b23e5d2b6034e1c13716abb73ab6b3397 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 20 Nov 2012 14:53:41 +0100 Subject: [PATCH 26/94] Automatically link to the qtmain library when linking to QtCore. When using QAxServer, ensure that the qtmain library is excluded by reporting an error at CMake time if it is not. --- Modules/FindQt4.cmake | 28 ++++++++++++++++++ Source/cmGeneratorExpressionEvaluator.cxx | 7 +++-- Source/cmPolicies.cxx | 21 +++++++++++++ Source/cmPolicies.h | 1 + Source/cmTarget.cxx | 3 ++ Source/cmTarget.h | 5 ++++ Tests/Qt4Targets/CMakeLists.txt | 27 ++++++++++++++--- Tests/Qt4Targets/activeqtexe.cpp | 36 +++++++++++++++++++++++ 8 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 Tests/Qt4Targets/activeqtexe.cpp diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 7baa11b7c1..35420b48b7 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -65,6 +65,12 @@ # is much more flexible, but requires that FindQt4.cmake is executed before # such an exported dependency file is processed. # +# Note that if using IMPORTED targets, the qtmain.lib static library is +# automatically linked on Windows. To disable that globally, set the +# QT4_NO_LINK_QTMAIN variable before finding Qt4. To disable that for a +# particular executable, set the QT4_NO_LINK_QTMAIN target property to +# True on the executable. +# # QT_INCLUDE_DIRS_NO_SYSTEM # If this variable is set to TRUE, the Qt include directories # in the QT_USE_FILE will NOT have the SYSTEM keyword set. @@ -1009,7 +1015,14 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) # platform dependent libraries if(Q_WS_WIN) _QT4_ADJUST_LIB_VARS(qtmain) + _QT4_ADJUST_LIB_VARS(QAxServer) + set_property(TARGET Qt4::QAxServer PROPERTY + INTERFACE_QT4_NO_LINK_QTMAIN ON + ) + set_property(TARGET Qt4::QAxServer APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN) + _QT4_ADJUST_LIB_VARS(QAxContainer) endif() @@ -1049,6 +1062,21 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) _qt4_add_target_private_depends(phonon DBus) endif() + if (WIN32 AND NOT QT4_NO_LINK_QTMAIN) + set(_isExe $,EXECUTABLE>) + set(_isWin32 $>) + set(_isNotExcluded $>>) + set(_isPolicyNEW $) + set_property(TARGET Qt4::QtCore APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES + $<$:Qt4::qtmain> + ) + unset(_isExe) + unset(_isWin32) + unset(_isNotExcluded) + unset(_isPolicyNEW) + endif() + ####################################### # # Check the executables of Qt diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 2ddc058abf..c79197765a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -492,6 +492,7 @@ static const char* targetPolicyWhitelist[] = { "CMP0003" , "CMP0004" , "CMP0008" + , "CMP0020" }; cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) @@ -505,6 +506,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) RETURN_POLICY(CMP0003) RETURN_POLICY(CMP0004) RETURN_POLICY(CMP0008) + RETURN_POLICY(CMP0020) #undef RETURN_POLICY @@ -523,6 +525,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id) RETURN_POLICY_ID(CMP0003) RETURN_POLICY_ID(CMP0004) RETURN_POLICY_ID(CMP0008) + RETURN_POLICY_ID(CMP0020) #undef RETURN_POLICY_ID @@ -575,8 +578,8 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode } reportError(context, content->GetOriginalExpression(), "$ may only be used with a limited number of " - "policies. Currently it may be used with policies CMP0003, CMP0004 " - "and CMP0008." + "policies. Currently it may be used with policies CMP0003, CMP0004, " + "CMP0008 and CMP0020." ); return std::string(); } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index eb7d6668e7..831e92e925 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -508,6 +508,27 @@ cmPolicies::cmPolicies() "for strict compatibility. " "The NEW behavior for this policy is to leave the values untouched.", 2,8,11,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0020, "CMP0020", + "Automatically link Qt executables to qtmain target on Windows.", + "CMake 2.8.10 and lower required users of Qt to always specify a link " + "dependency to the qtmain.lib static library manually on Windows. CMake " + "2.8.11 gained the ability to evaluate generator expressions while " + "determining the link dependencies from IMPORTED targets. This allows " + "CMake itself to automatically link executables which link to Qt to the " + "qtmain.lib library when using IMPORTED Qt targets. For applications " + "already linking to qtmain.lib, this should have little impact. For " + "applications which supply their own alternative WinMain implementation " + "and for applications which use the QAxServer library, this automatic " + "linking will need to be disabled as per the documentation." + "\n" + "The OLD behavior for this policy is not to link executables to " + "qtmain.lib automatically when they link to the QtCore IMPORTED" + "target. " + "The NEW behavior for this policy is to link executables to " + "qtmain.lib automatically when they link to QtCore IMPORTED target.", + 2,8,11,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index d7d945c429..c11af07140 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -69,6 +69,7 @@ public: /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C} /// instead. CMP0019, ///< No variable re-expansion in include and link info + CMP0020, ///< Automatically link Qt executables to qtmain target /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 45862fb930..d1bd4a6849 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -145,6 +145,7 @@ cmTarget::cmTarget() this->PolicyStatusCMP0003 = cmPolicies::WARN; this->PolicyStatusCMP0004 = cmPolicies::WARN; this->PolicyStatusCMP0008 = cmPolicies::WARN; + this->PolicyStatusCMP0020 = cmPolicies::WARN; this->LinkLibrariesAnalyzed = false; this->HaveInstallRule = false; this->DLLPlatform = false; @@ -1499,6 +1500,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->Makefile->GetPolicyStatus(cmPolicies::CMP0004); this->PolicyStatusCMP0008 = this->Makefile->GetPolicyStatus(cmPolicies::CMP0008); + this->PolicyStatusCMP0020 = + this->Makefile->GetPolicyStatus(cmPolicies::CMP0020); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 69a00c14c1..ea3b8231ac 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -102,6 +102,10 @@ public: cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const { return this->PolicyStatusCMP0008; } + /** Get the status of policy CMP0020 when the target was created. */ + cmPolicies::PolicyStatus GetPolicyStatusCMP0020() const + { return this->PolicyStatusCMP0020; } + /** * Get the list of the custom commands for this target */ @@ -656,6 +660,7 @@ private: cmPolicies::PolicyStatus PolicyStatusCMP0003; cmPolicies::PolicyStatus PolicyStatusCMP0004; cmPolicies::PolicyStatus PolicyStatusCMP0008; + cmPolicies::PolicyStatus PolicyStatusCMP0020; // Internal representation details. friend class cmTargetInternals; diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index 9bd7a64786..d3aba74f12 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -2,15 +2,16 @@ cmake_minimum_required(VERSION 2.8) project(Qt4Targets) +cmake_policy(SET CMP0020 NEW) + find_package(Qt4 REQUIRED) +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + add_executable(Qt4Targets WIN32 main.cpp) target_link_libraries(Qt4Targets Qt4::QtGui) -if (WIN32) - target_link_libraries(Qt4Targets Qt4::qtmain) -endif() - set_property(TARGET Qt4Targets APPEND PROPERTY INCLUDE_DIRECTORIES $ @@ -19,3 +20,21 @@ set_property(TARGET Qt4Targets APPEND PROPERTY COMPILE_DEFINITIONS $ ) + +if (WIN32) + if (TARGET Qt4::QAxServer) + add_executable(activeqtexe WIN32 activeqtexe.cpp) + set_property(TARGET activeqtexe PROPERTY QT4_NO_LINK_QTMAIN ON) + target_link_libraries(activeqtexe Qt4::QAxServer Qt4::QtGui) + set_property(TARGET activeqtexe APPEND PROPERTY + INCLUDE_DIRECTORIES + $ + $ + ) + set_property(TARGET activeqtexe APPEND PROPERTY + COMPILE_DEFINITIONS + $ + $ + ) + endif() +endif() diff --git a/Tests/Qt4Targets/activeqtexe.cpp b/Tests/Qt4Targets/activeqtexe.cpp new file mode 100644 index 0000000000..d4a9121732 --- /dev/null +++ b/Tests/Qt4Targets/activeqtexe.cpp @@ -0,0 +1,36 @@ + +#include + +#ifndef QT_QAXSERVER_LIB +#error Expected QT_QAXSERVER_LIB +#endif + +#include + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0) + : QObject(parent) + { + } +}; + +QAXFACTORY_DEFAULT(MyObject, + "{4dc3f340-a6f7-44e4-a79b-3e9217685fbd}", + "{9ee49617-7d5c-441a-b833-4b068d41d751}", + "{13eca64b-ee2a-4f3c-aa04-5d9d975779a7}", + "{ce947ee3-0403-4fdc-895a-4fe779344b46}", + "{8de435ce-8d2a-46ac-b3b3-cb800d0547c7}"); + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QAxFactory::isServer(); + + return app.exec(); +} + +#include "activeqtexe.moc" From 2cf9642e9ca70f005e3ea59ab219afe8d16b31fc Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 24 Jan 2013 00:01:18 -0500 Subject: [PATCH 27/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 623b7081e3..2c688b7715 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130123) +set(CMake_VERSION_TWEAK 20130124) #set(CMake_VERSION_RC 1) From 6fbe3ce4ef1178cc4f2f14f281cd48ef82a11e03 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 23 Jan 2013 22:17:14 +0100 Subject: [PATCH 28/94] Exclude the LINK_LIBRARIES related properties from INTERFACE evaluation. These interface-related link-libraries properties are used to determine the value of the other INTERFACE properties, so we were getting infinite recursion and segfaults otherwise. --- Source/cmGeneratorExpressionDAGChecker.cxx | 10 ++++++++-- Tests/CompatibleInterface/CMakeLists.txt | 16 ++++++++++++++++ Tests/CompatibleInterface/iface2.cpp | 7 +++++++ Tests/CompatibleInterface/iface2.h | 13 +++++++++++++ Tests/CompatibleInterface/main.cpp | 5 ++++- 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 Tests/CompatibleInterface/iface2.cpp create mode 100644 Tests/CompatibleInterface/iface2.h diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 057f4c3d55..269211b92b 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -114,8 +114,14 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries() const cmGeneratorExpressionDAGChecker *parent = this->Parent; while (parent) { - parent = parent->Parent; top = parent; + parent = parent->Parent; } - return top->Property == "LINK_LIBRARIES"; + + const char *prop = top->Property.c_str(); + return (strcmp(prop, "LINK_LIBRARIES") == 0 + || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 + || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 + || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 26) == 0 + || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 35) == 0); } diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index d0eb60f258..728065231a 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -3,12 +3,16 @@ cmake_minimum_required(VERSION 2.8) project(CompatibleInterface) +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + add_library(iface1 empty.cpp) set_property(TARGET iface1 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 + BOOL_PROP4 ) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) @@ -26,3 +30,15 @@ target_compile_definitions(CompatibleInterface $<$>:BOOL_PROP2> $<$>:BOOL_PROP3> ) + + +add_library(iface2 SHARED iface2.cpp) +generate_export_header(iface2) + +# For the LINK_LIBRARIES and related properties, we should not evaluate +# properties defined only in the interface - they should be implicitly zero +set_property(TARGET iface2 + APPEND PROPERTY + LINK_INTERFACE_LIBRARIES $<$>:nonexistant> +) +target_link_libraries(CompatibleInterface iface2) diff --git a/Tests/CompatibleInterface/iface2.cpp b/Tests/CompatibleInterface/iface2.cpp new file mode 100644 index 0000000000..a9b501508f --- /dev/null +++ b/Tests/CompatibleInterface/iface2.cpp @@ -0,0 +1,7 @@ + +#include "iface2.h" + +int Iface2::foo() +{ + return 0; +} diff --git a/Tests/CompatibleInterface/iface2.h b/Tests/CompatibleInterface/iface2.h new file mode 100644 index 0000000000..ef4ebeec21 --- /dev/null +++ b/Tests/CompatibleInterface/iface2.h @@ -0,0 +1,13 @@ + +#ifndef IFACE2_H +#define IFACE2_H + +#include "iface2_export.h" + +class IFACE2_EXPORT Iface2 +{ +public: + int foo(); +}; + +#endif diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index b7c66386c4..ae0e985c89 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -11,7 +11,10 @@ #error Expected BOOL_PROP3 #endif +#include "iface2.h" + int main(int argc, char **argv) { - return 0; + Iface2 if2; + return if2.foo(); } From ab26249db107146fc9ad624ac9dddc4052e798d6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 13:29:48 -0500 Subject: [PATCH 29/94] Add ExternalData module Take files we previously distributed in ITK 4.3.1: CMake/ExternalData.cmake CMake/ExternalData_config.cmake.in and add them for distribution in upstream CMake. Update the copyright notice block format to follow CMake conventions. --- Modules/ExternalData.cmake | 710 +++++++++++++++++++++++++++ Modules/ExternalData_config.cmake.in | 4 + 2 files changed, 714 insertions(+) create mode 100644 Modules/ExternalData.cmake create mode 100644 Modules/ExternalData_config.cmake.in diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake new file mode 100644 index 0000000000..84020f94de --- /dev/null +++ b/Modules/ExternalData.cmake @@ -0,0 +1,710 @@ +# - Manage data files stored outside source tree +# Use this module to unambiguously reference data files stored outside the +# source tree and fetch them at build time from arbitrary local and remote +# content-addressed locations. Functions provided by this module recognize +# arguments with the syntax "DATA{}" as references to external data, +# replace them with full paths to local copies of those data, and create build +# rules to fetch and update the local copies. +# +# The DATA{} syntax is literal and the is a full or relative path +# within the source tree. The source tree must contain either a real data +# file at or a "content link" at containing a hash of the +# real file using a hash algorithm corresponding to . For example, the +# argument "DATA{img.png}" may be satisfied by either a real "img.png" file in +# the current source directory or a "img.png.md5" file containing its MD5 sum. +# +# The 'ExternalData_Expand_Arguments' function evaluates DATA{} references +# in its arguments and constructs a new list of arguments: +# ExternalData_Expand_Arguments( +# # Name of data management target +# # Output variable +# [args...] # Input arguments, DATA{} allowed +# ) +# It replaces each DATA{} reference in an argument with the full path of a +# real data file on disk that will exist after the builds. +# +# The 'ExternalData_Add_Test' function wraps around the CMake add_test() +# command but supports DATA{} references in its arguments: +# ExternalData_Add_Test( +# # Name of data management target +# ... # Arguments of add_test(), DATA{} allowed +# ) +# It passes its arguments through ExternalData_Expand_Arguments and then +# invokes add_test() using the results. +# +# The 'ExternalData_Add_Target' function creates a custom target to manage +# local instances of data files stored externally: +# ExternalData_Add_Target( +# # Name of data management target +# ) +# It creates custom commands in the target as necessary to make data files +# available for each DATA{} reference previously evaluated by other functions +# provided by this module. A list of URL templates must be provided in the +# variable ExternalData_URL_TEMPLATES using the placeholders "%(algo)" and +# "%(hash)" in each template. Data fetch rules try each URL template in order +# by substituting the hash algorithm name for "%(algo)" and the hash value for +# "%(hash)". +# +# The following hash algorithms are supported: +# %(algo) Description +# ------- ----- ----------- +# MD5 .md5 Message-Digest Algorithm 5, RFC 1321 +# Note that the hashes are used only for unique data identification and +# download verification. This is not security software. +# +# Example usage: +# include(ExternalData) +# set(ExternalData_URL_TEMPLATES "file:///local/%(algo)/%(hash)" +# "http://data.org/%(algo)/%(hash)") +# ExternalData_Add_Test(MyData +# NAME MyTest +# COMMAND MyExe DATA{MyInput.png} +# ) +# ExternalData_Add_Target(MyData) +# When test "MyTest" runs the "DATA{MyInput.png}" argument will be replaced by +# the full path to a real instance of the data file "MyInput.png" on disk. If +# the source tree contains a content link such as "MyInput.png.md5" then the +# "MyData" target creates a real "MyInput.png" in the build tree. +# +# The DATA{} syntax can automatically recognize and fetch a file series. If +# the source tree contains a group of files or content links named like a +# series then a DATA{} reference to one member adds rules to fetch all of +# them. Although all members of a series are fetched, only the file +# originally named by the DATA{} argument is substituted for it. Two +# variables configure recognition of a series from DATA{}. First, +# ExternalData_SERIES_PARSE is a regex of the form "^(...)(...)(...)$" to +# parse , , and parts from . Second, +# ExternalData_SERIES_MATCH is a regex matching the part of series +# members named . Note that the of a series +# does not include a hash-algorithm extension. Both series configuration +# variables have default values that work well for common cases. +# +# The DATA{} syntax can alternatively match files associated with the named +# file and contained in the same directory. Associated files may be specified +# by options using the syntax DATA{,,,...}. Each option may +# specify one file by name or specify a regular expression to match file names +# using the syntax REGEX:. For example, the arguments +# DATA{MyData/MyInput.mhd,MyInput.img} # File pair +# DATA{MyData/MyFrames00.png,REGEX:MyFrames[0-9]+\\.png} # Series +# will pass MyInput.mha and MyFrames00.png on the command line but ensure +# that the associated files are present next to them. +# +# The variable ExternalData_LINK_CONTENT may be set to the name of a supported +# hash algorithm to enable automatic conversion of real data files referenced +# by the DATA{} syntax into content links. For each such a content +# link named "" is created. The original file is renamed to the +# form ".ExternalData__" to stage it for future transmission to +# one of the locations in the list of URL templates (by means outside the +# scope of this module). The data fetch rule created for the content link +# will use the staged object if it cannot be found using any URL template. +# +# The variable ExternalData_OBJECT_STORES may be set to a list of local +# directories that store objects using the layout /%(algo)/%(hash). +# These directories will be searched first for a needed object. If the object +# is not available in any store then it will be fetched remotely using the URL +# templates and added to the first local store listed. If no stores are +# specified the default is a location inside the build tree. +# +# The variable ExternalData_SOURCE_ROOT may be set to the highest source +# directory containing any path named by a DATA{} reference. The default is +# CMAKE_SOURCE_DIR. ExternalData_SOURCE_ROOT and CMAKE_SOURCE_DIR must refer +# to directories within a single source distribution (e.g. they come together +# in one tarball). +# +# The variable ExternalData_BINARY_ROOT may be set to the directory to hold +# the real data files named by expanded DATA{} references. The default is +# CMAKE_BINARY_DIR. The directory layout will mirror that of content links +# under ExternalData_SOURCE_ROOT. +# +# Variables ExternalData_TIMEOUT_INACTIVITY and ExternalData_TIMEOUT_ABSOLUTE +# set the download inactivity and absolute timeouts, in seconds. The defaults +# are 60 seconds and 300 seconds, respectively. Set either timeout to 0 +# seconds to disable enforcement. The inactivity timeout is enforced only +# with CMake >= 2.8.5. + +#============================================================================= +# Copyright 2010-2013 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(ExternalData_add_test target) + ExternalData_expand_arguments("${target}" testArgs ${ARGN}) + add_test(${testArgs}) +endfunction() + +function(ExternalData_add_target target) + if(NOT ExternalData_URL_TEMPLATES) + message(FATAL_ERROR "ExternalData_URL_TEMPLATES is not set!") + endif() + if(NOT ExternalData_OBJECT_STORES) + set(ExternalData_OBJECT_STORES ${CMAKE_BINARY_DIR}/ExternalData/Objects) + endif() + set(config ${CMAKE_CURRENT_BINARY_DIR}/${target}_config.cmake) + configure_file(${_ExternalData_SELF_DIR}/ExternalData_config.cmake.in ${config} @ONLY) + + set(files "") + + # Set "_ExternalData_FILE_${file}" for each output file to avoid duplicate + # rules. Use local data first to prefer real files over content links. + + # Custom commands to copy or link local data. + get_property(data_local GLOBAL PROPERTY _ExternalData_${target}_LOCAL) + foreach(entry IN LISTS data_local) + string(REPLACE "|" ";" tuple "${entry}") + list(GET tuple 0 file) + list(GET tuple 1 name) + if(NOT DEFINED "_ExternalData_FILE_${file}") + set("_ExternalData_FILE_${file}" 1) + add_custom_command( + COMMENT "Generating ${file}" + OUTPUT "${file}" + COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} + -Dfile=${file} -Dname=${name} + -DExternalData_ACTION=local + -DExternalData_CONFIG=${config} + -P ${_ExternalData_SELF} + DEPENDS "${name}" + ) + list(APPEND files "${file}") + endif() + endforeach() + + # Custom commands to fetch remote data. + get_property(data_fetch GLOBAL PROPERTY _ExternalData_${target}_FETCH) + foreach(entry IN LISTS data_fetch) + string(REPLACE "|" ";" tuple "${entry}") + list(GET tuple 0 file) + list(GET tuple 1 name) + list(GET tuple 2 ext) + set(stamp "${ext}-stamp") + if(NOT DEFINED "_ExternalData_FILE_${file}") + set("_ExternalData_FILE_${file}" 1) + add_custom_command( + # Users care about the data file, so hide the hash/timestamp file. + COMMENT "Generating ${file}" + # The hash/timestamp file is the output from the build perspective. + # List the real file as a second output in case it is a broken link. + # The files must be listed in this order so CMake can hide from the + # make tool that a symlink target may not be newer than the input. + OUTPUT "${file}${stamp}" "${file}" + # Run the data fetch/update script. + COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} + -Dfile=${file} -Dname=${name} -Dext=${ext} + -DExternalData_ACTION=fetch + -DExternalData_CONFIG=${config} + -P ${_ExternalData_SELF} + # Update whenever the object hash changes. + DEPENDS "${name}${ext}" + ) + list(APPEND files "${file}${stamp}") + endif() + endforeach() + + # Custom target to drive all update commands. + add_custom_target(${target} ALL DEPENDS ${files}) +endfunction() + +function(ExternalData_expand_arguments target outArgsVar) + # Replace DATA{} references with real arguments. + set(data_regex "DATA{([^{}\r\n]*)}") + set(other_regex "([^D]|D[^A]|DA[^T]|DAT[^A]|DATA[^{])+|.") + set(outArgs "") + foreach(arg IN LISTS ARGN) + if("x${arg}" MATCHES "${data_regex}") + # Split argument into DATA{}-pieces and other pieces. + string(REGEX MATCHALL "${data_regex}|${other_regex}" pieces "${arg}") + # Compose output argument with DATA{}-pieces replaced. + set(outArg "") + foreach(piece IN LISTS pieces) + if("x${piece}" MATCHES "^x${data_regex}$") + # Replace this DATA{}-piece with a file path. + string(REGEX REPLACE "${data_regex}" "\\1" data "${piece}") + _ExternalData_arg("${target}" "${piece}" "${data}" file) + set(outArg "${outArg}${file}") + else() + # No replacement needed for this piece. + set(outArg "${outArg}${piece}") + endif() + endforeach() + list(APPEND outArgs "${outArg}") + else() + # No replacements needed in this argument. + list(APPEND outArgs "${arg}") + endif() + endforeach() + set("${outArgsVar}" "${outArgs}" PARENT_SCOPE) +endfunction() + +#----------------------------------------------------------------------------- +# Private helper interface + +set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}") +get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH) + +function(_ExternalData_compute_hash var_hash algo file) + if("${algo}" STREQUAL "MD5") + # TODO: Errors + execute_process(COMMAND "${CMAKE_COMMAND}" -E md5sum "${file}" + OUTPUT_VARIABLE output) + string(SUBSTRING "${output}" 0 32 hash) + set("${var_hash}" "${hash}" PARENT_SCOPE) + else() + # TODO: Other hashes. + message(FATAL_ERROR "Hash algorithm ${algo} unimplemented.") + endif() +endfunction() + +function(_ExternalData_random var) + if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.5) + string(RANDOM LENGTH 6 random) + elseif(EXISTS /dev/urandom) + file(READ /dev/urandom random LIMIT 4 HEX) + else() + message(FATAL_ERROR "CMake >= 2.8.5 required in this environment") + endif() + set("${var}" "${random}" PARENT_SCOPE) +endfunction() + +function(_ExternalData_exact_regex regex_var string) + string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${string}") + set("${regex_var}" "${regex}" PARENT_SCOPE) +endfunction() + +function(_ExternalData_atomic_write file content) + _ExternalData_random(random) + set(tmp "${file}.tmp${random}") + file(WRITE "${tmp}" "${content}") + file(RENAME "${tmp}" "${file}") +endfunction() + +function(_ExternalData_link_content name var_ext) + if("${ExternalData_LINK_CONTENT}" MATCHES "^(MD5)$") + set(algo "${ExternalData_LINK_CONTENT}") + else() + message(FATAL_ERROR + "Unknown hash algorithm specified by ExternalData_LINK_CONTENT:\n" + " ${ExternalData_LINK_CONTENT}") + endif() + _ExternalData_compute_hash(hash "${algo}" "${name}") + get_filename_component(dir "${name}" PATH) + set(staged "${dir}/.ExternalData_${algo}_${hash}") + set(ext ".md5") + _ExternalData_atomic_write("${name}${ext}" "${hash}\n") + file(RENAME "${name}" "${staged}") + set("${var_ext}" "${ext}" PARENT_SCOPE) + + file(RELATIVE_PATH relname "${ExternalData_SOURCE_ROOT}" "${name}${ext}") + message(STATUS "Linked ${relname} to ExternalData ${algo}/${hash}") +endfunction() + +function(_ExternalData_arg target arg options var_file) + # Separate data path from the options. + string(REPLACE "," ";" options "${options}") + list(GET options 0 data) + list(REMOVE_AT options 0) + + # Convert to full path. + if(IS_ABSOLUTE "${data}") + set(absdata "${data}") + else() + # TODO: If ${data} does not start in "./" or "../" then use search path? + get_filename_component(absdata "${CMAKE_CURRENT_SOURCE_DIR}/${data}" ABSOLUTE) + endif() + + # Convert to relative path under the source tree. + if(NOT ExternalData_SOURCE_ROOT) + set(ExternalData_SOURCE_ROOT "${CMAKE_SOURCE_DIR}") + endif() + set(top_src "${ExternalData_SOURCE_ROOT}") + file(RELATIVE_PATH reldata "${top_src}" "${absdata}") + if(IS_ABSOLUTE "${reldata}" OR "${reldata}" MATCHES "^\\.\\./") + message(FATAL_ERROR "Data file referenced by argument\n" + " ${arg}\n" + "does not lie under the top-level source directory\n" + " ${top_src}\n") + endif() + if(NOT ExternalData_BINARY_ROOT) + set(ExternalData_BINARY_ROOT "${CMAKE_BINARY_DIR}") + endif() + set(top_bin "${ExternalData_BINARY_ROOT}") + + # Handle in-source builds gracefully. + if("${top_src}" STREQUAL "${top_bin}") + if(ExternalData_LINK_CONTENT) + message(WARNING "ExternalData_LINK_CONTENT cannot be used in-source") + set(ExternalData_LINK_CONTENT 0) + endif() + set(top_same 1) + endif() + + set(external "") # Entries external to the source tree. + set(internal "") # Entries internal to the source tree. + set(have_original 0) + + # Process options. + set(associated_files "") + set(associated_regex "") + foreach(opt ${options}) + if("x${opt}" MATCHES "^xREGEX:[^:/]+$") + # Regular expression to match associated files. + string(REGEX REPLACE "^REGEX:" "" regex "${opt}") + list(APPEND associated_regex "${regex}") + elseif("x${opt}" MATCHES "^[^][:/*?]+$") + # Specific associated file. + list(APPEND associated_files "${opt}") + else() + message(FATAL_ERROR "Unknown option \"${opt}\" in argument\n" + " ${arg}\n") + endif() + endforeach() + + if(associated_files OR associated_regex) + # Load the named data file and listed/matching associated files. + _ExternalData_arg_single() + _ExternalData_arg_associated() + elseif("${reldata}" MATCHES "(^|/)[^/.]+$") + # Files with no extension cannot be a series. + _ExternalData_arg_single() + else() + # Match a whole file series by default. + _ExternalData_arg_series() + endif() + + if(NOT have_original) + message(FATAL_ERROR "Data file referenced by argument\n" + " ${arg}\n" + "corresponds to source tree path\n" + " ${reldata}\n" + "that does not exist (with or without an extension)!") + endif() + + if(external) + # Make the series available in the build tree. + set_property(GLOBAL APPEND PROPERTY + _ExternalData_${target}_FETCH "${external}") + set_property(GLOBAL APPEND PROPERTY + _ExternalData_${target}_LOCAL "${internal}") + set("${var_file}" "${top_bin}/${reldata}" PARENT_SCOPE) + else() + # The whole series is in the source tree. + set("${var_file}" "${top_src}/${reldata}" PARENT_SCOPE) + endif() +endfunction() + +macro(_ExternalData_arg_associated) + # Associated files lie in the same directory. + get_filename_component(reldir "${reldata}" PATH) + if(reldir) + set(reldir "${reldir}/") + endif() + _ExternalData_exact_regex(reldir_regex "${reldir}") + + # Find files named explicitly. + foreach(file ${associated_files}) + _ExternalData_exact_regex(file_regex "${file}") + _ExternalData_arg_find_files("${reldir}${file}" "${reldir_regex}${file_regex}") + endforeach() + + # Find files matching the given regular expressions. + set(all "") + set(sep "") + foreach(regex ${associated_regex}) + set(all "${all}${sep}${reldir_regex}${regex}") + set(sep "|") + endforeach() + _ExternalData_arg_find_files("${reldir}" "${all}") +endmacro() + +macro(_ExternalData_arg_single) + # Match only the named data by itself. + _ExternalData_exact_regex(data_regex "${reldata}") + _ExternalData_arg_find_files("${reldata}" "${data_regex}") +endmacro() + +macro(_ExternalData_arg_series) + # Configure series parsing and matching. + if(ExternalData_SERIES_PARSE) + if(NOT "${ExternalData_SERIES_PARSE}" MATCHES + "^\\^\\([^()]*\\)\\([^()]*\\)\\([^()]*\\)\\$$") + message(FATAL_ERROR + "ExternalData_SERIES_PARSE is set to\n" + " ${ExternalData_SERIES_PARSE}\n" + "which is not of the form\n" + " ^(...)(...)(...)$\n") + endif() + set(series_parse "${ExternalData_SERIES_PARSE}") + else() + set(series_parse "^(.*)()(\\.[^./]*)$") + endif() + if(ExternalData_SERIES_MATCH) + set(series_match "${ExternalData_SERIES_MATCH}") + else() + set(series_match "[_.]?[0-9]*") + endif() + + # Parse the base, number, and extension components of the series. + string(REGEX REPLACE "${series_parse}" "\\1;\\2;\\3" tuple "${reldata}") + list(LENGTH tuple len) + if(NOT "${len}" EQUAL 3) + message(FATAL_ERROR "Data file referenced by argument\n" + " ${arg}\n" + "corresponds to path\n" + " ${reldata}\n" + "that does not match regular expression\n" + " ${series_parse}") + endif() + list(GET tuple 0 relbase) + list(GET tuple 2 ext) + + # Glob files that might match the series. + # Then match match base, number, and extension. + _ExternalData_exact_regex(series_base "${relbase}") + _ExternalData_exact_regex(series_ext "${ext}") + _ExternalData_arg_find_files("${relbase}*${ext}" + "${series_base}${series_match}${series_ext}") +endmacro() + +function(_ExternalData_arg_find_files pattern regex) + file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*") + foreach(entry IN LISTS globbed) + string(REGEX REPLACE "^(${regex})(\\.md5|)$" "\\1;\\2" tuple "${entry}") + list(LENGTH tuple len) + if("${len}" EQUAL 2) + list(GET tuple 0 relname) + list(GET tuple 1 alg) + set(name "${top_src}/${relname}") + set(file "${top_bin}/${relname}") + if(alg) + list(APPEND external "${file}|${name}|${alg}") + elseif(ExternalData_LINK_CONTENT) + _ExternalData_link_content("${name}" alg) + list(APPEND external "${file}|${name}|${alg}") + elseif(NOT top_same) + list(APPEND internal "${file}|${name}") + endif() + if("${relname}" STREQUAL "${reldata}") + set(have_original 1) + endif() + endif() + endforeach() + set(external "${external}" PARENT_SCOPE) + set(internal "${internal}" PARENT_SCOPE) + set(have_original "${have_original}" PARENT_SCOPE) +endfunction() + +#----------------------------------------------------------------------------- +# Private script mode interface + +if(CMAKE_GENERATOR OR NOT ExternalData_ACTION) + return() +endif() + +if(ExternalData_CONFIG) + include(${ExternalData_CONFIG}) +endif() +if(NOT ExternalData_URL_TEMPLATES) + message(FATAL_ERROR "No ExternalData_URL_TEMPLATES set!") +endif() + +function(_ExternalData_link_or_copy src dst) + # Create a temporary file first. + get_filename_component(dst_dir "${dst}" PATH) + file(MAKE_DIRECTORY "${dst_dir}") + _ExternalData_random(random) + set(tmp "${dst}.tmp${random}") + if(UNIX) + # Create a symbolic link. + set(tgt "${src}") + if(relative_top) + # Use relative path if files are close enough. + file(RELATIVE_PATH relsrc "${relative_top}" "${src}") + file(RELATIVE_PATH relfile "${relative_top}" "${dst}") + if(NOT IS_ABSOLUTE "${relsrc}" AND NOT "${relsrc}" MATCHES "^\\.\\./" AND + NOT IS_ABSOLUTE "${reldst}" AND NOT "${reldst}" MATCHES "^\\.\\./") + file(RELATIVE_PATH tgt "${dst_dir}" "${src}") + endif() + endif() + execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${tgt}" "${tmp}" RESULT_VARIABLE result) + else() + # Create a copy. + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${src}" "${tmp}" RESULT_VARIABLE result) + endif() + if(result) + file(REMOVE "${tmp}") + message(FATAL_ERROR "Failed to create\n ${tmp}\nfrom\n ${obj}") + endif() + + # Atomically create/replace the real destination. + file(RENAME "${tmp}" "${dst}") +endfunction() + +function(_ExternalData_download_file url file err_var msg_var) + set(retry 3) + while(retry) + math(EXPR retry "${retry} - 1") + if("${CMAKE_VERSION}" VERSION_GREATER 2.8.4.20110602) + if(ExternalData_TIMEOUT_INACTIVITY) + set(inactivity_timeout INACTIVITY_TIMEOUT ${ExternalData_TIMEOUT_INACTIVITY}) + elseif(NOT "${ExternalData_TIMEOUT_INACTIVITY}" EQUAL 0) + set(inactivity_timeout INACTIVITY_TIMEOUT 60) + else() + set(inactivity_timeout "") + endif() + else() + set(inactivity_timeout "") + endif() + if(ExternalData_TIMEOUT_ABSOLUTE) + set(absolute_timeout TIMEOUT ${ExternalData_TIMEOUT_ABSOLUTE}) + elseif(NOT "${ExternalData_TIMEOUT_ABSOLUTE}" EQUAL 0) + set(absolute_timeout TIMEOUT 300) + else() + set(absolute_timeout "") + endif() + file(DOWNLOAD "${url}" "${file}" STATUS status LOG log ${inactivity_timeout} ${absolute_timeout} SHOW_PROGRESS) + list(GET status 0 err) + list(GET status 1 msg) + if(err) + if("${msg}" MATCHES "HTTP response code said error" AND + "${log}" MATCHES "error: 503") + set(msg "temporarily unavailable") + endif() + elseif("${log}" MATCHES "\nHTTP[^\n]* 503") + set(err TRUE) + set(msg "temporarily unavailable") + endif() + if(NOT err OR NOT "${msg}" MATCHES "partial|timeout|temporarily") + break() + elseif(retry) + message(STATUS "[download terminated: ${msg}, retries left: ${retry}]") + endif() + endwhile() + set("${err_var}" "${err}" PARENT_SCOPE) + set("${msg_var}" "${msg}" PARENT_SCOPE) +endfunction() + +function(_ExternalData_download_object name hash algo var_obj) + # Search all object stores for an existing object. + foreach(dir ${ExternalData_OBJECT_STORES}) + set(obj "${dir}/${algo}/${hash}") + if(EXISTS "${obj}") + message(STATUS "Found object: \"${obj}\"") + set("${var_obj}" "${obj}" PARENT_SCOPE) + return() + endif() + endforeach() + + # Download object to the first store. + list(GET ExternalData_OBJECT_STORES 0 store) + set(obj "${store}/${algo}/${hash}") + + _ExternalData_random(random) + set(tmp "${obj}.tmp${random}") + set(found 0) + set(tried "") + foreach(url_template IN LISTS ExternalData_URL_TEMPLATES) + string(REPLACE "%(hash)" "${hash}" url_tmp "${url_template}") + string(REPLACE "%(algo)" "${algo}" url "${url_tmp}") + message(STATUS "Fetching \"${url}\"") + _ExternalData_download_file("${url}" "${tmp}" err errMsg) + set(tried "${tried}\n ${url}") + if(err) + set(tried "${tried} (${errMsg})") + else() + # Verify downloaded object. + _ExternalData_compute_hash(dl_hash "${algo}" "${tmp}") + if("${dl_hash}" STREQUAL "${hash}") + set(found 1) + break() + else() + set(tried "${tried} (wrong hash ${algo}=${dl_hash})") + if("$ENV{ExternalData_DEBUG_DOWNLOAD}" MATCHES ".") + file(RENAME "${tmp}" "${store}/${algo}/${dl_hash}") + endif() + endif() + endif() + file(REMOVE "${tmp}") + endforeach() + + get_filename_component(dir "${name}" PATH) + set(staged "${dir}/.ExternalData_${algo}_${hash}") + + if(found) + file(RENAME "${tmp}" "${obj}") + message(STATUS "Downloaded object: \"${obj}\"") + elseif(EXISTS "${staged}") + set(obj "${staged}") + message(STATUS "Staged object: \"${obj}\"") + else() + message(FATAL_ERROR "Object ${algo}=${hash} not found at:${tried}") + endif() + + set("${var_obj}" "${obj}" PARENT_SCOPE) +endfunction() + +if("${ExternalData_ACTION}" STREQUAL "fetch") + foreach(v ExternalData_OBJECT_STORES file name ext) + if(NOT DEFINED "${v}") + message(FATAL_ERROR "No \"-D${v}=\" value provided!") + endif() + endforeach() + + file(READ "${name}${ext}" hash) + string(STRIP "${hash}" hash) + + if("${ext}" STREQUAL ".md5") + set(algo "MD5") + else() + message(FATAL_ERROR "Unknown hash algorithm extension \"${ext}\"") + endif() + + _ExternalData_download_object("${name}" "${hash}" "${algo}" obj) + + # Check if file already corresponds to the object. + set(stamp "${ext}-stamp") + set(file_up_to_date 0) + if(EXISTS "${file}" AND EXISTS "${file}${stamp}") + file(READ "${file}${stamp}" f_hash) + string(STRIP "${f_hash}" f_hash) + if("${f_hash}" STREQUAL "${hash}") + #message(STATUS "File already corresponds to object") + set(file_up_to_date 1) + endif() + endif() + + if(file_up_to_date) + # Touch the file to convince the build system it is up to date. + execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${file}") + else() + _ExternalData_link_or_copy("${obj}" "${file}") + endif() + + # Atomically update the hash/timestamp file to record the object referenced. + _ExternalData_atomic_write("${file}${stamp}" "${hash}\n") +elseif("${ExternalData_ACTION}" STREQUAL "local") + foreach(v file name) + if(NOT DEFINED "${v}") + message(FATAL_ERROR "No \"-D${v}=\" value provided!") + endif() + endforeach() + _ExternalData_link_or_copy("${name}" "${file}") +elseif("${ExternalData_ACTION}" STREQUAL "store") + foreach(v dir file) + if(NOT DEFINED "${v}") + message(FATAL_ERROR "No \"-D${v}=\" value provided!") + endif() + endforeach() + if(NOT DEFINED algo) + set(algo "MD5") + endif() + _ExternalData_compute_hash(hash "${algo}" "${file}") +else() + message(FATAL_ERROR "Unknown ExternalData_ACTION=[${ExternalData_ACTION}]") +endif() diff --git a/Modules/ExternalData_config.cmake.in b/Modules/ExternalData_config.cmake.in new file mode 100644 index 0000000000..0858f53688 --- /dev/null +++ b/Modules/ExternalData_config.cmake.in @@ -0,0 +1,4 @@ +set(ExternalData_OBJECT_STORES "@ExternalData_OBJECT_STORES@") +set(ExternalData_URL_TEMPLATES "@ExternalData_URL_TEMPLATES@") +set(ExternalData_TIMEOUT_INACTIVITY "@ExternalData_TIMEOUT_INACTIVITY@") +set(ExternalData_TIMEOUT_ABSOLUTE "@ExternalData_TIMEOUT_ABSOLUTE@") From 00d801fbfe9c5170e3a83019cc2e3f6b1ce64200 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 13:34:12 -0500 Subject: [PATCH 30/94] ExternalData: Remove compatibility with CMake < 2.8.5 Now that the module comes in a sufficiently new CMake it does not need to support older versions. --- Modules/ExternalData.cmake | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 84020f94de..4ab21867a7 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -119,8 +119,7 @@ # Variables ExternalData_TIMEOUT_INACTIVITY and ExternalData_TIMEOUT_ABSOLUTE # set the download inactivity and absolute timeouts, in seconds. The defaults # are 60 seconds and 300 seconds, respectively. Set either timeout to 0 -# seconds to disable enforcement. The inactivity timeout is enforced only -# with CMake >= 2.8.5. +# seconds to disable enforcement. #============================================================================= # Copyright 2010-2013 Kitware, Inc. @@ -263,13 +262,7 @@ function(_ExternalData_compute_hash var_hash algo file) endfunction() function(_ExternalData_random var) - if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.5) - string(RANDOM LENGTH 6 random) - elseif(EXISTS /dev/urandom) - file(READ /dev/urandom random LIMIT 4 HEX) - else() - message(FATAL_ERROR "CMake >= 2.8.5 required in this environment") - endif() + string(RANDOM LENGTH 6 random) set("${var}" "${random}" PARENT_SCOPE) endfunction() @@ -550,14 +543,10 @@ function(_ExternalData_download_file url file err_var msg_var) set(retry 3) while(retry) math(EXPR retry "${retry} - 1") - if("${CMAKE_VERSION}" VERSION_GREATER 2.8.4.20110602) - if(ExternalData_TIMEOUT_INACTIVITY) - set(inactivity_timeout INACTIVITY_TIMEOUT ${ExternalData_TIMEOUT_INACTIVITY}) - elseif(NOT "${ExternalData_TIMEOUT_INACTIVITY}" EQUAL 0) - set(inactivity_timeout INACTIVITY_TIMEOUT 60) - else() - set(inactivity_timeout "") - endif() + if(ExternalData_TIMEOUT_INACTIVITY) + set(inactivity_timeout INACTIVITY_TIMEOUT ${ExternalData_TIMEOUT_INACTIVITY}) + elseif(NOT "${ExternalData_TIMEOUT_INACTIVITY}" EQUAL 0) + set(inactivity_timeout INACTIVITY_TIMEOUT 60) else() set(inactivity_timeout "") endif() From cd66b9131d76984795c8a77353d6afa33abb54f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Jan 2013 13:49:16 +0100 Subject: [PATCH 31/94] Make calculation of link-interface-dependent properties type-sensitive. --- Source/cmTarget.cxx | 166 +++++++++++++++++++++++++++++++------------- 1 file changed, 118 insertions(+), 48 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2b912f3fca..d2839c5422 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4500,22 +4500,50 @@ void cmTarget::AddLinkDependentTargetsForProperties( } //---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) +template +PropertyType getTypedProperty(cmTarget *tgt, const char *prop, + PropertyType *); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget *tgt, const char *prop, bool *) { - bool propContent = this->GetPropertyAsBool(p.c_str()); - const bool explicitlySet = this->GetProperties() + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template +bool consistentProperty(PropertyType lhs, PropertyType rhs); + +//---------------------------------------------------------------------------- +template<> +bool consistentProperty(bool lhs, bool rhs) +{ + return lhs == rhs; +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, + const std::string &p, + const char *config, + const char *defaultValue, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p.c_str(), + 0); + const bool explicitlySet = tgt->GetProperties() .find(p.c_str()) - != this->GetProperties().end(); + != tgt->GetProperties().end(); std::set dependentTargets; - this->GetLinkDependentTargetsForProperty(p, + tgt->GetLinkDependentTargetsForProperty(p, dependentTargets); const bool impliedByUse = - this->IsNullImpliedByLinkLibraries(p); + tgt->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); - cmComputeLinkInformation *info = this->GetLinkInformation(config); + cmComputeLinkInformation *info = tgt->GetLinkInformation(config); const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; @@ -4537,17 +4565,18 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, const bool ifaceIsSet = li->Target->GetProperties() .find("INTERFACE_" + p) != li->Target->GetProperties().end(); - const bool ifacePropContent = li->Target->GetPropertyAsBool( - ("INTERFACE_" + p).c_str()); + PropertyType ifacePropContent = + getTypedProperty(li->Target, + ("INTERFACE_" + p).c_str(), 0); if (explicitlySet) { if (ifaceIsSet) { - if (propContent != ifacePropContent) + if (!consistentProperty(propContent, ifacePropContent)) { cmOStringStream e; e << "Property " << p << " on target \"" - << this->GetName() << "\" does\nnot match the " + << tgt->GetName() << "\" does\nnot match the " "INTERFACE_" << p << " property requirement\nof " "dependency \"" << li->Target->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); @@ -4569,13 +4598,13 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, { if (ifaceIsSet) { - if (propContent != ifacePropContent) + if (!consistentProperty(propContent, ifacePropContent)) { cmOStringStream e; e << "Property " << p << " on target \"" - << this->GetName() << "\" is\nimplied to be FALSE because it " - "was used to determine the link libraries\nalready. The " - "INTERFACE_" << p << " property on\ndependency \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" << li->Target->GetName() << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); break; @@ -4598,13 +4627,13 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, { if (propInitialized) { - if (propContent != ifacePropContent) + if (!consistentProperty(propContent, ifacePropContent)) { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" << li->Target->GetName() << "\" does\nnot agree with the value " "of " << p << " already determined\nfor \"" - << this->GetName() << "\".\n"; + << tgt->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); break; } @@ -4630,6 +4659,14 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, return propContent; } +//---------------------------------------------------------------------------- +bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, + const char *config) +{ + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", + 0); +} + //---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, const char *interfaceProperty, @@ -5417,6 +5454,64 @@ std::string cmTarget::CheckCMP0004(std::string const& item) return lib; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget *tgt, + const std::string prop, + const char *config, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget *tgt, + const std::string prop, + const char *config, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, + const char *propName, + std::set &emitted, + const char *config, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + if (depender->GetMakefile()->GetCMakeInstance() + ->GetIsPropertyDefined(pi->c_str(), + cmProperty::TARGET)) + { + cmOStringStream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + //---------------------------------------------------------------------------- void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, const char* config) @@ -5433,38 +5528,13 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, { continue; } - const char *prop = li->Target->GetProperty("COMPATIBLE_INTERFACE_BOOL"); - if (!prop) - { - continue; - } - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) + checkPropertyConsistency(this, li->Target, + "COMPATIBLE_INTERFACE_BOOL", + emitted, config, 0); + if (cmSystemTools::GetErrorOccuredFlag()) { - if (this->Makefile->GetCMakeInstance() - ->GetIsPropertyDefined(pi->c_str(), - cmProperty::TARGET)) - { - cmOStringStream e; - e << "Target \"" << li->Target->GetName() << "\" has property \"" - << *pi << "\" listed in its COMPATIBLE_INTERFACE_BOOL property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the COMPATIBLE_INTERFACE_BOOL property."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - this->GetLinkInterfaceDependentBoolProperty(*pi, config); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } + return; } } } From 2fb2c32f9b304bc71b039754f9b9170fd6f27a6f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Jan 2013 13:49:20 +0100 Subject: [PATCH 32/94] Add the COMPATIBLE_INTERFACE_STRING property. --- Source/cmExportFileGenerator.cxx | 6 ++ Source/cmGeneratorExpressionEvaluator.cxx | 7 ++ Source/cmTarget.cxx | 65 +++++++++++++++++++ Source/cmTarget.h | 5 ++ Tests/CompatibleInterface/CMakeLists.txt | 13 ++++ Tests/CompatibleInterface/main.cpp | 12 ++++ Tests/ExportImport/Export/CMakeLists.txt | 9 ++- Tests/ExportImport/Import/A/CMakeLists.txt | 2 + .../Import/A/deps_shared_iface.cpp | 4 ++ .../InterfaceString-builtin-prop-result.txt | 1 + .../InterfaceString-builtin-prop-stderr.txt | 5 ++ .../InterfaceString-builtin-prop.cmake | 11 ++++ ...faceString-mismatch-depend-self-result.txt | 1 + ...faceString-mismatch-depend-self-stderr.txt | 3 + ...InterfaceString-mismatch-depend-self.cmake | 11 ++++ ...nterfaceString-mismatch-depends-result.txt | 1 + ...nterfaceString-mismatch-depends-stderr.txt | 3 + .../InterfaceString-mismatch-depends.cmake | 10 +++ .../InterfaceString-mismatched-use-result.txt | 1 + .../InterfaceString-mismatched-use-stderr.txt | 4 ++ .../InterfaceString-mismatched-use.cmake | 9 +++ .../CompatibleInterface/RunCMakeTest.cmake | 4 ++ 22 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index ef1fc5f3b1..96e0aea0e8 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -217,6 +217,9 @@ void getCompatibleInterfaceProperties(cmTarget *target, getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_STRING", + ifaceProperties); } } @@ -227,10 +230,13 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( { this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", + target, properties); std::set ifaceProperties; getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); getCompatibleInterfaceProperties(target, ifaceProperties, 0); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index c468c3934c..0c61a122fb 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -462,6 +462,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode propertyName, context->Config) ? "1" : "0"; } + if (target->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) + { + return target->GetLinkInterfaceDependentStringProperty( + propertyName, + context->Config); + } return std::string(); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d2839c5422..e3be510344 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -907,6 +907,17 @@ void cmTarget::DefineProperties(cmake *cm) "then it must have the same boolean value as all others, and if the " "property is not set, then it is ignored."); + cm->DefineProperty + ("COMPATIBLE_INTERFACE_STRING", cmProperty::TARGET, + "Properties which must be string-compatible with their link interface", + "The COMPATIBLE_INTERFACE_STRING property may contain a list of " + "properties for this target which must be the same when evaluated as " + "a string in the INTERFACE of all linked dependencies. For example, " + "if a property \"FOO\" appears in the list, then the \"INTERFACE_FOO\" " + "property content in all dependencies must be equal with each " + "other, and with the \"FOO\" property in this target. If the " + "property is not set, then it is ignored."); + cm->DefineProperty ("POST_INSTALL_SCRIPT", cmProperty::TARGET, "Deprecated install support.", @@ -4511,6 +4522,14 @@ bool getTypedProperty(cmTarget *tgt, const char *prop, bool *) return tgt->GetPropertyAsBool(prop); } +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget *tgt, const char *prop, + const char **) +{ + return tgt->GetProperty(prop); +} + //---------------------------------------------------------------------------- template bool consistentProperty(PropertyType lhs, PropertyType rhs); @@ -4522,6 +4541,17 @@ bool consistentProperty(bool lhs, bool rhs) return lhs == rhs; } +//---------------------------------------------------------------------------- +template<> +bool consistentProperty(const char *lhs, const char *rhs) +{ + if (!lhs && !rhs) + return true; + if (!lhs || !rhs) + return false; + return strcmp(lhs, rhs) == 0; +} + //---------------------------------------------------------------------------- template PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, @@ -4667,6 +4697,17 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, 0); } +//---------------------------------------------------------------------------- +const char * cmTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const char *config) +{ + return checkInterfacePropertyCompatibility(this, + p, + config, + "empty", 0); +} + //---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, const char *interfaceProperty, @@ -4714,6 +4755,14 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, config); } +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, + const char *config) +{ + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", + config); +} + //---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages) const { @@ -5468,6 +5517,15 @@ bool getLinkInterfaceDependentProperty(cmTarget *tgt, return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } +template<> +const char * getLinkInterfaceDependentProperty(cmTarget *tgt, + const std::string prop, + const char *config, + const char **) +{ + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); +} + //---------------------------------------------------------------------------- template void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, @@ -5536,6 +5594,13 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, { return; } + checkPropertyConsistency(this, li->Target, + "COMPATIBLE_INTERFACE_STRING", + emitted, config, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9909bae600..4457becdf3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -501,12 +501,17 @@ public: bool IsNullImpliedByLinkLibraries(const std::string &p); bool IsLinkInterfaceDependentBoolProperty(const std::string &p, const char *config); + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const char *config); void AddLinkDependentTargetsForProperties( const std::map &map); bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const char *config); + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const char *config); private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 728065231a..259b5a1860 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -14,21 +14,34 @@ set_property(TARGET iface1 APPEND PROPERTY BOOL_PROP3 BOOL_PROP4 ) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING + STRING_PROP1 + STRING_PROP2 + STRING_PROP3 +) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1) +set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2) add_executable(CompatibleInterface main.cpp) target_link_libraries(CompatibleInterface iface1) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) +set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2) +set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3) target_compile_definitions(CompatibleInterface PRIVATE $<$>:BOOL_PROP1> $<$>:BOOL_PROP2> $<$>:BOOL_PROP3> + $<$,prop1>:STRING_PROP1> + $<$,prop2>:STRING_PROP2> + $<$,prop3>:STRING_PROP3> ) diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index ae0e985c89..f5e6e38918 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -11,6 +11,18 @@ #error Expected BOOL_PROP3 #endif +#ifndef STRING_PROP1 +#error Expected STRING_PROP1 +#endif + +#ifndef STRING_PROP2 +#error Expected STRING_PROP2 +#endif + +#ifndef STRING_PROP3 +#error Expected STRING_PROP3 +#endif + #include "iface2.h" int main(int argc, char **argv) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 599229340d..eecfd6a319 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -181,7 +181,14 @@ set_property(TARGET testSharedLibRequired PROPERTY INTERFACE_CUSTOM_PROP ON ) - +set_property(TARGET testSharedLibRequired + APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING CUSTOM_STRING +) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_CUSTOM_STRING testcontent +) add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) set_property(TARGET testSharedLibDepends APPEND PROPERTY diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 4df57715b4..187c48ae0a 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -170,6 +170,7 @@ target_compile_definitions(deps_shared_iface testSharedLibDepends $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> + $<$,testcontent>:CUSTOM_STRING_IS_MATCH> ) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -201,4 +202,5 @@ target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> + $<$,testcontent>:CUSTOM_STRING_IS_MATCH> ) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index a33f200ecd..2f0e74a07b 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -16,6 +16,10 @@ #error Expected CUSTOM_PROPERTY_IS_ON #endif +#ifndef CUSTOM_STRING_IS_MATCH +#error Expected CUSTOM_STRING_IS_MATCH +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt new file mode 100644 index 0000000000..6a293b4f11 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Target "foo" has property "INCLUDE_DIRECTORIES" listed in its + COMPATIBLE_INTERFACE_STRING property. This is not allowed. Only + user-defined properties may appear listed in the + COMPATIBLE_INTERFACE_STRING property. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake new file mode 100644 index 0000000000..5221a129c6 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING INCLUDE_DIRECTORIES) +set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES foo_inc) +set_property(TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES bar_inc) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES bar_inc) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt new file mode 100644 index 0000000000..0476da97d2 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: Property SOMEPROP on target "user" does +not match the INTERFACE_SOMEPROP property requirement +of dependency "foo". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake new file mode 100644 index 0000000000..187f29f796 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP prop) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP prop) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY SOMEPROP different) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt new file mode 100644 index 0000000000..d885c09d95 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: The INTERFACE_SOMEPROP property of "bar" does +not agree with the value of SOMEPROP already determined +for "user". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake new file mode 100644 index 0000000000..73cc3fc55b --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake @@ -0,0 +1,10 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP foo) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP bar) + +add_executable(user main.cpp) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt new file mode 100644 index 0000000000..723daec098 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: Property SOMEPROP on target "user" is +implied to be empty because it was used to determine the link libraries +already. The INTERFACE_SOMEPROP property on +dependency "foo" is in conflict. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake new file mode 100644 index 0000000000..af3ce8fbc8 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP prop) + +add_executable(user main.cpp) +target_link_libraries(user foo $<$,prop>:bar>) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake index ba8917b865..922ad7fc73 100644 --- a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -4,3 +4,7 @@ run_cmake(InterfaceBool-mismatch-depends) run_cmake(InterfaceBool-mismatch-depend-self) run_cmake(InterfaceBool-mismatched-use) run_cmake(InterfaceBool-builtin-prop) +run_cmake(InterfaceString-mismatch-depends) +run_cmake(InterfaceString-mismatch-depend-self) +run_cmake(InterfaceString-mismatched-use) +run_cmake(InterfaceString-builtin-prop) From d4774140b7fa8685a9f29147308fd7fe5365e1fb Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 24 Jan 2013 21:15:58 +0100 Subject: [PATCH 33/94] configure_package_config_file: force absolute paths for usr-move The configure_package_config()_file() macro will now use absolute paths for the PATH_VARS if the Config.cmake file will be installed into /lib(64) or /usr/lib(64), since due to the usr-move filesystem changes Config.cmake files installed there may be found via two paths (once per symlink via /lib(64) and once via /usr/lib ), and in this case relative paths break. Alex --- Modules/CMakePackageConfigHelpers.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index a92ce7cc96..13617cec19 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -173,18 +173,34 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) else() set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}") endif() + + # with the /usr-move, /lib(64) is a symlink to /usr/lib on Fedora, ArchLinux, Mageira and others. + # If we are installed to such a location, force using absolute paths. + set(forceAbsolutePaths FALSE) + if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") + set(forceAbsolutePaths TRUE) + endif() + file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" ) foreach(var ${CCF_PATH_VARS}) if(NOT DEFINED ${var}) message(FATAL_ERROR "Variable ${var} does not exist") else() + if(forceAbsolutePaths) + if(IS_ABSOLUTE "${${var}}") + set(PACKAGE_${var} "${${var}}") + else() + set(PACKAGE_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() + else() if(IS_ABSOLUTE "${${var}}") string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" PACKAGE_${var} "${${var}}") else() set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") endif() + endif() endif() endforeach() From 37c4bc1f86a72a76a1ccc3094ba7cc3ec134ff21 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 24 Jan 2013 21:18:47 +0100 Subject: [PATCH 34/94] configure_package_config_file(): fix indentation This is a separate commit, so that the previous commit is smaller. Alex --- Modules/CMakePackageConfigHelpers.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 13617cec19..d6d3cb11b0 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -194,12 +194,12 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) set(PACKAGE_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() else() - if(IS_ABSOLUTE "${${var}}") - string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" - PACKAGE_${var} "${${var}}") - else() - set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") - endif() + if(IS_ABSOLUTE "${${var}}") + string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" + PACKAGE_${var} "${${var}}") + else() + set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") + endif() endif() endif() endforeach() From 4cad84836989c6c9e4da97fced637b7bdbc222c7 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 24 Jan 2013 21:27:32 +0100 Subject: [PATCH 35/94] configure_package_config_file(): extend documentation Alex --- Modules/CMakePackageConfigHelpers.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index d6d3cb11b0..393d05c806 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -9,6 +9,8 @@ # configure_file() command when creating the Config.cmake or -config.cmake # file for installing a project or library. It helps making the resulting package # relocatable by avoiding hardcoded paths in the installed Config.cmake file. +# Config.cmake files installed under UNIX into /lib(64) or /usr/lib(64) are +# considered system packages and are not relocatable. # # In a FooConfig.cmake file there may be code like this to make the # install destinations know to the using project: From f032fb904b9b7a4f18702bcdbdeff0dfda01b803 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 15:46:22 -0500 Subject: [PATCH 36/94] target_link_libraries: Document that new sigs privatize old (#13876) Explain in the documentation for the legacy signature target_link_libraries(foo bar) that the other signatures like target_link_libraries(foo LINK_INTERFACE_LIBRARIES ...) target_link_libraries(foo LINK_PRIVATE ...) will set the LINK_INTERFACE_LIBRARIES target property and therefore make libraries specified only by the legacy signature private. --- Source/cmTargetLinkLibrariesCommand.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 34fe54c346..3da395089a 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -93,7 +93,9 @@ public: "linked to this target will appear on the link line for the other " "target too. " "See the LINK_INTERFACE_LIBRARIES target property to override the " - "set of transitive link dependencies for a target." + "set of transitive link dependencies for a target. " + "Calls to other signatures of this command may set the property " + "making any libraries linked exclusively by this signature private." "\n" " target_link_libraries( LINK_INTERFACE_LIBRARIES\n" " [[debug|optimized|general] ] ...)\n" From 6c57c31414b17028cfe2c393752458d5899f09a4 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Thu, 24 Jan 2013 22:04:09 +0100 Subject: [PATCH 37/94] doc: fix linebreaks in generator expression documentation --- Source/cmDocumentGeneratorExpressions.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index c2bf423ca6..be9f2ffa70 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -47,9 +47,10 @@ " $/$\n" \ " $/$\n" \ "\n" \ - " $ = The value of the property prop\n" \ - "on the target tgt. Note that tgt is not added as a dependency of\n" \ - "the target this expression is evaluated on.\n" \ + " $ = The value of the property prop " \ + "on the target tgt.\n" \ + "Note that tgt is not added as a dependency of the target this " \ + "expression is evaluated on.\n" \ " $ = '1' if the policy was NEW when " \ "the 'head' target was created, else '0'. If the policy was not " \ "set, the warning message for the policy will be emitted. This " \ @@ -64,7 +65,7 @@ #define CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS \ CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS \ "Expressions with an implicit 'this' target:\n" \ - " $ = The value of the property prop on\n" \ + " $ = The value of the property prop on " \ "the target on which the generator expression is evaluated.\n" \ "" From e03f83f394c53acbcc9dcff03f189170b2f33322 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Thu, 24 Jan 2013 23:15:13 +0100 Subject: [PATCH 38/94] ProcessorCount test: fix path to cmsysTestsCxx executable Use a generator expression to get the real place of this target instead of guessing it wrong. --- Tests/CMakeTests/CMakeLists.txt | 5 +++-- Tests/CMakeTests/ProcessorCountTest.cmake.in | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index d34d4a6185..b0499954bd 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -4,7 +4,8 @@ set(CMAKE_EXECUTABLE "${CMake_BIN_DIR}/cmake") macro(AddCMakeTest TestName PreArgs) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${TestName}Test.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" @ONLY IMMEDIATE) - add_test(CMake.${TestName} ${CMAKE_EXECUTABLE} ${PreArgs} + add_test(NAME CMake.${TestName} + COMMAND ${CMAKE_EXECUTABLE} ${PreArgs} -P "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" ${ARGN}) endmacro() @@ -28,7 +29,7 @@ AddCMakeTest(String "") AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") -AddCMakeTest(ProcessorCount "") +AddCMakeTest(ProcessorCount "-DKWSYS_TEST_EXE=$") AddCMakeTest(PushCheckState "") AddCMakeTest(While "") diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in index 98f6ab16df..15e0219489 100644 --- a/Tests/CMakeTests/ProcessorCountTest.cmake.in +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -9,7 +9,7 @@ message("### 3. ProcessorCount(...) function call is emitting output that it sho message("processor_count='${processor_count}'") execute_process( - COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx" + COMMAND "${KWSYS_TEST_EXE}" testSystemInformation OUTPUT_VARIABLE tsi_out ERROR_VARIABLE tsi_err) From 4d0e2e81e9c60f6f147f3b332b1d885d543b2084 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 23 Jan 2013 20:23:18 +0100 Subject: [PATCH 39/94] ProcessorCount test: require SystemInformation process to work Currently this silently fails on some systems. Make sure those things get noticed so we can fix that. --- Tests/CMakeTests/ProcessorCountTest.cmake.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in index 15e0219489..f92dcc44c5 100644 --- a/Tests/CMakeTests/ProcessorCountTest.cmake.in +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -12,7 +12,14 @@ execute_process( COMMAND "${KWSYS_TEST_EXE}" testSystemInformation OUTPUT_VARIABLE tsi_out - ERROR_VARIABLE tsi_err) + ERROR_VARIABLE tsi_err + RESULT_VARIABLE tsi_res +) +if (tsi_res) + message("executing \"${KWSYS_TEST_EXE}\" failed") + message(FATAL_ERROR "output: ${tsi_res}") +endif () + string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2" system_info_processor_count "${tsi_out}") From a4eb27fbab81087fde72f2058b60a67f1f9298da Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 25 Jan 2013 00:01:19 -0500 Subject: [PATCH 40/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2c688b7715..2c5211150b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130124) +set(CMake_VERSION_TWEAK 20130125) #set(CMake_VERSION_RC 1) From f7db6d115d0bd665ee0ed9be9994a59792d016af Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 26 Jan 2013 00:01:18 -0500 Subject: [PATCH 41/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2c5211150b..059bb6c0f0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130125) +set(CMake_VERSION_TWEAK 20130126) #set(CMake_VERSION_RC 1) From 00ba2545fabcb8ce7d62387464060634683282b9 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 27 Jan 2013 00:01:25 -0500 Subject: [PATCH 42/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 059bb6c0f0..380f6cd3e5 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130126) +set(CMake_VERSION_TWEAK 20130127) #set(CMake_VERSION_RC 1) From 3a1719793fa4eb4024e2e36e17196832551d469c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 27 Jan 2013 09:42:54 +0100 Subject: [PATCH 43/94] Generate the _IMPORT_PREFIX in the non-config export file. --- Source/cmExportInstallFileGenerator.cxx | 57 ++++++++++++------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index a35f5cf6e0..c7e3581d74 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -69,6 +69,27 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateExpectedTargetsCode(os, expectedTargets); } + // Add code to compute the installation prefix relative to the + // import file location. + const char* installDest = this->IEGen->GetDestination(); + if(!cmSystemTools::FileIsFullPath(installDest)) + { + std::string dest = installDest; + os << "# Compute the installation prefix relative to this file.\n" + << "get_filename_component(_IMPORT_PREFIX " + << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; + while(!dest.empty()) + { + os << + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + dest = cmSystemTools::GetFilenamePath(dest); + } + os << "\n"; + + // Import location properties may reference this variable. + this->ImportPrefix = "${_IMPORT_PREFIX}/"; + } + std::vector missingTargets; // Create all the imported targets. @@ -107,6 +128,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) << "endforeach()\n" << "\n"; + // Cleanup the import prefix variable. + if(!this->ImportPrefix.empty()) + { + os << "# Cleanup temporary variables.\n" + << "set(_IMPORT_PREFIX)\n" + << "\n"; + } this->GenerateImportedFileCheckLoop(os); // Generate an import file for each configuration. @@ -187,27 +215,6 @@ cmExportInstallFileGenerator const char* config, std::string const& suffix, std::vector &missingTargets) { - // Add code to compute the installation prefix relative to the - // import file location. - const char* installDest = this->IEGen->GetDestination(); - if(!cmSystemTools::FileIsFullPath(installDest)) - { - std::string dest = installDest; - os << "# Compute the installation prefix relative to this file.\n" - << "get_filename_component(_IMPORT_PREFIX " - << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - while(!dest.empty()) - { - os << - "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; - dest = cmSystemTools::GetFilenamePath(dest); - } - os << "\n"; - - // Import location properties may reference this variable. - this->ImportPrefix = "${_IMPORT_PREFIX}/"; - } - // Add each target in the set to the export. for(std::vector::const_iterator tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); @@ -253,14 +260,6 @@ cmExportInstallFileGenerator importedLocations); } } - - // Cleanup the import prefix variable. - if(!this->ImportPrefix.empty()) - { - os << "# Cleanup temporary variables.\n" - << "set(_IMPORT_PREFIX)\n" - << "\n"; - } } //---------------------------------------------------------------------------- From 34d1ade048a87953c089d730f0126eecb6685968 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 27 Jan 2013 09:43:44 +0100 Subject: [PATCH 44/94] Add the INSTALL_PREFIX genex. --- Source/cmDocumentGeneratorExpressions.h | 2 ++ Source/cmExportFileGenerator.cxx | 10 ++++++++++ Source/cmExportFileGenerator.h | 2 ++ Source/cmExportInstallFileGenerator.cxx | 15 +++++++++++++++ Source/cmExportInstallFileGenerator.h | 2 ++ Source/cmGeneratorExpressionEvaluator.cxx | 20 ++++++++++++++++++++ Tests/ExportImport/Export/CMakeLists.txt | 17 ++++++++++++++++- Tests/GeneratorExpression/CMakeLists.txt | 1 + Tests/GeneratorExpression/check-part2.cmake | 1 + 9 files changed, 69 insertions(+), 1 deletion(-) diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index be9f2ffa70..8b80a8a321 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -55,6 +55,8 @@ "the 'head' target was created, else '0'. If the policy was not " \ "set, the warning message for the policy will be emitted. This " \ "generator expression only works for a subset of policies.\n" \ + " $ = Content of the install prefix when " \ + "the target is exported via INSTALL(EXPORT) and empty otherwise.\n" \ "Boolean expressions:\n" \ " $ = '1' if all '?' are '1', else '0'\n" \ " $ = '0' if all '?' are '0', else '1'\n" \ diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 96e0aea0e8..2ae7138bd7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -431,12 +431,22 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( input.replace(pos, endPos - pos + 1, targetName); lastPos = endPos; } + + this->ReplaceInstallPrefix(input); + if (!errorString.empty()) { mf->IssueMessage(cmake::FATAL_ERROR, errorString); } } +//---------------------------------------------------------------------------- +void +cmExportFileGenerator::ReplaceInstallPrefix(std::string &) +{ + // Do nothing +} + //---------------------------------------------------------------------------- void cmExportFileGenerator diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index b39df0f8b1..776be614d3 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -152,6 +152,8 @@ private: void ResolveTargetsInGeneratorExpression(std::string &input, cmTarget* target, std::vector &missingTargets); + + virtual void ReplaceInstallPrefix(std::string &input); }; #endif diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c7e3581d74..b6600f0b48 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -154,6 +154,21 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) return result; } +//---------------------------------------------------------------------------- +void +cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input) +{ + std::string::size_type pos = 0; + std::string::size_type lastPos = pos; + + while((pos = input.find("$", lastPos)) != input.npos) + { + std::string::size_type endPos = pos + sizeof("$") - 1; + input.replace(pos, endPos - pos, "${_IMPORT_PREFIX}"); + lastPos = endPos; + } +} + //---------------------------------------------------------------------------- bool cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index e1877499d6..7a704311ec 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -64,6 +64,8 @@ protected: cmTarget* depender, cmTarget* dependee); + virtual void ReplaceInstallPrefix(std::string &input); + void ComplainAboutMissingTarget(cmTarget* depender, cmTarget* dependee, int occurrences); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 0c61a122fb..f74b69e5f4 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -614,6 +614,24 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode } targetPolicyNode; +//---------------------------------------------------------------------------- +static const struct InstallPrefixNode : public cmGeneratorExpressionNode +{ + InstallPrefixNode() {} + + virtual bool GeneratesContent() const { return false; } + virtual int NumExpectedParameters() const { return 0; } + + std::string Evaluate(const std::vector &, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return std::string(); + } + +} installPrefixNode; + //---------------------------------------------------------------------------- template struct TargetFilesystemArtifactResultCreator @@ -849,6 +867,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &installInterfaceNode; else if (identifier == "TARGET_DEFINED") return &targetDefinedNode; + else if (identifier == "INSTALL_PREFIX") + return &installPrefixNode; return 0; } diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index eecfd6a319..cfcd9fa886 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -113,9 +113,16 @@ macro(add_include_lib _libName) add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_libName}") set_property(TARGET ${_libName} APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/${_libName}") + INTERFACE_INCLUDE_DIRECTORIES + "$" + "$/include/${_libName}>" + ) if (NOT "${ARGV1}" STREQUAL "NO_HEADER") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" "// no content\n") + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" + DESTINATION include/${_libName} + ) endif() endmacro() @@ -129,6 +136,10 @@ add_include_lib(testLibIncludeRequired3 NO_HEADER) # but we are testing that the INSTALL_INTERFACE causes it not to be used # at build time. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h" "#error Should not be included\n") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h" + DESTINATION include/testLibIncludeRequired3 +) add_include_lib(testLibIncludeRequired4) add_include_lib(testLibIncludeRequired5 NO_HEADER) # Generate testLibIncludeRequired6 in the testLibIncludeRequired5 directory @@ -139,6 +150,10 @@ add_include_lib(testLibIncludeRequired5 NO_HEADER) # the Import side of this unit test, the '6' include from the '5' directory # will not be used because it is in the BUILD_INTERFACE only. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h" "#error Should not be included\n") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h" + DESTINATION include/testLibIncludeRequired5 +) add_include_lib(testLibIncludeRequired6) set_property(TARGET testLibRequired APPEND PROPERTY diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ecbbedf446..a40a54124a 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -89,6 +89,7 @@ add_custom_target(check-part2 ALL -Dtest_install_interface=$ -Dtest_target_name_1=$ -Dtest_target_name_2=$ + -Dtest_install_prefix=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 2)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part2.cmake b/Tests/GeneratorExpression/check-part2.cmake index 8855a977c5..0b502045d7 100644 --- a/Tests/GeneratorExpression/check-part2.cmake +++ b/Tests/GeneratorExpression/check-part2.cmake @@ -26,3 +26,4 @@ check(test_build_interface "build") check(test_install_interface "") check(test_target_name_1 "tgt,ok") check(test_target_name_2 "tgt:ok") +check(test_install_prefix "") From a7d6ebb01ba7418af3af74a532900f0d7cb210fe Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 27 Jan 2013 18:00:14 +0100 Subject: [PATCH 45/94] documentation: handling of relative paths by include- and link_directories() Alex --- Source/cmIncludeDirectoryCommand.h | 5 +++-- Source/cmLinkDirectoriesCommand.h | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index a32fc77594..77a340a645 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -59,8 +59,9 @@ public: return " include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)\n" "Add the given directories to those the compiler uses to search " - "for include files. " - "These directories are added to the directory property " + "for include files. Relative paths are interpreted as relative to " + "the current source directory. \n" + "The include directories are added to the directory property " "INCLUDE_DIRECTORIES for the current CMakeLists file. " "They are also added to the target property INCLUDE_DIRECTORIES " "for each target in the current CMakeLists file. " diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 889118cbca..9218f448d9 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -62,10 +62,8 @@ public: " link_directories(directory1 directory2 ...)\n" "Specify the paths in which the linker should search for libraries. " "The command will apply only to targets created after it is called. " - "For historical reasons, relative paths given to this command are " - "passed to the linker unchanged " - "(unlike many CMake commands which interpret them relative to the " - "current source directory).\n" + "Relative paths given to this command are interpreted as relative to " + "the current source directory, see CMP0015. \n" "Note that this command is rarely necessary. Library locations " "returned by find_package() and find_library() are absolute paths. " "Pass these absolute library file paths directly to the " From e2afc40d0651e3762829fa911bfc11373afd092b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 28 Jan 2013 00:01:18 -0500 Subject: [PATCH 46/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 380f6cd3e5..ef3952be93 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130127) +set(CMake_VERSION_TWEAK 20130128) #set(CMake_VERSION_RC 1) From 399c3b8e5458c57a5505bade291ec7944c7391ec Mon Sep 17 00:00:00 2001 From: Rodolfo Schulz de Lima Date: Fri, 25 Jan 2013 17:03:00 -0500 Subject: [PATCH 47/94] FindGTK2: Fix GTK2_LIBRARIES order for static gtk libraries Before this, when creating GTK2_LIBRARIES, FindGTK2 added the GTK dependencies in wrong order into GTK2_LIBRARIES. With dynamic libraries this is not a major problem, but when linking to static gtk libraries, the linker outputs a lot of undefined symbols. Reorder the calls that append libraries to GTK2_LIBRARIES to respect dependency order. --- Modules/FindGTK2.cmake | 76 +++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 517a9ac6a9..06cf962443 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -439,28 +439,19 @@ list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES}) foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(_GTK2_component STREQUAL "gtk") - _GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG_INCLUDE_DIR glibconfig.h) - _GTK2_FIND_LIBRARY (GTK2_GLIB_LIBRARY glib false true) - - _GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h) - _GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true) - - _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) - _GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true) - - _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h) if(UNIX) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) else() - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) endif() + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h) _GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false) @@ -469,35 +460,40 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h) _GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) + _GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true) + + _GTK2_FIND_LIBRARY (GTK2_GIO_LIBRARY gio false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h) _GTK2_FIND_LIBRARY (GTK2_ATK_LIBRARY atk false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h) + _GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG_INCLUDE_DIR glibconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLIB_LIBRARY glib false true) elseif(_GTK2_component STREQUAL "gtkmm") - _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMM_INCLUDE_DIR glibmm.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h) - _GTK2_FIND_LIBRARY (GTK2_GLIBMM_LIBRARY glibmm true true) - - _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMM_INCLUDE_DIR gdkmm.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h) - _GTK2_FIND_LIBRARY (GTK2_GDKMM_LIBRARY gdkmm true true) - _GTK2_FIND_INCLUDE_DIR(GTK2_GTKMM_INCLUDE_DIR gtkmm.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GTKMMCONFIG_INCLUDE_DIR gtkmmconfig.h) _GTK2_FIND_LIBRARY (GTK2_GTKMM_LIBRARY gtkmm true true) - _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMMCONFIG_INCLUDE_DIR cairommconfig.h) - _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMM_INCLUDE_DIR gdkmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GDKMM_LIBRARY gdkmm true true) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM_INCLUDE_DIR pangomm.h) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h) _GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true) - _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++CONFIG_INCLUDE_DIR sigc++config.h) - _GTK2_FIND_LIBRARY (GTK2_SIGC++_LIBRARY sigc true true) + _GTK2_FIND_LIBRARY (GTK2_PANGOCAIRO_LIBRARY pangocairo true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMMCONFIG_INCLUDE_DIR cairommconfig.h) + _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) _GTK2_FIND_INCLUDE_DIR(GTK2_GIOMM_INCLUDE_DIR giomm.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GIOMMCONFIG_INCLUDE_DIR giommconfig.h) @@ -506,6 +502,15 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK2_ATKMM_INCLUDE_DIR atkmm.h) _GTK2_FIND_LIBRARY (GTK2_ATKMM_LIBRARY atkmm true true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMM_INCLUDE_DIR glibmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLIBMM_LIBRARY glibmm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++CONFIG_INCLUDE_DIR sigc++config.h) + _GTK2_FIND_LIBRARY (GTK2_SIGC++_LIBRARY sigc true true) + + elseif(_GTK2_component STREQUAL "glade") _GTK2_FIND_INCLUDE_DIR(GTK2_GLADE_INCLUDE_DIR glade/glade.h) @@ -549,13 +554,13 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) GTK2_GTK_LIBRARY GTK2_GTK_INCLUDE_DIR - GTK2_GLIB_INCLUDE_DIR - GTK2_GLIBCONFIG_INCLUDE_DIR - GTK2_GLIB_LIBRARY - GTK2_GDK_INCLUDE_DIR GTK2_GDKCONFIG_INCLUDE_DIR GTK2_GDK_LIBRARY + + GTK2_GLIB_INCLUDE_DIR + GTK2_GLIBCONFIG_INCLUDE_DIR + GTK2_GLIB_LIBRARY ) elseif(_GTK2_component STREQUAL "gtkmm") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found." @@ -563,13 +568,14 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) GTK2_GTKMM_INCLUDE_DIR GTK2_GTKMMCONFIG_INCLUDE_DIR + GTK2_GDKMM_INCLUDE_DIR + GTK2_GDKMMCONFIG_INCLUDE_DIR + GTK2_GDKMM_LIBRARY + GTK2_GLIBMM_INCLUDE_DIR GTK2_GLIBMMCONFIG_INCLUDE_DIR GTK2_GLIBMM_LIBRARY - GTK2_GDKMM_INCLUDE_DIR - GTK2_GDKMMCONFIG_INCLUDE_DIR - GTK2_GDKMM_LIBRARY ) elseif(_GTK2_component STREQUAL "glade") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glade library was not found." From 7bb8344d50fa317580068dedd00b019be8a6cb98 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 13:35:30 -0500 Subject: [PATCH 48/94] ExternalData: Do not match directory names when resolving DATA{} Our content link and object download infrastructure supports only blobs (files), not trees (directories). Do not allow references to end in a slash. --- Modules/ExternalData.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 4ab21867a7..29ddffd9ea 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -304,6 +304,13 @@ function(_ExternalData_arg target arg options var_file) list(GET options 0 data) list(REMOVE_AT options 0) + # Reject trailing slashes. + if("x${data}" MATCHES "[/\\]$") + message(FATAL_ERROR "Data file reference in argument\n" + " ${arg}\n" + "may not end in a slash!") + endif() + # Convert to full path. if(IS_ABSOLUTE "${data}") set(absdata "${data}") @@ -376,7 +383,7 @@ function(_ExternalData_arg target arg options var_file) " ${arg}\n" "corresponds to source tree path\n" " ${reldata}\n" - "that does not exist (with or without an extension)!") + "that does not exist as a file (with or without an extension)!") endif() if(external) @@ -470,7 +477,7 @@ function(_ExternalData_arg_find_files pattern regex) foreach(entry IN LISTS globbed) string(REGEX REPLACE "^(${regex})(\\.md5|)$" "\\1;\\2" tuple "${entry}") list(LENGTH tuple len) - if("${len}" EQUAL 2) + if("${len}" EQUAL 2 AND NOT IS_DIRECTORY "${top_src}/${entry}") list(GET tuple 0 relname) list(GET tuple 1 alg) set(name "${top_src}/${relname}") From 52759930bd7a5e1642b16cdc2bde3d23aaaddd2c Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 13:37:54 -0500 Subject: [PATCH 49/94] ExternalData: Cleanup stray TODO and typo in comments Remove an outdated TODO line left from earlier designs. Also fix a typo. --- Modules/ExternalData.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 29ddffd9ea..0800bb37ef 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -315,7 +315,6 @@ function(_ExternalData_arg target arg options var_file) if(IS_ABSOLUTE "${data}") set(absdata "${data}") else() - # TODO: If ${data} does not start in "./" or "../" then use search path? get_filename_component(absdata "${CMAKE_CURRENT_SOURCE_DIR}/${data}" ABSOLUTE) endif() @@ -465,7 +464,7 @@ macro(_ExternalData_arg_series) list(GET tuple 2 ext) # Glob files that might match the series. - # Then match match base, number, and extension. + # Then match base, number, and extension. _ExternalData_exact_regex(series_base "${relbase}") _ExternalData_exact_regex(series_ext "${ext}") _ExternalData_arg_find_files("${relbase}*${ext}" From c0cebcb19ae53773f6b21035813c6d58dd829b94 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 14:06:17 -0500 Subject: [PATCH 50/94] ExternalData: Remove unused private interface The 'store' action was part of an older design and is no longer needed. Remove it. --- Modules/ExternalData.cmake | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 0800bb37ef..d678cf2faf 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -690,16 +690,6 @@ elseif("${ExternalData_ACTION}" STREQUAL "local") endif() endforeach() _ExternalData_link_or_copy("${name}" "${file}") -elseif("${ExternalData_ACTION}" STREQUAL "store") - foreach(v dir file) - if(NOT DEFINED "${v}") - message(FATAL_ERROR "No \"-D${v}=\" value provided!") - endif() - endforeach() - if(NOT DEFINED algo) - set(algo "MD5") - endif() - _ExternalData_compute_hash(hash "${algo}" "${file}") else() message(FATAL_ERROR "Unknown ExternalData_ACTION=[${ExternalData_ACTION}]") endif() From 61d641dccb216bd585430231e0851c6b6eab4343 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 29 Jan 2013 00:01:18 -0500 Subject: [PATCH 51/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ef3952be93..608c269eeb 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130128) +set(CMake_VERSION_TWEAK 20130129) #set(CMake_VERSION_RC 1) From 5daaa5c48dc6066b5bb145aff30286cc63c12e81 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 26 Jan 2013 11:04:12 +0100 Subject: [PATCH 52/94] Fix TARGET_PROPERTY target extractions. We need to make sure we can export targets which have content such as $<0:$ That means making not finding a target non-fatal here. --- Source/cmExportFileGenerator.cxx | 14 +++----------- Tests/ExportImport/Export/CMakeLists.txt | 2 ++ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 96e0aea0e8..63756b1a94 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -367,7 +367,6 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string::size_type lastPos = pos; cmMakefile *mf = target->GetMakefile(); - std::string errorString; while((pos = input.find("$AddTargetNamespace(targetName, target, missingTargets)) + if (this->AddTargetNamespace(targetName, target, missingTargets)) { - errorString = "$ requires " - "its first parameter to be a reachable target."; - break; + input.replace(nameStartPos, commaPos - nameStartPos, targetName); } - input.replace(nameStartPos, commaPos - nameStartPos, targetName); lastPos = pos + targetName.size(); } - if (!errorString.empty()) - { - mf->IssueMessage(cmake::FATAL_ERROR, errorString); - return; - } + std::string errorString; pos = 0; lastPos = pos; while((pos = input.find("$> $> $> + # Test that the below is non-fatal + $<$:$> ) set_property(TARGET testLibRequired APPEND PROPERTY From b3a7e19ee479fda18b1dfe237fc4b78467c05fd7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 29 Jan 2013 17:20:45 +0100 Subject: [PATCH 53/94] Make the Property name protected so that subclasses can use it. Makes subclasses more dry in upcoming patches. --- Source/cmTargetPropCommandBase.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 15a78c9a6d..0289c44261 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -31,6 +31,9 @@ public: bool HandleArguments(std::vector const& args, const char *prop, ArgumentFlags flags = NO_FLAGS); +protected: + std::string Property; + private: virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; @@ -51,7 +54,6 @@ private: private: cmTarget *Target; - std::string Property; }; #endif From f6b16d4b0642d26111cddff714b464e22b715482 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 29 Jan 2013 17:43:28 +0100 Subject: [PATCH 54/94] Don't allow targets args in the new target commands. --- Source/cmTargetCompileDefinitionsCommand.cxx | 10 --------- Source/cmTargetCompileDefinitionsCommand.h | 5 ----- Source/cmTargetIncludeDirectoriesCommand.cxx | 20 ----------------- Source/cmTargetIncludeDirectoriesCommand.h | 5 ----- Source/cmTargetPropCommandBase.cxx | 22 +------------------ Source/cmTargetPropCommandBase.h | 5 ----- .../target_compile_definitions/CMakeLists.txt | 2 +- .../target_include_directories/CMakeLists.txt | 2 +- Tests/ExportImport/Import/A/CMakeLists.txt | 19 +++++++++++----- 9 files changed, 16 insertions(+), 74 deletions(-) diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 683eff62a4..312d625f0e 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -37,16 +37,6 @@ void cmTargetCompileDefinitionsCommand this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } -bool cmTargetCompileDefinitionsCommand -::HandleNonTargetArg(std::string &content, - const std::string &sep, - const std::string &entry, - const std::string &) -{ - content += sep + entry; - return true; -} - void cmTargetCompileDefinitionsCommand ::HandleDirectContent(cmTarget *tgt, const std::string &content, bool) diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index d49b9e8ee6..6e8fc84712 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -81,11 +81,6 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual bool HandleNonTargetArg(std::string &content, - const std::string &sep, - const std::string &entry, - const std::string &tgt); - virtual void HandleDirectContent(cmTarget *tgt, const std::string &content, bool prepend); }; diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index aeba4686a1..51a2b6bdc3 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -40,26 +40,6 @@ void cmTargetIncludeDirectoriesCommand this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } -//---------------------------------------------------------------------------- -bool cmTargetIncludeDirectoriesCommand -::HandleNonTargetArg(std::string &content, - const std::string &sep, - const std::string &entry, - const std::string &tgt) -{ - if (!cmSystemTools::FileIsFullPath(entry.c_str())) - { - cmOStringStream e; - e << "Cannot specify relative include directory \"" << entry << "\" for " - "target \"" << tgt << "\". Only absolute paths are permitted"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; - } - - content += sep + entry; - return true; -} - //---------------------------------------------------------------------------- void cmTargetIncludeDirectoriesCommand ::HandleDirectContent(cmTarget *tgt, const std::string &content, diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 5a5f859fd3..a2548783d9 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -85,11 +85,6 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual bool HandleNonTargetArg(std::string &content, - const std::string &sep, - const std::string &entry, - const std::string &tgt); - virtual void HandleDirectContent(cmTarget *tgt, const std::string &content, bool prepend); }; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index e1eb1d2d45..ef404382af 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -65,14 +65,6 @@ bool cmTargetPropCommandBase return true; } -//---------------------------------------------------------------------------- -static bool isGeneratorExpression(const std::string &lib) -{ - const std::string::size_type openpos = lib.find("$<"); - return (openpos != std::string::npos) - && (lib.find(">", openpos) != std::string::npos); -} - //---------------------------------------------------------------------------- bool cmTargetPropCommandBase ::ProcessContentArgs(std::vector const& args, @@ -108,19 +100,7 @@ bool cmTargetPropCommandBase this->PopulateTargetProperies(scope, content, prepend); return true; } - if (this->Makefile->FindTargetToUse(args[i].c_str())) - { - content += sep + "$Property + ">"; - } - else if(isGeneratorExpression(args[i])) - { - content += sep + args[i]; - } - else if (!this->HandleNonTargetArg(content, sep, args[i], args[0])) - { - return false; - } + content += sep + args[i]; sep = ";"; } this->PopulateTargetProperies(scope, content, prepend); diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 0289c44261..cc9897d251 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -38,11 +38,6 @@ private: virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; - virtual bool HandleNonTargetArg(std::string &content, - const std::string &sep, - const std::string &entry, - const std::string &tgt) = 0; - virtual void HandleDirectContent(cmTarget *tgt, const std::string &content, bool prepend) = 0; diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 3eca7fc78a..00cba44f05 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -17,7 +17,7 @@ add_executable(consumer ) target_compile_definitions(consumer - PRIVATE target_compile_definitions importedlib + PRIVATE $ $<$:SHOULD_NOT_BE_DEFINED> $<$:SHOULD_BE_DEFINED> ) diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index e190161d36..89b61f331b 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -43,5 +43,5 @@ add_executable(consumer ) target_include_directories(consumer - PRIVATE target_include_directories + PRIVATE $ ) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 187c48ae0a..e9bd2bac03 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -159,15 +159,18 @@ endif() add_executable(deps_iface deps_iface.c) target_link_libraries(deps_iface testLibDepends) -target_include_directories(deps_iface PRIVATE testLibDepends) -target_compile_definitions(deps_iface PRIVATE testLibDepends) +target_include_directories(deps_iface PRIVATE $) +target_compile_definitions(deps_iface PRIVATE $) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) -target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends) +target_include_directories(deps_shared_iface + PRIVATE + $ +) target_compile_definitions(deps_shared_iface PRIVATE - testSharedLibDepends + $ $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> $<$,testcontent>:CUSTOM_STRING_IS_MATCH> @@ -197,9 +200,13 @@ endif() add_executable(deps_shared_iface2 deps_shared_iface.cpp) target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) -target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends bld_subdirlib) +target_include_directories(deps_shared_iface2 + PRIVATE + $ + $ +) target_compile_definitions(deps_shared_iface2 - PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB + PRIVATE $ TEST_SUBDIR_LIB $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> $<$,testcontent>:CUSTOM_STRING_IS_MATCH> From 7bf490e9bb6128082aa178f28691b3fc418322fe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 29 Jan 2013 17:23:31 +0100 Subject: [PATCH 55/94] Make subclasses responsible for joining content. This way we can add handling of relative/absolute paths and of -D in compile definitions. --- Source/cmTargetCompileDefinitionsCommand.cxx | 27 ++++++++++++-- Source/cmTargetCompileDefinitionsCommand.h | 4 ++- Source/cmTargetIncludeDirectoriesCommand.cxx | 36 +++++++++++++++++-- Source/cmTargetIncludeDirectoriesCommand.h | 4 ++- Source/cmTargetPropCommandBase.cxx | 13 ++++--- Source/cmTargetPropCommandBase.h | 10 +++--- .../target_compile_definitions/CMakeLists.txt | 1 + .../target_compile_definitions/consumer.cpp | 4 +++ .../target_include_directories/CMakeLists.txt | 1 + .../target_include_directories/consumer.cpp | 5 +++ .../relative_dir/relative_dir.h | 2 ++ 11 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 Tests/CMakeCommands/target_include_directories/relative_dir/relative_dir.h diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 312d625f0e..76458338cd 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -37,9 +37,32 @@ void cmTargetCompileDefinitionsCommand this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } +//---------------------------------------------------------------------------- +std::string cmTargetCompileDefinitionsCommand +::Join(const std::vector &content) +{ + std::string defs; + std::string sep; + for(std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + if (strncmp(it->c_str(), "-D", 2) == 0) + { + defs += sep + it->substr(2); + } + else + { + defs += sep + *it; + } + sep = ";"; + } + return defs; +} + +//---------------------------------------------------------------------------- void cmTargetCompileDefinitionsCommand -::HandleDirectContent(cmTarget *tgt, const std::string &content, +::HandleDirectContent(cmTarget *tgt, const std::vector &content, bool) { - tgt->AppendProperty("COMPILE_DEFINITIONS", content.c_str()); + tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str()); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 6e8fc84712..3b438207c4 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -81,8 +81,10 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual void HandleDirectContent(cmTarget *tgt, const std::string &content, + virtual void HandleDirectContent(cmTarget *tgt, + const std::vector &content, bool prepend); + virtual std::string Join(const std::vector &content); }; #endif diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 51a2b6bdc3..eaacfa9e78 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -40,13 +40,45 @@ void cmTargetIncludeDirectoriesCommand this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } +//---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + +//---------------------------------------------------------------------------- +std::string cmTargetIncludeDirectoriesCommand +::Join(const std::vector &content) +{ + std::string dirs; + std::string sep; + std::string prefix = this->Makefile->GetStartDirectory() + std::string("/"); + for(std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + if (cmSystemTools::FileIsFullPath(it->c_str()) + || isGeneratorExpression(*it)) + { + dirs += sep + *it; + } + else + { + dirs += sep + prefix + *it; + } + sep = ";"; + } + return dirs; +} + //---------------------------------------------------------------------------- void cmTargetIncludeDirectoriesCommand -::HandleDirectContent(cmTarget *tgt, const std::string &content, +::HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend) { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); - cmMakefileIncludeDirectoriesEntry entry(content, lfbt); + cmMakefileIncludeDirectoriesEntry entry(this->Join(content), lfbt); tgt->InsertInclude(entry, prepend); } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index a2548783d9..d02cb4a2f1 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -85,8 +85,10 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual void HandleDirectContent(cmTarget *tgt, const std::string &content, + virtual void HandleDirectContent(cmTarget *tgt, + const std::vector &content, bool prepend); + virtual std::string Join(const std::vector &content); }; #endif diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index ef404382af..18a1d2a9f6 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -88,9 +88,8 @@ bool cmTargetPropCommandBase ++argIndex; - std::string content; + std::vector content; - std::string sep; for(unsigned int i=argIndex; i < args.size(); ++i, ++argIndex) { if(args[i] == "PUBLIC" @@ -100,8 +99,7 @@ bool cmTargetPropCommandBase this->PopulateTargetProperies(scope, content, prepend); return true; } - content += sep + args[i]; - sep = ";"; + content.push_back(args[i]); } this->PopulateTargetProperies(scope, content, prepend); return true; @@ -110,7 +108,8 @@ bool cmTargetPropCommandBase //---------------------------------------------------------------------------- void cmTargetPropCommandBase ::PopulateTargetProperies(const std::string &scope, - const std::string &content, bool prepend) + const std::vector &content, + bool prepend) { if (scope == "PRIVATE" || scope == "PUBLIC") { @@ -122,7 +121,7 @@ void cmTargetPropCommandBase { const std::string propName = std::string("INTERFACE_") + this->Property; const char *propValue = this->Target->GetProperty(propName.c_str()); - const std::string totalContent = content + (propValue + const std::string totalContent = this->Join(content) + (propValue ? std::string(";") + propValue : std::string()); this->Target->SetProperty(propName.c_str(), totalContent.c_str()); @@ -130,7 +129,7 @@ void cmTargetPropCommandBase else { this->Target->AppendProperty(("INTERFACE_" + this->Property).c_str(), - content.c_str()); + this->Join(content).c_str()); } } } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index cc9897d251..a5b4ff8235 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -33,22 +33,22 @@ public: protected: std::string Property; + cmTarget *Target; private: virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; virtual void HandleDirectContent(cmTarget *tgt, - const std::string &content, + const std::vector &content, bool prepend) = 0; + virtual std::string Join(const std::vector &content) = 0; bool ProcessContentArgs(std::vector const& args, unsigned int &argIndex, bool prepend); void PopulateTargetProperies(const std::string &scope, - const std::string &content, bool prepend); - -private: - cmTarget *Target; + const std::vector &content, + bool prepend); }; #endif diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 00cba44f05..8a4437ba54 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -20,4 +20,5 @@ target_compile_definitions(consumer PRIVATE $ $<$:SHOULD_NOT_BE_DEFINED> $<$:SHOULD_BE_DEFINED> + -DDASH_D_DEFINE ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index f835b6cf5c..1a46aa50cf 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -19,4 +19,8 @@ #error Expected SHOULD_BE_DEFINED #endif +#ifndef DASH_D_DEFINE +#error Expected DASH_D_DEFINE +#endif + int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 89b61f331b..7529283783 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -44,4 +44,5 @@ add_executable(consumer target_include_directories(consumer PRIVATE $ + relative_dir ) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 5d88488b56..82b800a40a 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "publicinclude.h" #include "interfaceinclude.h" +#include "relative_dir.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -19,4 +20,8 @@ #error Expected CURE_DEFINE #endif +#ifndef RELATIVE_DIR_DEFINE +#error Expected RELATIVE_DIR_DEFINE +#endif + int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/relative_dir/relative_dir.h b/Tests/CMakeCommands/target_include_directories/relative_dir/relative_dir.h new file mode 100644 index 0000000000..7017b61a89 --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/relative_dir/relative_dir.h @@ -0,0 +1,2 @@ + +#define RELATIVE_DIR_DEFINE From 0e10782ba795050e1ea82530d79c323f60478df4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Dec 2012 03:40:49 +0100 Subject: [PATCH 56/94] Move GetCompileDefinitions to cmTarget. --- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 29 ---------------------- Source/cmGeneratorTarget.h | 2 -- Source/cmGlobalXCodeGenerator.cxx | 4 +-- Source/cmLocalVisualStudio6Generator.cxx | 14 ++++------- Source/cmLocalVisualStudio7Generator.cxx | 4 +-- Source/cmMakefileTargetGenerator.cxx | 4 +-- Source/cmNinjaTargetGenerator.cxx | 4 +-- Source/cmTarget.cxx | 29 ++++++++++++++++++++++ Source/cmTarget.h | 2 ++ Source/cmVisualStudio10TargetGenerator.cxx | 4 +-- 11 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 0cf9cbbf27..6d5d5b5f60 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -621,7 +621,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, ->GetGeneratorTarget(target); // the compilerdefines for this target - std::string cdefs = gtgt->GetCompileDefinitions(); + std::string cdefs = target->GetCompileDefinitions(); if(!cdefs.empty()) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 62ee26a22b..335ba0f25f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -254,32 +254,3 @@ std::vector cmGeneratorTarget::GetIncludeDirectories( { return this->Target->GetIncludeDirectories(config); } - -//---------------------------------------------------------------------------- -std::string cmGeneratorTarget::GetCompileDefinitions(const char *config) -{ - std::string defPropName = "COMPILE_DEFINITIONS"; - if (config) - { - defPropName += "_" + cmSystemTools::UpperCase(config); - } - - const char *prop = this->Target->GetProperty(defPropName.c_str()); - - if (!prop) - { - return ""; - } - - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - defPropName, 0, 0); - return ge.Parse(prop)->Evaluate(this->Makefile, - config, - false, - this->Target, - &dagChecker); -} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6f5ecb7e9f..cbcd8a5790 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -68,8 +68,6 @@ public: /** Get the include directories for this target. */ std::vector GetIncludeDirectories(const char *config); - std::string GetCompileDefinitions(const char *config = 0); - private: void ClassifySources(); void LookupObjectLibraries(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0681ce53a7..abe60c66d1 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1681,11 +1681,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - this->AppendDefines(ppDefs, gtgt->GetCompileDefinitions().c_str()); + this->AppendDefines(ppDefs, target.GetCompileDefinitions().c_str()); if(configName) { this->AppendDefines(ppDefs, - gtgt->GetCompileDefinitions(configName).c_str()); + target.GetCompileDefinitions(configName).c_str()); } buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 6c78ac47ee..617eb4ea9a 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1697,25 +1697,21 @@ void cmLocalVisualStudio6Generator std::set minsizeDefinesSet; std::set debugrelDefinesSet; - - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); - this->AppendDefines( definesSet, - gt->GetCompileDefinitions()); + target.GetCompileDefinitions()); this->AppendDefines( debugDefinesSet, - gt->GetCompileDefinitions("DEBUG")); + target.GetCompileDefinitions("DEBUG")); this->AppendDefines( releaseDefinesSet, - gt->GetCompileDefinitions("RELEASE")); + target.GetCompileDefinitions("RELEASE")); this->AppendDefines( minsizeDefinesSet, - gt->GetCompileDefinitions("MINSIZEREL")); + target.GetCompileDefinitions("MINSIZEREL")); this->AppendDefines( debugrelDefinesSet, - gt->GetCompileDefinitions("RELWITHDEBINFO")); + target.GetCompileDefinitions("RELWITHDEBINFO")); std::string defines = " "; std::string debugDefines = " "; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 918b21e4d9..f9df8616a3 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -745,8 +745,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.ParseFinish(); cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); - targetOptions.AddDefines(gt->GetCompileDefinitions().c_str()); - targetOptions.AddDefines(gt->GetCompileDefinitions(configName).c_str()); + targetOptions.AddDefines(target.GetCompileDefinitions().c_str()); + targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str()); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 64fcfcefa3..d9aa7fed9b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -303,10 +303,10 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AppendDefines - (defines, this->GeneratorTarget->GetCompileDefinitions()); + (defines, this->Target->GetCompileDefinitions()); this->LocalGenerator->AppendDefines - (defines, this->GeneratorTarget->GetCompileDefinitions( + (defines, this->Target->GetCompileDefinitions( this->LocalGenerator->ConfigurationName.c_str())); std::string definesString; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0f484da4cf..f8e4399819 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -228,7 +228,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AppendDefines (defines, - this->GeneratorTarget->GetCompileDefinitions()); + this->Target->GetCompileDefinitions()); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); @@ -237,7 +237,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language) defPropName += cmSystemTools::UpperCase(this->GetConfigName()); this->LocalGenerator->AppendDefines (defines, - this->GeneratorTarget->GetCompileDefinitions(this->GetConfigName())); + this->Target->GetCompileDefinitions(this->GetConfigName())); this->LocalGenerator->AppendDefines (defines, source->GetProperty(defPropName.c_str())); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2b912f3fca..9fd2d1380a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2803,6 +2803,35 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) return includes; } +//---------------------------------------------------------------------------- +std::string cmTarget::GetCompileDefinitions(const char *config) +{ + std::string defPropName = "COMPILE_DEFINITIONS"; + if (config) + { + defPropName += "_" + cmSystemTools::UpperCase(config); + } + + const char *prop = this->GetProperty(defPropName.c_str()); + + if (!prop) + { + return ""; + } + + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + defPropName, 0, 0); + return ge.Parse(prop)->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker); +} + //---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const char* prop) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9909bae600..11dfdf798d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -430,6 +430,8 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro(); + std::string GetCompileDefinitions(const char *config = 0); + // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2596d73405..171ed9a7ca 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1221,8 +1221,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); clOptions.AddDefines( - this->GeneratorTarget->GetCompileDefinitions().c_str()); - clOptions.AddDefines(this->GeneratorTarget->GetCompileDefinitions( + this->Target->GetCompileDefinitions().c_str()); + clOptions.AddDefines(this->Target->GetCompileDefinitions( configName.c_str()).c_str()); clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); From 429e369974015640d7a0878d986e3e418b42b7a4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 25 Jan 2013 14:03:17 +0100 Subject: [PATCH 57/94] Process COMPILE_DEFINITIONS as generator expressions in QtAutomoc. Fixes #13493. --- Source/cmQtAutomoc.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index bf034cf448..cc421751e1 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -229,7 +229,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } const char* tmp = target->GetProperty("COMPILE_DEFINITIONS"); - std::string _moc_compile_defs = (tmp!=0 ? tmp : ""); + std::string _moc_compile_defs; + if (tmp) + { + _moc_compile_defs = target->GetCompileDefinitions(); + } tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); if (tmp) { From bcd25808ac540d279a36a9e0f1b60f152fc0d6bb Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Jan 2013 16:30:30 -0500 Subject: [PATCH 58/94] ExternalData: Improve series matching using an explicit syntax Automatic series recognition can generate false positives too easily when the default series configuration is flexible enough to handle common cases. Avoid false positives by requiring an explicit syntax to activate series recognition. Choose the syntax DATA{,:} to be short, simple, and look like a vertical ellipsis. This allows us to improve the default series match configuration. Allow series references to contain one of the numbered file names. Allow '-' as a separator in addition to '.' and '_'. Document what the default configuration matches. Also provide more options to configure series parsing. --- Modules/ExternalData.cmake | 82 +++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index d678cf2faf..0ef514c1f6 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -66,18 +66,26 @@ # the source tree contains a content link such as "MyInput.png.md5" then the # "MyData" target creates a real "MyInput.png" in the build tree. # -# The DATA{} syntax can automatically recognize and fetch a file series. If -# the source tree contains a group of files or content links named like a -# series then a DATA{} reference to one member adds rules to fetch all of -# them. Although all members of a series are fetched, only the file -# originally named by the DATA{} argument is substituted for it. Two -# variables configure recognition of a series from DATA{}. First, -# ExternalData_SERIES_PARSE is a regex of the form "^(...)(...)(...)$" to -# parse , , and parts from . Second, -# ExternalData_SERIES_MATCH is a regex matching the part of series -# members named . Note that the of a series -# does not include a hash-algorithm extension. Both series configuration -# variables have default values that work well for common cases. +# The DATA{} syntax can be told to fetch a file series using the form +# "DATA{,:}", where the ":" is literal. If the source tree contains a +# group of files or content links named like a series then a reference to one +# member adds rules to fetch all of them. Although all members of a series +# are fetched, only the file originally named by the DATA{} argument is +# substituted for it. The default configuration recognizes file series names +# ending with "#.ext", "_#.ext", ".#.ext", or "-#.ext" where "#" is a sequence +# of decimal digits and ".ext" is any single extension. Configure it with a +# regex that parses and parts from the end of : +# ExternalData_SERIES_PARSE = regex of the form ()()$ +# For more complicated cases set: +# ExternalData_SERIES_PARSE = regex with at least two () groups +# ExternalData_SERIES_PARSE_PREFIX = regex group number, if any +# ExternalData_SERIES_PARSE_NUMBER = regex group number +# ExternalData_SERIES_PARSE_SUFFIX = regex group number +# Configure series number matching with a regex that matches the +# part of series members named : +# ExternalData_SERIES_MATCH = regex matching in all series members +# Note that the of a series does not include a hash-algorithm +# extension. # # The DATA{} syntax can alternatively match files associated with the named # file and contained in the same directory. Associated files may be specified @@ -349,6 +357,7 @@ function(_ExternalData_arg target arg options var_file) set(have_original 0) # Process options. + set(series_option "") set(associated_files "") set(associated_regex "") foreach(opt ${options}) @@ -356,6 +365,9 @@ function(_ExternalData_arg target arg options var_file) # Regular expression to match associated files. string(REGEX REPLACE "^REGEX:" "" regex "${opt}") list(APPEND associated_regex "${regex}") + elseif("x${opt}" MATCHES "^x:$") + # Activate series matching. + set(series_option "${opt}") elseif("x${opt}" MATCHES "^[^][:/*?]+$") # Specific associated file. list(APPEND associated_files "${opt}") @@ -365,16 +377,19 @@ function(_ExternalData_arg target arg options var_file) endif() endforeach() - if(associated_files OR associated_regex) - # Load the named data file and listed/matching associated files. - _ExternalData_arg_single() - _ExternalData_arg_associated() - elseif("${reldata}" MATCHES "(^|/)[^/.]+$") - # Files with no extension cannot be a series. - _ExternalData_arg_single() - else() - # Match a whole file series by default. + if(series_option) + if(associated_files OR associated_regex) + message(FATAL_ERROR "Series option \"${series_option}\" not allowed with associated files.") + endif() + # Load a whole file series. _ExternalData_arg_series() + else() + # Load the named data file. + _ExternalData_arg_single() + if(associated_files OR associated_regex) + # Load listed/matching associated files. + _ExternalData_arg_associated() + endif() endif() if(NOT have_original) @@ -430,27 +445,40 @@ endmacro() macro(_ExternalData_arg_series) # Configure series parsing and matching. + set(series_parse_prefix "") + set(series_parse_number "\\1") + set(series_parse_suffix "\\2") if(ExternalData_SERIES_PARSE) - if(NOT "${ExternalData_SERIES_PARSE}" MATCHES - "^\\^\\([^()]*\\)\\([^()]*\\)\\([^()]*\\)\\$$") + if(ExternalData_SERIES_PARSE_NUMBER AND ExternalData_SERIES_PARSE_SUFFIX) + if(ExternalData_SERIES_PARSE_PREFIX) + set(series_parse_prefix "\\${ExternalData_SERIES_PARSE_PREFIX}") + endif() + set(series_parse_number "\\${ExternalData_SERIES_PARSE_NUMBER}") + set(series_parse_suffix "\\${ExternalData_SERIES_PARSE_SUFFIX}") + elseif(NOT "x${ExternalData_SERIES_PARSE}" MATCHES "^x\\([^()]*\\)\\([^()]*\\)\\$$") message(FATAL_ERROR "ExternalData_SERIES_PARSE is set to\n" " ${ExternalData_SERIES_PARSE}\n" "which is not of the form\n" - " ^(...)(...)(...)$\n") + " ()()$\n" + "Fix the regular expression or set variables\n" + " ExternalData_SERIES_PARSE_PREFIX = regex group number, if any\n" + " ExternalData_SERIES_PARSE_NUMBER = regex group number\n" + " ExternalData_SERIES_PARSE_SUFFIX = regex group number\n" + ) endif() set(series_parse "${ExternalData_SERIES_PARSE}") else() - set(series_parse "^(.*)()(\\.[^./]*)$") + set(series_parse "([0-9]*)(\\.[^./]*)$") endif() if(ExternalData_SERIES_MATCH) set(series_match "${ExternalData_SERIES_MATCH}") else() - set(series_match "[_.]?[0-9]*") + set(series_match "[_.-]?[0-9]*") endif() # Parse the base, number, and extension components of the series. - string(REGEX REPLACE "${series_parse}" "\\1;\\2;\\3" tuple "${reldata}") + string(REGEX REPLACE "${series_parse}" "${series_parse_prefix};${series_parse_number};${series_parse_suffix}" tuple "${reldata}") list(LENGTH tuple len) if(NOT "${len}" EQUAL 3) message(FATAL_ERROR "Data file referenced by argument\n" From 7462a8a8c3417e559e54d6de7eef837e2adfd2e6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 30 Jan 2013 00:01:21 -0500 Subject: [PATCH 59/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 608c269eeb..2010f63d01 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130129) +set(CMake_VERSION_TWEAK 20130130) #set(CMake_VERSION_RC 1) From 4befecc77caa97aeb450d9a2b6bcbe0985dc4054 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Jan 2013 16:39:57 -0500 Subject: [PATCH 60/94] ExternalData: Add tests covering interfaces and errors Add a Module.ExternalData test to verify data retrieval and test argument DATA{} references. Add a RunCMake.ExternalData test to verify error handling and automatic transformation of a raw data to a content link and staged object. --- Tests/CMakeLists.txt | 12 ++++++ Tests/Module/ExternalData/CMakeLists.txt | 32 +++++++++++++++ Tests/Module/ExternalData/Data.dat.md5 | 1 + Tests/Module/ExternalData/Data1Check.cmake | 40 +++++++++++++++++++ Tests/Module/ExternalData/Data2.dat.md5 | 1 + .../Module/ExternalData/Data2/CMakeLists.txt | 10 +++++ .../ExternalData/Data2/Data2Check.cmake | 9 +++++ .../ExternalData/Data2/SeriesC_1_.my.dat.md5 | 1 + .../ExternalData/Data2/SeriesC_2_.my.dat.md5 | 1 + .../ExternalData/Data2/SeriesC_3_.my.dat.md5 | 1 + .../Module/ExternalData/Data3/CMakeLists.txt | 14 +++++++ Tests/Module/ExternalData/Data3/Data.dat.md5 | 1 + .../ExternalData/Data3/Data3Check.cmake | 25 ++++++++++++ Tests/Module/ExternalData/Data3/Other.dat.md5 | 1 + Tests/Module/ExternalData/MD5/.gitattributes | 1 + .../MD5/08cfcf221f76ace7b906b312284e73d7 | 1 + .../MD5/30ba0acdee9096b3b9fc6c69362c6b42 | 1 + .../MD5/31eff09e84fca01415f8cd9d82ec432b | 1 + .../MD5/401767f22a456b3522953722090a2c36 | 1 + .../MD5/8c018830e3efa5caf3c7415028335a57 | 1 + .../MD5/8f4add4581551facf27237e6577fd662 | 1 + .../MD5/9d980b06c2f0fec3d4872d68175b9822 | 1 + .../MD5/aaad162b85f60d1eb57ca71a23e8efd7 | 1 + .../MD5/c1030719c95f3435d8abc39c0d442946 | 1 + .../MD5/ecfa1ecd417d4253af81ae04d1bd6581 | 1 + .../MD5/f41c94425d01ecbbee70440b951cb058 | 1 + .../MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7 | 1 + Tests/Module/ExternalData/MetaA.dat.md5 | 1 + Tests/Module/ExternalData/MetaB.dat.md5 | 1 + Tests/Module/ExternalData/MetaC.dat.md5 | 1 + Tests/Module/ExternalData/MetaTop.dat.md5 | 1 + Tests/Module/ExternalData/PairedA.dat.md5 | 1 + Tests/Module/ExternalData/PairedB.dat.md5 | 1 + Tests/Module/ExternalData/SeriesA.dat.md5 | 1 + Tests/Module/ExternalData/SeriesA1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesA2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesA3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesAn1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesAn2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesAn3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesB.dat.md5 | 1 + Tests/Module/ExternalData/SeriesB_1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesB_2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesB_3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesBn_1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesBn_2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesBn_3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesC.1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesC.2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesC.3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesC.dat.md5 | 1 + Tests/Module/ExternalData/SeriesCn.1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesCn.2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesCn.3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesD-1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesD-2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesD-3.dat.md5 | 1 + Tests/Module/ExternalData/SeriesD.dat.md5 | 1 + Tests/Module/ExternalData/SeriesDn-1.dat.md5 | 1 + Tests/Module/ExternalData/SeriesDn-2.dat.md5 | 1 + Tests/Module/ExternalData/SeriesDn-3.dat.md5 | 1 + Tests/RunCMake/CMakeLists.txt | 1 + .../ExternalData/BadHashAlgo1-result.txt | 1 + .../ExternalData/BadHashAlgo1-stderr.txt | 8 ++++ .../RunCMake/ExternalData/BadHashAlgo1.cmake | 3 ++ Tests/RunCMake/ExternalData/BadHashAlgo1.txt | 1 + .../ExternalData/BadOption1-result.txt | 1 + .../ExternalData/BadOption1-stderr.txt | 9 +++++ Tests/RunCMake/ExternalData/BadOption1.cmake | 5 +++ .../ExternalData/BadOption2-result.txt | 1 + .../ExternalData/BadOption2-stderr.txt | 9 +++++ Tests/RunCMake/ExternalData/BadOption2.cmake | 5 +++ .../ExternalData/BadSeries1-result.txt | 1 + .../ExternalData/BadSeries1-stderr.txt | 19 +++++++++ Tests/RunCMake/ExternalData/BadSeries1.cmake | 3 ++ .../ExternalData/BadSeries2-result.txt | 1 + .../ExternalData/BadSeries2-stderr.txt | 16 ++++++++ Tests/RunCMake/ExternalData/BadSeries2.cmake | 3 ++ .../ExternalData/BadSeries3-result.txt | 1 + .../ExternalData/BadSeries3-stderr.txt | 6 +++ Tests/RunCMake/ExternalData/BadSeries3.cmake | 2 + Tests/RunCMake/ExternalData/CMakeLists.txt | 3 ++ Tests/RunCMake/ExternalData/Data.txt.md5 | 1 + .../ExternalData/Directory1-result.txt | 1 + .../ExternalData/Directory1-stderr.txt | 14 +++++++ Tests/RunCMake/ExternalData/Directory1.cmake | 6 +++ .../ExternalData/Directory1/DirData1.txt | 0 .../ExternalData/Directory2-result.txt | 1 + .../ExternalData/Directory2-stderr.txt | 10 +++++ Tests/RunCMake/ExternalData/Directory2.cmake | 6 +++ Tests/RunCMake/ExternalData/Directory2.md5 | 1 + .../ExternalData/Directory2/DirData2.txt | 0 .../ExternalData/Directory3-result.txt | 1 + .../ExternalData/Directory3-stderr.txt | 14 +++++++ Tests/RunCMake/ExternalData/Directory3.cmake | 6 +++ .../ExternalData/Directory3/DirData3.txt | 0 .../ExternalData/LinkContentMD5-stdout.txt | 3 ++ .../ExternalData/LinkContentMD5.cmake | 22 ++++++++++ .../ExternalData/MissingData-result.txt | 1 + .../ExternalData/MissingData-stderr.txt | 14 +++++++ Tests/RunCMake/ExternalData/MissingData.cmake | 5 +++ .../ExternalData/NoLinkInSource-stderr.txt | 6 +++ .../ExternalData/NoLinkInSource-stdout.txt | 1 + .../ExternalData/NoLinkInSource.cmake | 14 +++++++ .../ExternalData/NoURLTemplates-result.txt | 1 + .../ExternalData/NoURLTemplates-stderr.txt | 5 +++ .../ExternalData/NoURLTemplates.cmake | 2 + .../ExternalData/NormalData1-stdout.txt | 1 + Tests/RunCMake/ExternalData/NormalData1.cmake | 13 ++++++ .../ExternalData/NormalData2-stdout.txt | 1 + Tests/RunCMake/ExternalData/NormalData2.cmake | 14 +++++++ .../ExternalData/NormalData3-stdout.txt | 1 + Tests/RunCMake/ExternalData/NormalData3.cmake | 14 +++++++ .../ExternalData/NormalDataSub1-stdout.txt | 1 + .../ExternalData/NormalDataSub1.cmake | 13 ++++++ .../ExternalData/NotUnderRoot-result.txt | 1 + .../ExternalData/NotUnderRoot-stderr.txt | 12 ++++++ .../RunCMake/ExternalData/NotUnderRoot.cmake | 5 +++ .../RunCMake/ExternalData/RunCMakeTest.cmake | 21 ++++++++++ .../ExternalData/SubDirectory1-stdout.txt | 2 + .../RunCMake/ExternalData/SubDirectory1.cmake | 5 +++ .../ExternalData/SubDirectory1/CMakeLists.txt | 19 +++++++++ .../ExternalData/SubDirectory1/Data.txt.md5 | 1 + 123 files changed, 554 insertions(+) create mode 100644 Tests/Module/ExternalData/CMakeLists.txt create mode 100644 Tests/Module/ExternalData/Data.dat.md5 create mode 100644 Tests/Module/ExternalData/Data1Check.cmake create mode 100644 Tests/Module/ExternalData/Data2.dat.md5 create mode 100644 Tests/Module/ExternalData/Data2/CMakeLists.txt create mode 100644 Tests/Module/ExternalData/Data2/Data2Check.cmake create mode 100644 Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5 create mode 100644 Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5 create mode 100644 Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5 create mode 100644 Tests/Module/ExternalData/Data3/CMakeLists.txt create mode 100644 Tests/Module/ExternalData/Data3/Data.dat.md5 create mode 100644 Tests/Module/ExternalData/Data3/Data3Check.cmake create mode 100644 Tests/Module/ExternalData/Data3/Other.dat.md5 create mode 100644 Tests/Module/ExternalData/MD5/.gitattributes create mode 100644 Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7 create mode 100644 Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42 create mode 100644 Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b create mode 100644 Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36 create mode 100644 Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57 create mode 100644 Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662 create mode 100644 Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822 create mode 100644 Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7 create mode 100644 Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946 create mode 100644 Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581 create mode 100644 Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058 create mode 100644 Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7 create mode 100644 Tests/Module/ExternalData/MetaA.dat.md5 create mode 100644 Tests/Module/ExternalData/MetaB.dat.md5 create mode 100644 Tests/Module/ExternalData/MetaC.dat.md5 create mode 100644 Tests/Module/ExternalData/MetaTop.dat.md5 create mode 100644 Tests/Module/ExternalData/PairedA.dat.md5 create mode 100644 Tests/Module/ExternalData/PairedB.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesA.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesA1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesA2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesA3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesAn1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesAn2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesAn3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesB.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesB_1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesB_2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesB_3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesBn_1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesBn_2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesBn_3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesC.1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesC.2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesC.3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesC.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesCn.1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesCn.2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesCn.3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesD-1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesD-2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesD-3.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesD.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesDn-1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesDn-2.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesDn-3.dat.md5 create mode 100644 Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt create mode 100644 Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/BadHashAlgo1.cmake create mode 100644 Tests/RunCMake/ExternalData/BadHashAlgo1.txt create mode 100644 Tests/RunCMake/ExternalData/BadOption1-result.txt create mode 100644 Tests/RunCMake/ExternalData/BadOption1-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/BadOption1.cmake create mode 100644 Tests/RunCMake/ExternalData/BadOption2-result.txt create mode 100644 Tests/RunCMake/ExternalData/BadOption2-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/BadOption2.cmake create mode 100644 Tests/RunCMake/ExternalData/BadSeries1-result.txt create mode 100644 Tests/RunCMake/ExternalData/BadSeries1-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/BadSeries1.cmake create mode 100644 Tests/RunCMake/ExternalData/BadSeries2-result.txt create mode 100644 Tests/RunCMake/ExternalData/BadSeries2-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/BadSeries2.cmake create mode 100644 Tests/RunCMake/ExternalData/BadSeries3-result.txt create mode 100644 Tests/RunCMake/ExternalData/BadSeries3-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/BadSeries3.cmake create mode 100644 Tests/RunCMake/ExternalData/CMakeLists.txt create mode 100644 Tests/RunCMake/ExternalData/Data.txt.md5 create mode 100644 Tests/RunCMake/ExternalData/Directory1-result.txt create mode 100644 Tests/RunCMake/ExternalData/Directory1-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/Directory1.cmake create mode 100644 Tests/RunCMake/ExternalData/Directory1/DirData1.txt create mode 100644 Tests/RunCMake/ExternalData/Directory2-result.txt create mode 100644 Tests/RunCMake/ExternalData/Directory2-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/Directory2.cmake create mode 100644 Tests/RunCMake/ExternalData/Directory2.md5 create mode 100644 Tests/RunCMake/ExternalData/Directory2/DirData2.txt create mode 100644 Tests/RunCMake/ExternalData/Directory3-result.txt create mode 100644 Tests/RunCMake/ExternalData/Directory3-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/Directory3.cmake create mode 100644 Tests/RunCMake/ExternalData/Directory3/DirData3.txt create mode 100644 Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/LinkContentMD5.cmake create mode 100644 Tests/RunCMake/ExternalData/MissingData-result.txt create mode 100644 Tests/RunCMake/ExternalData/MissingData-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/MissingData.cmake create mode 100644 Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/NoLinkInSource.cmake create mode 100644 Tests/RunCMake/ExternalData/NoURLTemplates-result.txt create mode 100644 Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/NoURLTemplates.cmake create mode 100644 Tests/RunCMake/ExternalData/NormalData1-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/NormalData1.cmake create mode 100644 Tests/RunCMake/ExternalData/NormalData2-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/NormalData2.cmake create mode 100644 Tests/RunCMake/ExternalData/NormalData3-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/NormalData3.cmake create mode 100644 Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/NormalDataSub1.cmake create mode 100644 Tests/RunCMake/ExternalData/NotUnderRoot-result.txt create mode 100644 Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/NotUnderRoot.cmake create mode 100644 Tests/RunCMake/ExternalData/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/SubDirectory1.cmake create mode 100644 Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt create mode 100644 Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5 diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0c75892384..c21922e65c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -312,6 +312,18 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) + add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Module/ExternalData" + "${CMake_BINARY_DIR}/Tests/Module/ExternalData" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project ExternalDataTest + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData") + ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt new file mode 100644 index 0000000000..55326100d5 --- /dev/null +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 2.8.10.20130115) +project(ExternalDataTest NONE) + +include(CTest) + +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(ExternalData_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ExternalData") +file(REMOVE_RECURSE ${ExternalData_BINARY_ROOT}) # clean test + +ExternalData_Add_Test(Data1 + NAME Data1Check + COMMAND ${CMAKE_COMMAND} + -D Data=DATA{Data.dat} + -D SeriesA=DATA{SeriesA.dat,:} + -D SeriesB=DATA{SeriesB.dat,:} + -D SeriesC=DATA{SeriesC.dat,:} + -D SeriesD=DATA{SeriesD.dat,:} + -D SeriesAn=DATA{SeriesAn1.dat,:} + -D SeriesBn=DATA{SeriesBn_1.dat,:} + -D SeriesCn=DATA{SeriesCn.1.dat,:} + -D SeriesDn=DATA{SeriesDn-1.dat,:} + -D Paired=DATA{PairedA.dat,PairedB.dat} + -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} + -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake + ) +ExternalData_Add_Target(Data1) + +add_subdirectory(Data2) +add_subdirectory(Data3) diff --git a/Tests/Module/ExternalData/Data.dat.md5 b/Tests/Module/ExternalData/Data.dat.md5 new file mode 100644 index 0000000000..70e39bd5d1 --- /dev/null +++ b/Tests/Module/ExternalData/Data.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake new file mode 100644 index 0000000000..fd18cdf5fd --- /dev/null +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -0,0 +1,40 @@ +file(STRINGS "${Data}" lines LIMIT_INPUT 1024) +if(NOT "x${lines}" STREQUAL "xInput file already transformed.") + message(SEND_ERROR "Input file:\n ${Data}\ndoes not have expected content, but [[${lines}]]") +endif() +set(SeriesAn1 "1\\.dat") +set(SeriesBn1 "_1\\.dat") +set(SeriesCn1 "\\.1\\.dat") +set(SeriesDn1 "-1\\.dat") +set(SeriesAl 1 2 3) +set(SeriesBl _1 _2 _3) +set(SeriesCl .1 .2 .3) +set(SeriesDl -1 -2 -3) +foreach(s A B C D) + foreach(n "" ${Series${s}l}) + string(REGEX REPLACE "\\.dat$" "${n}.dat" file "${Series${s}}") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() + endforeach() +endforeach() +foreach(s A B C D) + foreach(n ${Series${s}l}) + string(REGEX REPLACE "${Series${s}n1}$" "${n}.dat" file "${Series${s}n}") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() + endforeach() +endforeach() +foreach(n A B) + string(REGEX REPLACE "A\\.dat$" "${n}.dat" file "${Paired}") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() +endforeach() +foreach(n Top A B C) + string(REGEX REPLACE "Top\\.dat$" "${n}.dat" file "${Meta}") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() +endforeach() diff --git a/Tests/Module/ExternalData/Data2.dat.md5 b/Tests/Module/ExternalData/Data2.dat.md5 new file mode 100644 index 0000000000..70e39bd5d1 --- /dev/null +++ b/Tests/Module/ExternalData/Data2.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/Module/ExternalData/Data2/CMakeLists.txt b/Tests/Module/ExternalData/Data2/CMakeLists.txt new file mode 100644 index 0000000000..f8eedff642 --- /dev/null +++ b/Tests/Module/ExternalData/Data2/CMakeLists.txt @@ -0,0 +1,10 @@ +set(ExternalData_SERIES_PARSE "([0-9]+)(_\\.my\\.dat)$") +set(ExternalData_SERIES_MATCH "[0-9]+") +ExternalData_Add_Test(Data2 + NAME Data2Check + COMMAND ${CMAKE_COMMAND} + -D Data2=DATA{../Data2.dat} + -D SeriesC=DATA{SeriesC_1_.my.dat,:} + -P ${CMAKE_CURRENT_SOURCE_DIR}/Data2Check.cmake + ) +ExternalData_Add_Target(Data2) diff --git a/Tests/Module/ExternalData/Data2/Data2Check.cmake b/Tests/Module/ExternalData/Data2/Data2Check.cmake new file mode 100644 index 0000000000..a1dd5091d1 --- /dev/null +++ b/Tests/Module/ExternalData/Data2/Data2Check.cmake @@ -0,0 +1,9 @@ +if(NOT EXISTS "${Data2}") + message(SEND_ERROR "Input file:\n ${Data2}\ndoes not exist!") +endif() +foreach(n 1 2 3) + string(REGEX REPLACE "_1_\\.my\\.dat$" "_${n}_.my.dat" SeriesCFile "${SeriesC}") + if(NOT EXISTS "${SeriesCFile}") + message(SEND_ERROR "Input file:\n ${SeriesCFile}\ndoes not exist!") + endif() +endforeach() diff --git a/Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5 b/Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/Data2/SeriesC_1_.my.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5 b/Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/Data2/SeriesC_2_.my.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5 b/Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/Data2/SeriesC_3_.my.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/Data3/CMakeLists.txt b/Tests/Module/ExternalData/Data3/CMakeLists.txt new file mode 100644 index 0000000000..a7c2b6e068 --- /dev/null +++ b/Tests/Module/ExternalData/Data3/CMakeLists.txt @@ -0,0 +1,14 @@ +set(Store0 ${CMAKE_BINARY_DIR}/ExternalData/Other) +set(Store1 ${CMAKE_BINARY_DIR}/ExternalData/Objects) +set(ExternalData_OBJECT_STORES ${Store0} ${Store1}) +ExternalData_Add_Test(Data3 + NAME Data3Check + COMMAND ${CMAKE_COMMAND} + -D Data=DATA{Data.dat} + -D Other=DATA{Other.dat} + -D Store0=${Store0} + -D Store1=${Store1} + -P ${CMAKE_CURRENT_SOURCE_DIR}/Data3Check.cmake + ) +ExternalData_Add_Target(Data3) +add_dependencies(Data3 Data1 Data2) diff --git a/Tests/Module/ExternalData/Data3/Data.dat.md5 b/Tests/Module/ExternalData/Data3/Data.dat.md5 new file mode 100644 index 0000000000..70e39bd5d1 --- /dev/null +++ b/Tests/Module/ExternalData/Data3/Data.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/Module/ExternalData/Data3/Data3Check.cmake b/Tests/Module/ExternalData/Data3/Data3Check.cmake new file mode 100644 index 0000000000..de9883948d --- /dev/null +++ b/Tests/Module/ExternalData/Data3/Data3Check.cmake @@ -0,0 +1,25 @@ +if(NOT EXISTS "${Data}") + message(SEND_ERROR "Input file:\n ${Data}\ndoes not exist!") +endif() +if(NOT EXISTS "${Other}") + message(SEND_ERROR "Input file:\n ${Other}\ndoes not exist!") +endif() +# Verify that the 'Data' object was found in the second store location left +# from Data1 target downloads and that the 'Other' object was downloaded to +# our first store location. Neither object should exist in the other store. +foreach(should_exist + "${Store0}/MD5/aaad162b85f60d1eb57ca71a23e8efd7" + "${Store1}/MD5/8c018830e3efa5caf3c7415028335a57" + ) + if(NOT EXISTS ${should_exist}) + message(SEND_ERROR "Store file:\n ${should_exist}\nshould exist!") + endif() +endforeach() +foreach(should_not_exist + "${Store0}/MD5/8c018830e3efa5caf3c7415028335a57" + "${Store1}/MD5/aaad162b85f60d1eb57ca71a23e8efd7" + ) + if(EXISTS ${should_not_exist}) + message(SEND_ERROR "Store file:\n ${should_not_exist}\nshould not exist!") + endif() +endforeach() diff --git a/Tests/Module/ExternalData/Data3/Other.dat.md5 b/Tests/Module/ExternalData/Data3/Other.dat.md5 new file mode 100644 index 0000000000..5312faac0a --- /dev/null +++ b/Tests/Module/ExternalData/Data3/Other.dat.md5 @@ -0,0 +1 @@ +aaad162b85f60d1eb57ca71a23e8efd7 diff --git a/Tests/Module/ExternalData/MD5/.gitattributes b/Tests/Module/ExternalData/MD5/.gitattributes new file mode 100644 index 0000000000..3e51d39dba --- /dev/null +++ b/Tests/Module/ExternalData/MD5/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7 b/Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7 new file mode 100644 index 0000000000..a689e3cc49 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/08cfcf221f76ace7b906b312284e73d7 @@ -0,0 +1 @@ +MetaTop diff --git a/Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42 b/Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42 new file mode 100644 index 0000000000..5491241b0b --- /dev/null +++ b/Tests/Module/ExternalData/MD5/30ba0acdee9096b3b9fc6c69362c6b42 @@ -0,0 +1 @@ +Series.3 diff --git a/Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b b/Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b new file mode 100644 index 0000000000..4d0475e228 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/31eff09e84fca01415f8cd9d82ec432b @@ -0,0 +1 @@ +Series.1 diff --git a/Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36 b/Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36 new file mode 100644 index 0000000000..9dec116617 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/401767f22a456b3522953722090a2c36 @@ -0,0 +1 @@ +PairedA diff --git a/Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57 b/Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57 new file mode 100644 index 0000000000..fa701e21bb --- /dev/null +++ b/Tests/Module/ExternalData/MD5/8c018830e3efa5caf3c7415028335a57 @@ -0,0 +1 @@ +Input file already transformed. diff --git a/Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662 b/Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662 new file mode 100644 index 0000000000..69ba09c86c --- /dev/null +++ b/Tests/Module/ExternalData/MD5/8f4add4581551facf27237e6577fd662 @@ -0,0 +1 @@ +MetaB diff --git a/Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822 b/Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822 new file mode 100644 index 0000000000..000e7b2bf3 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/9d980b06c2f0fec3d4872d68175b9822 @@ -0,0 +1 @@ +MetaA diff --git a/Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7 b/Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7 new file mode 100644 index 0000000000..df0510c3c0 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/aaad162b85f60d1eb57ca71a23e8efd7 @@ -0,0 +1 @@ +Another input file already transformed. diff --git a/Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946 b/Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946 new file mode 100644 index 0000000000..3fac5e63d3 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/c1030719c95f3435d8abc39c0d442946 @@ -0,0 +1 @@ +MetaC diff --git a/Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581 b/Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581 new file mode 100644 index 0000000000..8c414f53bf --- /dev/null +++ b/Tests/Module/ExternalData/MD5/ecfa1ecd417d4253af81ae04d1bd6581 @@ -0,0 +1 @@ +PairedB diff --git a/Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058 b/Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058 new file mode 100644 index 0000000000..3503da4f28 --- /dev/null +++ b/Tests/Module/ExternalData/MD5/f41c94425d01ecbbee70440b951cb058 @@ -0,0 +1 @@ +Series diff --git a/Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7 b/Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7 new file mode 100644 index 0000000000..29d727b8fe --- /dev/null +++ b/Tests/Module/ExternalData/MD5/f7ab5a04aae9cb9a520e70b20b9c8ed7 @@ -0,0 +1 @@ +Series.2 diff --git a/Tests/Module/ExternalData/MetaA.dat.md5 b/Tests/Module/ExternalData/MetaA.dat.md5 new file mode 100644 index 0000000000..4a78fc7834 --- /dev/null +++ b/Tests/Module/ExternalData/MetaA.dat.md5 @@ -0,0 +1 @@ +9d980b06c2f0fec3d4872d68175b9822 diff --git a/Tests/Module/ExternalData/MetaB.dat.md5 b/Tests/Module/ExternalData/MetaB.dat.md5 new file mode 100644 index 0000000000..4557a216ad --- /dev/null +++ b/Tests/Module/ExternalData/MetaB.dat.md5 @@ -0,0 +1 @@ +8f4add4581551facf27237e6577fd662 diff --git a/Tests/Module/ExternalData/MetaC.dat.md5 b/Tests/Module/ExternalData/MetaC.dat.md5 new file mode 100644 index 0000000000..a7f23dd7fe --- /dev/null +++ b/Tests/Module/ExternalData/MetaC.dat.md5 @@ -0,0 +1 @@ +c1030719c95f3435d8abc39c0d442946 diff --git a/Tests/Module/ExternalData/MetaTop.dat.md5 b/Tests/Module/ExternalData/MetaTop.dat.md5 new file mode 100644 index 0000000000..1906cbf7ff --- /dev/null +++ b/Tests/Module/ExternalData/MetaTop.dat.md5 @@ -0,0 +1 @@ +08cfcf221f76ace7b906b312284e73d7 diff --git a/Tests/Module/ExternalData/PairedA.dat.md5 b/Tests/Module/ExternalData/PairedA.dat.md5 new file mode 100644 index 0000000000..1ffe035e03 --- /dev/null +++ b/Tests/Module/ExternalData/PairedA.dat.md5 @@ -0,0 +1 @@ +401767f22a456b3522953722090a2c36 diff --git a/Tests/Module/ExternalData/PairedB.dat.md5 b/Tests/Module/ExternalData/PairedB.dat.md5 new file mode 100644 index 0000000000..89c942b636 --- /dev/null +++ b/Tests/Module/ExternalData/PairedB.dat.md5 @@ -0,0 +1 @@ +ecfa1ecd417d4253af81ae04d1bd6581 diff --git a/Tests/Module/ExternalData/SeriesA.dat.md5 b/Tests/Module/ExternalData/SeriesA.dat.md5 new file mode 100644 index 0000000000..be2d6878b0 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesA.dat.md5 @@ -0,0 +1 @@ +f41c94425d01ecbbee70440b951cb058 diff --git a/Tests/Module/ExternalData/SeriesA1.dat.md5 b/Tests/Module/ExternalData/SeriesA1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesA1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesA2.dat.md5 b/Tests/Module/ExternalData/SeriesA2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesA2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesA3.dat.md5 b/Tests/Module/ExternalData/SeriesA3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesA3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesAn1.dat.md5 b/Tests/Module/ExternalData/SeriesAn1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesAn1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesAn2.dat.md5 b/Tests/Module/ExternalData/SeriesAn2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesAn2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesAn3.dat.md5 b/Tests/Module/ExternalData/SeriesAn3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesAn3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesB.dat.md5 b/Tests/Module/ExternalData/SeriesB.dat.md5 new file mode 100644 index 0000000000..be2d6878b0 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesB.dat.md5 @@ -0,0 +1 @@ +f41c94425d01ecbbee70440b951cb058 diff --git a/Tests/Module/ExternalData/SeriesB_1.dat.md5 b/Tests/Module/ExternalData/SeriesB_1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesB_1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesB_2.dat.md5 b/Tests/Module/ExternalData/SeriesB_2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesB_2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesB_3.dat.md5 b/Tests/Module/ExternalData/SeriesB_3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesB_3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesBn_1.dat.md5 b/Tests/Module/ExternalData/SeriesBn_1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesBn_1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesBn_2.dat.md5 b/Tests/Module/ExternalData/SeriesBn_2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesBn_2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesBn_3.dat.md5 b/Tests/Module/ExternalData/SeriesBn_3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesBn_3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesC.1.dat.md5 b/Tests/Module/ExternalData/SeriesC.1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesC.1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesC.2.dat.md5 b/Tests/Module/ExternalData/SeriesC.2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesC.2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesC.3.dat.md5 b/Tests/Module/ExternalData/SeriesC.3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesC.3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesC.dat.md5 b/Tests/Module/ExternalData/SeriesC.dat.md5 new file mode 100644 index 0000000000..be2d6878b0 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesC.dat.md5 @@ -0,0 +1 @@ +f41c94425d01ecbbee70440b951cb058 diff --git a/Tests/Module/ExternalData/SeriesCn.1.dat.md5 b/Tests/Module/ExternalData/SeriesCn.1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesCn.1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesCn.2.dat.md5 b/Tests/Module/ExternalData/SeriesCn.2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesCn.2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesCn.3.dat.md5 b/Tests/Module/ExternalData/SeriesCn.3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesCn.3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesD-1.dat.md5 b/Tests/Module/ExternalData/SeriesD-1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesD-1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesD-2.dat.md5 b/Tests/Module/ExternalData/SeriesD-2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesD-2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesD-3.dat.md5 b/Tests/Module/ExternalData/SeriesD-3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesD-3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/Module/ExternalData/SeriesD.dat.md5 b/Tests/Module/ExternalData/SeriesD.dat.md5 new file mode 100644 index 0000000000..be2d6878b0 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesD.dat.md5 @@ -0,0 +1 @@ +f41c94425d01ecbbee70440b951cb058 diff --git a/Tests/Module/ExternalData/SeriesDn-1.dat.md5 b/Tests/Module/ExternalData/SeriesDn-1.dat.md5 new file mode 100644 index 0000000000..f22e266a6d --- /dev/null +++ b/Tests/Module/ExternalData/SeriesDn-1.dat.md5 @@ -0,0 +1 @@ +31eff09e84fca01415f8cd9d82ec432b diff --git a/Tests/Module/ExternalData/SeriesDn-2.dat.md5 b/Tests/Module/ExternalData/SeriesDn-2.dat.md5 new file mode 100644 index 0000000000..2b917e793f --- /dev/null +++ b/Tests/Module/ExternalData/SeriesDn-2.dat.md5 @@ -0,0 +1 @@ +f7ab5a04aae9cb9a520e70b20b9c8ed7 diff --git a/Tests/Module/ExternalData/SeriesDn-3.dat.md5 b/Tests/Module/ExternalData/SeriesDn-3.dat.md5 new file mode 100644 index 0000000000..b9c9760c43 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesDn-3.dat.md5 @@ -0,0 +1 @@ +30ba0acdee9096b3b9fc6c69362c6b42 diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 35b9a43d4b..e55cf6952b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -46,6 +46,7 @@ macro(add_RunCMake_test test) endmacro() add_RunCMake_test(CMP0019) +add_RunCMake_test(ExternalData) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadHashAlgo1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt new file mode 100644 index 0000000000..f68f0be6b1 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Unknown hash algorithm specified by ExternalData_LINK_CONTENT: + + BAD +Call Stack \(most recent call first\): + .* + BadHashAlgo1.cmake:3 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1.cmake b/Tests/RunCMake/ExternalData/BadHashAlgo1.cmake new file mode 100644 index 0000000000..19e2e412dc --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadHashAlgo1.cmake @@ -0,0 +1,3 @@ +include(ExternalData) +set(ExternalData_LINK_CONTENT BAD) +ExternalData_Expand_Arguments(Data args DATA{BadHashAlgo1.txt}) diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1.txt new file mode 100644 index 0000000000..bfa2818c23 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadHashAlgo1.txt @@ -0,0 +1 @@ +Sample input file that should not be transformed. diff --git a/Tests/RunCMake/ExternalData/BadOption1-result.txt b/Tests/RunCMake/ExternalData/BadOption1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadOption1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadOption1-stderr.txt b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt new file mode 100644 index 0000000000..b63d098c0b --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Unknown option "Bad/Option" in argument + + DATA{Data.txt,Bad/Option} + +Call Stack \(most recent call first\): + .* + BadOption1.cmake:2 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadOption1.cmake b/Tests/RunCMake/ExternalData/BadOption1.cmake new file mode 100644 index 0000000000..1303d7f1a1 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadOption1.cmake @@ -0,0 +1,5 @@ +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Data.txt,Bad/Option} + ) diff --git a/Tests/RunCMake/ExternalData/BadOption2-result.txt b/Tests/RunCMake/ExternalData/BadOption2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadOption2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadOption2-stderr.txt b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt new file mode 100644 index 0000000000..d114c8aa9b --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Unknown option "Bad:Option" in argument + + DATA{Data.txt,Bad:Option} + +Call Stack \(most recent call first\): + .* + BadOption2.cmake:2 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadOption2.cmake b/Tests/RunCMake/ExternalData/BadOption2.cmake new file mode 100644 index 0000000000..6269b064c1 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadOption2.cmake @@ -0,0 +1,5 @@ +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Data.txt,Bad:Option} + ) diff --git a/Tests/RunCMake/ExternalData/BadSeries1-result.txt b/Tests/RunCMake/ExternalData/BadSeries1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt new file mode 100644 index 0000000000..3099be579c --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt @@ -0,0 +1,19 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + ExternalData_SERIES_PARSE is set to + + NotASeriesRegex + + which is not of the form + + \(\)\(\)\$ + + Fix the regular expression or set variables + + ExternalData_SERIES_PARSE_PREFIX = regex group number, if any + ExternalData_SERIES_PARSE_NUMBER = regex group number + ExternalData_SERIES_PARSE_SUFFIX = regex group number + +Call Stack \(most recent call first\): + .* + BadSeries1.cmake:3 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadSeries1.cmake b/Tests/RunCMake/ExternalData/BadSeries1.cmake new file mode 100644 index 0000000000..7d712106f1 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries1.cmake @@ -0,0 +1,3 @@ +include(ExternalData) +set(ExternalData_SERIES_PARSE NotASeriesRegex) +ExternalData_Expand_Arguments(Data args DATA{Data.txt,:}) diff --git a/Tests/RunCMake/ExternalData/BadSeries2-result.txt b/Tests/RunCMake/ExternalData/BadSeries2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt new file mode 100644 index 0000000000..3a02c25e94 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt @@ -0,0 +1,16 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file referenced by argument + + DATA{Data.txt,:} + + corresponds to path + + Data.txt + + that does not match regular expression + + \(x\)\(y\)\$ +Call Stack \(most recent call first\): + .* + BadSeries2.cmake:3 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadSeries2.cmake b/Tests/RunCMake/ExternalData/BadSeries2.cmake new file mode 100644 index 0000000000..e81993b8fd --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries2.cmake @@ -0,0 +1,3 @@ +include(ExternalData) +set(ExternalData_SERIES_PARSE "(x)(y)$") +ExternalData_Expand_Arguments(Data args DATA{Data.txt,:}) diff --git a/Tests/RunCMake/ExternalData/BadSeries3-result.txt b/Tests/RunCMake/ExternalData/BadSeries3-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt new file mode 100644 index 0000000000..594cb6f6a4 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Series option ":" not allowed with associated files. +Call Stack \(most recent call first\): + .* + BadSeries3.cmake:2 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/BadSeries3.cmake b/Tests/RunCMake/ExternalData/BadSeries3.cmake new file mode 100644 index 0000000000..b640df8781 --- /dev/null +++ b/Tests/RunCMake/ExternalData/BadSeries3.cmake @@ -0,0 +1,2 @@ +include(ExternalData) +ExternalData_Expand_Arguments(Data args DATA{PairA.txt,PairB.txt,:}) diff --git a/Tests/RunCMake/ExternalData/CMakeLists.txt b/Tests/RunCMake/ExternalData/CMakeLists.txt new file mode 100644 index 0000000000..e8db6b05be --- /dev/null +++ b/Tests/RunCMake/ExternalData/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/ExternalData/Data.txt.md5 b/Tests/RunCMake/ExternalData/Data.txt.md5 new file mode 100644 index 0000000000..93b3485e94 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Data.txt.md5 @@ -0,0 +1 @@ +e8bb14af900b998b5a3df7e21dd07d58 diff --git a/Tests/RunCMake/ExternalData/Directory1-result.txt b/Tests/RunCMake/ExternalData/Directory1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt new file mode 100644 index 0000000000..85c250f027 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt @@ -0,0 +1,14 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file referenced by argument + + DATA{Directory1} + + corresponds to source tree path + + Directory1 + + that does not exist as a file \(with or without an extension\)! +Call Stack \(most recent call first\): + .* + Directory1.cmake:3 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory1.cmake b/Tests/RunCMake/ExternalData/Directory1.cmake new file mode 100644 index 0000000000..68f1b54bea --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory1.cmake @@ -0,0 +1,6 @@ +include(CTest) +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory1} + ) diff --git a/Tests/RunCMake/ExternalData/Directory1/DirData1.txt b/Tests/RunCMake/ExternalData/Directory1/DirData1.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/ExternalData/Directory2-result.txt b/Tests/RunCMake/ExternalData/Directory2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/Directory2-stderr.txt b/Tests/RunCMake/ExternalData/Directory2-stderr.txt new file mode 100644 index 0000000000..dc1a59a0b8 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory2-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file reference in argument + + DATA{Directory2/} + + may not end in a slash! +Call Stack \(most recent call first\): + .* + Directory2.cmake:3 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory2.cmake b/Tests/RunCMake/ExternalData/Directory2.cmake new file mode 100644 index 0000000000..30b992e6eb --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory2.cmake @@ -0,0 +1,6 @@ +include(CTest) +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory2/} + ) diff --git a/Tests/RunCMake/ExternalData/Directory2.md5 b/Tests/RunCMake/ExternalData/Directory2.md5 new file mode 100644 index 0000000000..93b3485e94 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory2.md5 @@ -0,0 +1 @@ +e8bb14af900b998b5a3df7e21dd07d58 diff --git a/Tests/RunCMake/ExternalData/Directory2/DirData2.txt b/Tests/RunCMake/ExternalData/Directory2/DirData2.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/ExternalData/Directory3-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt new file mode 100644 index 0000000000..56a341e035 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt @@ -0,0 +1,14 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file referenced by argument + + DATA{Directory3/\*} + + corresponds to source tree path + + Directory3/. + + that does not exist as a file \(with or without an extension\)! +Call Stack \(most recent call first\): + .* + Directory3.cmake:3 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory3.cmake b/Tests/RunCMake/ExternalData/Directory3.cmake new file mode 100644 index 0000000000..55d8be9dd3 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory3.cmake @@ -0,0 +1,6 @@ +include(CTest) +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory3/*} + ) diff --git a/Tests/RunCMake/ExternalData/Directory3/DirData3.txt b/Tests/RunCMake/ExternalData/Directory3/DirData3.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt b/Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt new file mode 100644 index 0000000000..f77fca9b51 --- /dev/null +++ b/Tests/RunCMake/ExternalData/LinkContentMD5-stdout.txt @@ -0,0 +1,3 @@ +-- Linked ToLink.txt.md5 to ExternalData MD5/c18ff9804c8deec9eaeb17063cda8b7b +-- Raw data correctly transformed to content link! +-- Staged content exists! diff --git a/Tests/RunCMake/ExternalData/LinkContentMD5.cmake b/Tests/RunCMake/ExternalData/LinkContentMD5.cmake new file mode 100644 index 0000000000..41b4deebfd --- /dev/null +++ b/Tests/RunCMake/ExternalData/LinkContentMD5.cmake @@ -0,0 +1,22 @@ +include(ExternalData) +set(ExternalData_LINK_CONTENT MD5) +set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR}) +set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData) +set(input ${CMAKE_CURRENT_BINARY_DIR}/ToLink.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/ToLink.txt) +set(staged "${CMAKE_CURRENT_BINARY_DIR}/.ExternalData_MD5_c18ff9804c8deec9eaeb17063cda8b7b") +file(REMOVE ${staged}) +file(REMOVE ${input}.md5) +file(WRITE ${input} "To be transformed into a content link.") +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Raw data correctly transformed to content link!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() +if(EXISTS "${staged}") + message(STATUS "Staged content exists!") +else() + message(FATAL_ERROR "Staged content missing!") +endif() diff --git a/Tests/RunCMake/ExternalData/MissingData-result.txt b/Tests/RunCMake/ExternalData/MissingData-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingData-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt new file mode 100644 index 0000000000..e794f955da --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt @@ -0,0 +1,14 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file referenced by argument + + DATA{MissingData.txt} + + corresponds to source tree path + + MissingData.txt + + that does not exist as a file \(with or without an extension\)! +Call Stack \(most recent call first\): + .* + MissingData.cmake:2 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/MissingData.cmake b/Tests/RunCMake/ExternalData/MissingData.cmake new file mode 100644 index 0000000000..b3c8a5cdc0 --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingData.cmake @@ -0,0 +1,5 @@ +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{MissingData.txt} + ) diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt new file mode 100644 index 0000000000..496ad8ae4e --- /dev/null +++ b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt @@ -0,0 +1,6 @@ +CMake Warning at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + ExternalData_LINK_CONTENT cannot be used in-source +Call Stack \(most recent call first\): + .* + NoLinkInSource.cmake:8 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt b/Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt new file mode 100644 index 0000000000..18946f0ecb --- /dev/null +++ b/Tests/RunCMake/ExternalData/NoLinkInSource-stdout.txt @@ -0,0 +1 @@ +-- Data reference correctly not transformed! diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource.cmake b/Tests/RunCMake/ExternalData/NoLinkInSource.cmake new file mode 100644 index 0000000000..cbf45ebbf7 --- /dev/null +++ b/Tests/RunCMake/ExternalData/NoLinkInSource.cmake @@ -0,0 +1,14 @@ +include(ExternalData) +set(ExternalData_LINK_CONTENT MD5) +set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR}) +set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}) +set(input ${CMAKE_CURRENT_BINARY_DIR}/ToLink.txt) +file(REMOVE ${input}.md5) +file(WRITE ${input} "To be transformed into a content link.") +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${input}") + message(STATUS "Data reference correctly not transformed!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected no transformation.") +endif() diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-result.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/NoURLTemplates-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt new file mode 100644 index 0000000000..ad059d434f --- /dev/null +++ b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + ExternalData_URL_TEMPLATES is not set! +Call Stack \(most recent call first\): + NoURLTemplates.cmake:2 \(ExternalData_Add_Target\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates.cmake b/Tests/RunCMake/ExternalData/NoURLTemplates.cmake new file mode 100644 index 0000000000..8f0e069c22 --- /dev/null +++ b/Tests/RunCMake/ExternalData/NoURLTemplates.cmake @@ -0,0 +1,2 @@ +include(ExternalData) +ExternalData_Add_Target(Data) diff --git a/Tests/RunCMake/ExternalData/NormalData1-stdout.txt b/Tests/RunCMake/ExternalData/NormalData1-stdout.txt new file mode 100644 index 0000000000..2f2c770cbf --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalData1-stdout.txt @@ -0,0 +1 @@ +-- Data reference correctly transformed! diff --git a/Tests/RunCMake/ExternalData/NormalData1.cmake b/Tests/RunCMake/ExternalData/NormalData1.cmake new file mode 100644 index 0000000000..d6cc384c85 --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalData1.cmake @@ -0,0 +1,13 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(input Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/NormalData2-stdout.txt b/Tests/RunCMake/ExternalData/NormalData2-stdout.txt new file mode 100644 index 0000000000..2f2c770cbf --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalData2-stdout.txt @@ -0,0 +1 @@ +-- Data reference correctly transformed! diff --git a/Tests/RunCMake/ExternalData/NormalData2.cmake b/Tests/RunCMake/ExternalData/NormalData2.cmake new file mode 100644 index 0000000000..c979b48ea9 --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalData2.cmake @@ -0,0 +1,14 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData) +set(input Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/NormalData3-stdout.txt b/Tests/RunCMake/ExternalData/NormalData3-stdout.txt new file mode 100644 index 0000000000..2f2c770cbf --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalData3-stdout.txt @@ -0,0 +1 @@ +-- Data reference correctly transformed! diff --git a/Tests/RunCMake/ExternalData/NormalData3.cmake b/Tests/RunCMake/ExternalData/NormalData3.cmake new file mode 100644 index 0000000000..e99112267a --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalData3.cmake @@ -0,0 +1,14 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData) +set(input ${CMAKE_CURRENT_SOURCE_DIR}/Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt b/Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt new file mode 100644 index 0000000000..2f2c770cbf --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalDataSub1-stdout.txt @@ -0,0 +1 @@ +-- Data reference correctly transformed! diff --git a/Tests/RunCMake/ExternalData/NormalDataSub1.cmake b/Tests/RunCMake/ExternalData/NormalDataSub1.cmake new file mode 100644 index 0000000000..015e94c0a7 --- /dev/null +++ b/Tests/RunCMake/ExternalData/NormalDataSub1.cmake @@ -0,0 +1,13 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(input SubDirectory1/Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/SubDirectory1/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/NotUnderRoot-result.txt b/Tests/RunCMake/ExternalData/NotUnderRoot-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/NotUnderRoot-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt b/Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt new file mode 100644 index 0000000000..1f2eb1c7af --- /dev/null +++ b/Tests/RunCMake/ExternalData/NotUnderRoot-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file referenced by argument + + DATA{../NotUnderRoot.txt} + + does not lie under the top-level source directory + + .*/Tests/RunCMake/ExternalData + +Call Stack \(most recent call first\): + .* + NotUnderRoot.cmake:2 \(ExternalData_Add_Test\) diff --git a/Tests/RunCMake/ExternalData/NotUnderRoot.cmake b/Tests/RunCMake/ExternalData/NotUnderRoot.cmake new file mode 100644 index 0000000000..c7942d678d --- /dev/null +++ b/Tests/RunCMake/ExternalData/NotUnderRoot.cmake @@ -0,0 +1,5 @@ +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{../NotUnderRoot.txt} + ) diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake new file mode 100644 index 0000000000..c61527e484 --- /dev/null +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -0,0 +1,21 @@ +include(RunCMake) + +run_cmake(BadHashAlgo1) +run_cmake(BadOption1) +run_cmake(BadOption2) +run_cmake(BadSeries1) +run_cmake(BadSeries2) +run_cmake(BadSeries3) +run_cmake(Directory1) +run_cmake(Directory2) +run_cmake(Directory3) +run_cmake(LinkContentMD5) +run_cmake(MissingData) +run_cmake(NoLinkInSource) +run_cmake(NoURLTemplates) +run_cmake(NormalData1) +run_cmake(NormalData2) +run_cmake(NormalData3) +run_cmake(NormalDataSub1) +run_cmake(NotUnderRoot) +run_cmake(SubDirectory1) diff --git a/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt new file mode 100644 index 0000000000..35a8cc172a --- /dev/null +++ b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt @@ -0,0 +1,2 @@ +-- Data reference correctly transformed in parent dir! +-- Data reference correctly transformed in current dir! diff --git a/Tests/RunCMake/ExternalData/SubDirectory1.cmake b/Tests/RunCMake/ExternalData/SubDirectory1.cmake new file mode 100644 index 0000000000..29894710ac --- /dev/null +++ b/Tests/RunCMake/ExternalData/SubDirectory1.cmake @@ -0,0 +1,5 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +add_subdirectory(SubDirectory1) diff --git a/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt new file mode 100644 index 0000000000..07824608cd --- /dev/null +++ b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt @@ -0,0 +1,19 @@ +set(input ../Data.txt) +set(output ${CMAKE_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed in parent dir!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() + +set(input Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed in current dir!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5 b/Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5 new file mode 100644 index 0000000000..93b3485e94 --- /dev/null +++ b/Tests/RunCMake/ExternalData/SubDirectory1/Data.txt.md5 @@ -0,0 +1 @@ +e8bb14af900b998b5a3df7e21dd07d58 From 175ed02207ea5fe25aa7156acb2554d706611263 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jan 2013 10:26:11 -0500 Subject: [PATCH 61/94] ExternalData: Allow ()-groups in series match regex Refactor use of the ExternalData_SERIES_MATCH value to avoid assuming that it has no ()-groups that interfere with group indexing. Extend the Module.ExternalData test to cover this case. --- Modules/ExternalData.cmake | 13 ++++++++----- Tests/Module/ExternalData/Data2/CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 0ef514c1f6..6442c3ee9d 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -502,11 +502,14 @@ endmacro() function(_ExternalData_arg_find_files pattern regex) file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*") foreach(entry IN LISTS globbed) - string(REGEX REPLACE "^(${regex})(\\.md5|)$" "\\1;\\2" tuple "${entry}") - list(LENGTH tuple len) - if("${len}" EQUAL 2 AND NOT IS_DIRECTORY "${top_src}/${entry}") - list(GET tuple 0 relname) - list(GET tuple 1 alg) + if("x${entry}" MATCHES "^x(.*)(\\.md5)$") + set(relname "${CMAKE_MATCH_1}") + set(alg "${CMAKE_MATCH_2}") + else() + set(relname "${entry}") + set(alg "") + endif() + if("x${relname}" MATCHES "^x${regex}$" AND NOT IS_DIRECTORY "${top_src}/${entry}") set(name "${top_src}/${relname}") set(file "${top_bin}/${relname}") if(alg) diff --git a/Tests/Module/ExternalData/Data2/CMakeLists.txt b/Tests/Module/ExternalData/Data2/CMakeLists.txt index f8eedff642..e6d8767a66 100644 --- a/Tests/Module/ExternalData/Data2/CMakeLists.txt +++ b/Tests/Module/ExternalData/Data2/CMakeLists.txt @@ -1,5 +1,5 @@ set(ExternalData_SERIES_PARSE "([0-9]+)(_\\.my\\.dat)$") -set(ExternalData_SERIES_MATCH "[0-9]+") +set(ExternalData_SERIES_MATCH "([0-9]+)") ExternalData_Add_Test(Data2 NAME Data2Check COMMAND ${CMAKE_COMMAND} From 9e518a8169bae33c8a971c146e29b5af20114648 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jan 2013 15:12:08 -0500 Subject: [PATCH 62/94] ExternalData: Allow DATA{} syntax to reference directories Use a trailing slash to reference a directory. Require that a list of associated files be specified to select from within the directory. One may simply use DATA{Dir/,REGEX:.*} to reference all files but get a directory passed on the command line. --- Modules/ExternalData.cmake | 45 ++++++++++++++++--- Tests/Module/ExternalData/CMakeLists.txt | 1 + Tests/Module/ExternalData/Data1Check.cmake | 6 +++ Tests/Module/ExternalData/Directory/A.dat.md5 | 1 + Tests/Module/ExternalData/Directory/B.dat.md5 | 1 + Tests/Module/ExternalData/Directory/C.dat.md5 | 1 + .../ExternalData/Directory2-stderr.txt | 4 +- .../ExternalData/Directory4-result.txt | 1 + .../ExternalData/Directory4-stderr.txt | 6 +++ Tests/RunCMake/ExternalData/Directory4.cmake | 6 +++ .../ExternalData/Directory4/DirData4.txt | 0 .../ExternalData/Directory5-result.txt | 1 + .../ExternalData/Directory5-stderr.txt | 14 ++++++ Tests/RunCMake/ExternalData/Directory5.cmake | 6 +++ .../RunCMake/ExternalData/RunCMakeTest.cmake | 2 + 15 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 Tests/Module/ExternalData/Directory/A.dat.md5 create mode 100644 Tests/Module/ExternalData/Directory/B.dat.md5 create mode 100644 Tests/Module/ExternalData/Directory/C.dat.md5 create mode 100644 Tests/RunCMake/ExternalData/Directory4-result.txt create mode 100644 Tests/RunCMake/ExternalData/Directory4-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/Directory4.cmake create mode 100644 Tests/RunCMake/ExternalData/Directory4/DirData4.txt create mode 100644 Tests/RunCMake/ExternalData/Directory5-result.txt create mode 100644 Tests/RunCMake/ExternalData/Directory5-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/Directory5.cmake diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 6442c3ee9d..43ff5175df 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -97,6 +97,14 @@ # will pass MyInput.mha and MyFrames00.png on the command line but ensure # that the associated files are present next to them. # +# The DATA{} syntax may reference a directory using a trailing slash and a +# list of associated files. The form DATA{/,,,...} adds +# rules to fetch any files in the directory that match one of the associated +# file options. For example, the argument DATA{MyDataDir/,REGEX:.*} will pass +# the full path to a MyDataDir directory on the command line and ensure that +# the directory contains files corresponding to every file or content link in +# the MyDataDir source directory. +# # The variable ExternalData_LINK_CONTENT may be set to the name of a supported # hash algorithm to enable automatic conversion of real data files referenced # by the DATA{} syntax into content links. For each such a content @@ -312,11 +320,11 @@ function(_ExternalData_arg target arg options var_file) list(GET options 0 data) list(REMOVE_AT options 0) - # Reject trailing slashes. - if("x${data}" MATCHES "[/\\]$") - message(FATAL_ERROR "Data file reference in argument\n" - " ${arg}\n" - "may not end in a slash!") + # Interpret trailing slashes as directories. + set(data_is_directory 0) + if("x${data}" MATCHES "^x(.*)([/\\])$") + set(data_is_directory 1) + set(data "${CMAKE_MATCH_1}") endif() # Convert to full path. @@ -338,6 +346,13 @@ function(_ExternalData_arg target arg options var_file) "does not lie under the top-level source directory\n" " ${top_src}\n") endif() + if(data_is_directory AND NOT IS_DIRECTORY "${top_src}/${reldata}") + message(FATAL_ERROR "Data directory referenced by argument\n" + " ${arg}\n" + "corresponds to source tree path\n" + " ${reldata}\n" + "that does not exist as a directory!") + endif() if(NOT ExternalData_BINARY_ROOT) set(ExternalData_BINARY_ROOT "${CMAKE_BINARY_DIR}") endif() @@ -354,7 +369,7 @@ function(_ExternalData_arg target arg options var_file) set(external "") # Entries external to the source tree. set(internal "") # Entries internal to the source tree. - set(have_original 0) + set(have_original ${data_is_directory}) # Process options. set(series_option "") @@ -378,11 +393,23 @@ function(_ExternalData_arg target arg options var_file) endforeach() if(series_option) + if(data_is_directory) + message(FATAL_ERROR "Series option \"${series_option}\" not allowed with directories.") + endif() if(associated_files OR associated_regex) message(FATAL_ERROR "Series option \"${series_option}\" not allowed with associated files.") endif() # Load a whole file series. _ExternalData_arg_series() + elseif(data_is_directory) + if(associated_files OR associated_regex) + # Load listed/matching associated files in the directory. + _ExternalData_arg_associated() + else() + message(FATAL_ERROR "Data directory referenced by argument\n" + " ${arg}\n" + "must list associated files.") + endif() else() # Load the named data file. _ExternalData_arg_single() @@ -415,7 +442,11 @@ endfunction() macro(_ExternalData_arg_associated) # Associated files lie in the same directory. - get_filename_component(reldir "${reldata}" PATH) + if(data_is_directory) + set(reldir "${reldata}") + else() + get_filename_component(reldir "${reldata}" PATH) + endif() if(reldir) set(reldir "${reldir}/") endif() diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index 55326100d5..c9a192bbd7 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -24,6 +24,7 @@ ExternalData_Add_Test(Data1 -D SeriesDn=DATA{SeriesDn-1.dat,:} -D Paired=DATA{PairedA.dat,PairedB.dat} -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} + -D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat} -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake ) ExternalData_Add_Target(Data1) diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake index fd18cdf5fd..972ec4632a 100644 --- a/Tests/Module/ExternalData/Data1Check.cmake +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -38,3 +38,9 @@ foreach(n Top A B C) message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") endif() endforeach() +foreach(n A B C) + set(file "${Directory}/${n}.dat") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() +endforeach() diff --git a/Tests/Module/ExternalData/Directory/A.dat.md5 b/Tests/Module/ExternalData/Directory/A.dat.md5 new file mode 100644 index 0000000000..4a78fc7834 --- /dev/null +++ b/Tests/Module/ExternalData/Directory/A.dat.md5 @@ -0,0 +1 @@ +9d980b06c2f0fec3d4872d68175b9822 diff --git a/Tests/Module/ExternalData/Directory/B.dat.md5 b/Tests/Module/ExternalData/Directory/B.dat.md5 new file mode 100644 index 0000000000..4557a216ad --- /dev/null +++ b/Tests/Module/ExternalData/Directory/B.dat.md5 @@ -0,0 +1 @@ +8f4add4581551facf27237e6577fd662 diff --git a/Tests/Module/ExternalData/Directory/C.dat.md5 b/Tests/Module/ExternalData/Directory/C.dat.md5 new file mode 100644 index 0000000000..a7f23dd7fe --- /dev/null +++ b/Tests/Module/ExternalData/Directory/C.dat.md5 @@ -0,0 +1 @@ +c1030719c95f3435d8abc39c0d442946 diff --git a/Tests/RunCMake/ExternalData/Directory2-stderr.txt b/Tests/RunCMake/ExternalData/Directory2-stderr.txt index dc1a59a0b8..92c9a2ff59 100644 --- a/Tests/RunCMake/ExternalData/Directory2-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory2-stderr.txt @@ -1,9 +1,9 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): - Data file reference in argument + Data directory referenced by argument DATA{Directory2/} - may not end in a slash! + must list associated files. Call Stack \(most recent call first\): .* Directory2.cmake:3 \(ExternalData_Add_Test\) diff --git a/Tests/RunCMake/ExternalData/Directory4-result.txt b/Tests/RunCMake/ExternalData/Directory4-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/Directory4-stderr.txt b/Tests/RunCMake/ExternalData/Directory4-stderr.txt new file mode 100644 index 0000000000..dcb8522f88 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory4-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Series option ":" not allowed with directories. +Call Stack \(most recent call first\): + .* + Directory4.cmake:3 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory4.cmake b/Tests/RunCMake/ExternalData/Directory4.cmake new file mode 100644 index 0000000000..7d3d6384d6 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory4.cmake @@ -0,0 +1,6 @@ +include(CTest) +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory4/,:} + ) diff --git a/Tests/RunCMake/ExternalData/Directory4/DirData4.txt b/Tests/RunCMake/ExternalData/Directory4/DirData4.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/ExternalData/Directory5-result.txt b/Tests/RunCMake/ExternalData/Directory5-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalData/Directory5-stderr.txt b/Tests/RunCMake/ExternalData/Directory5-stderr.txt new file mode 100644 index 0000000000..8e54aecd2a --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory5-stderr.txt @@ -0,0 +1,14 @@ +CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data directory referenced by argument + + DATA{Directory5/} + + corresponds to source tree path + + Directory5 + + that does not exist as a directory! +Call Stack \(most recent call first\): + .* + Directory5.cmake:3 \(ExternalData_Add_Test\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExternalData/Directory5.cmake b/Tests/RunCMake/ExternalData/Directory5.cmake new file mode 100644 index 0000000000..931589e4e4 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Directory5.cmake @@ -0,0 +1,6 @@ +include(CTest) +include(ExternalData) +ExternalData_Add_Test(Data + NAME Test + COMMAND ${CMAKE_COMMAND} -E echo DATA{Directory5/} + ) diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake index c61527e484..fc85a21257 100644 --- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -9,6 +9,8 @@ run_cmake(BadSeries3) run_cmake(Directory1) run_cmake(Directory2) run_cmake(Directory3) +run_cmake(Directory4) +run_cmake(Directory5) run_cmake(LinkContentMD5) run_cmake(MissingData) run_cmake(NoLinkInSource) From aa8b2288d320335d28f3777e1bc86ed3df231a09 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 14:09:39 -0500 Subject: [PATCH 63/94] ExternalData: Generalize hash algo/ext handling Use private global variables _ExternalData_REGEX_(ALGO|EXT) to match the possible hash algorithm names and extensions in regular expressions. Use "file()" instead of "cmake -E md5sum" to compute hashes without a child process and to support more hash algorithms. --- Modules/ExternalData.cmake | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 43ff5175df..fef83672bf 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -261,18 +261,16 @@ endfunction() #----------------------------------------------------------------------------- # Private helper interface +set(_ExternalData_REGEX_ALGO "MD5") +set(_ExternalData_REGEX_EXT "md5") set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}") get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH) function(_ExternalData_compute_hash var_hash algo file) - if("${algo}" STREQUAL "MD5") - # TODO: Errors - execute_process(COMMAND "${CMAKE_COMMAND}" -E md5sum "${file}" - OUTPUT_VARIABLE output) - string(SUBSTRING "${output}" 0 32 hash) + if("${algo}" MATCHES "^${_ExternalData_REGEX_ALGO}$") + file("${algo}" "${file}" hash) set("${var_hash}" "${hash}" PARENT_SCOPE) else() - # TODO: Other hashes. message(FATAL_ERROR "Hash algorithm ${algo} unimplemented.") endif() endfunction() @@ -295,7 +293,7 @@ function(_ExternalData_atomic_write file content) endfunction() function(_ExternalData_link_content name var_ext) - if("${ExternalData_LINK_CONTENT}" MATCHES "^(MD5)$") + if("${ExternalData_LINK_CONTENT}" MATCHES "^(${_ExternalData_REGEX_ALGO})$") set(algo "${ExternalData_LINK_CONTENT}") else() message(FATAL_ERROR @@ -305,7 +303,7 @@ function(_ExternalData_link_content name var_ext) _ExternalData_compute_hash(hash "${algo}" "${name}") get_filename_component(dir "${name}" PATH) set(staged "${dir}/.ExternalData_${algo}_${hash}") - set(ext ".md5") + string(TOLOWER ".${algo}" ext) _ExternalData_atomic_write("${name}${ext}" "${hash}\n") file(RENAME "${name}" "${staged}") set("${var_ext}" "${ext}" PARENT_SCOPE) @@ -533,7 +531,7 @@ endmacro() function(_ExternalData_arg_find_files pattern regex) file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*") foreach(entry IN LISTS globbed) - if("x${entry}" MATCHES "^x(.*)(\\.md5)$") + if("x${entry}" MATCHES "^x(.*)(\\.(${_ExternalData_REGEX_EXT}))$") set(relname "${CMAKE_MATCH_1}") set(alg "${CMAKE_MATCH_2}") else() @@ -716,8 +714,8 @@ if("${ExternalData_ACTION}" STREQUAL "fetch") file(READ "${name}${ext}" hash) string(STRIP "${hash}" hash) - if("${ext}" STREQUAL ".md5") - set(algo "MD5") + if("${ext}" MATCHES "^\\.(${_ExternalData_REGEX_EXT})$") + string(TOUPPER "${CMAKE_MATCH_1}" algo) else() message(FATAL_ERROR "Unknown hash algorithm extension \"${ext}\"") endif() From ee2abfdc8913e4e9a5bc77c56a9d3dea83fde6f1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 14:12:10 -0500 Subject: [PATCH 64/94] ExternalData: Add support for SHA 1 and 2 hash algorithms Update the Module.ExternalData and RunCMake.ExternalData tests to cover some of them. --- Modules/ExternalData.cmake | 9 ++++++-- Tests/Module/ExternalData/CMakeLists.txt | 1 + Tests/Module/ExternalData/Data1Check.cmake | 6 +++++ .../MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0 | 1 + Tests/Module/ExternalData/SHA1/.gitattributes | 1 + .../2af59a7022024974f3b8521b7ed8137c996a79f1 | 1 + .../Module/ExternalData/SHA224/.gitattributes | 1 + ...fe1cc28db47ffb89bae025f4551dceb343a5869174 | 1 + .../Module/ExternalData/SHA256/.gitattributes | 1 + ...3e8178c7e26c711c9b20dbcaa3853d869d3871f133 | 1 + .../Module/ExternalData/SeriesMixed.1.dat.md5 | 1 + .../ExternalData/SeriesMixed.2.dat.sha1 | 1 + .../ExternalData/SeriesMixed.3.dat.sha224 | 1 + .../ExternalData/SeriesMixed.4.dat.sha256 | 1 + .../ExternalData/LinkContentSHA1-stdout.txt | 3 +++ .../ExternalData/LinkContentSHA1.cmake | 22 +++++++++++++++++++ .../RunCMake/ExternalData/RunCMakeTest.cmake | 1 + 17 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0 create mode 100644 Tests/Module/ExternalData/SHA1/.gitattributes create mode 100644 Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1 create mode 100644 Tests/Module/ExternalData/SHA224/.gitattributes create mode 100644 Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174 create mode 100644 Tests/Module/ExternalData/SHA256/.gitattributes create mode 100644 Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133 create mode 100644 Tests/Module/ExternalData/SeriesMixed.1.dat.md5 create mode 100644 Tests/Module/ExternalData/SeriesMixed.2.dat.sha1 create mode 100644 Tests/Module/ExternalData/SeriesMixed.3.dat.sha224 create mode 100644 Tests/Module/ExternalData/SeriesMixed.4.dat.sha256 create mode 100644 Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/LinkContentSHA1.cmake diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index fef83672bf..26b0f99ab1 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -49,6 +49,11 @@ # %(algo) Description # ------- ----- ----------- # MD5 .md5 Message-Digest Algorithm 5, RFC 1321 +# SHA1 .sha1 US Secure Hash Algorithm 1, RFC 3174 +# SHA224 .sha224 US Secure Hash Algorithms, RFC 4634 +# SHA256 .sha256 US Secure Hash Algorithms, RFC 4634 +# SHA384 .sha384 US Secure Hash Algorithms, RFC 4634 +# SHA512 .sha512 US Secure Hash Algorithms, RFC 4634 # Note that the hashes are used only for unique data identification and # download verification. This is not security software. # @@ -261,8 +266,8 @@ endfunction() #----------------------------------------------------------------------------- # Private helper interface -set(_ExternalData_REGEX_ALGO "MD5") -set(_ExternalData_REGEX_EXT "md5") +set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512") +set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512") set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}") get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH) diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index c9a192bbd7..e69713ad51 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -22,6 +22,7 @@ ExternalData_Add_Test(Data1 -D SeriesBn=DATA{SeriesBn_1.dat,:} -D SeriesCn=DATA{SeriesCn.1.dat,:} -D SeriesDn=DATA{SeriesDn-1.dat,:} + -D SeriesMixed=DATA{SeriesMixed.1.dat,:} -D Paired=DATA{PairedA.dat,PairedB.dat} -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} -D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat} diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake index 972ec4632a..b99d7aea72 100644 --- a/Tests/Module/ExternalData/Data1Check.cmake +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -26,6 +26,12 @@ foreach(s A B C D) endif() endforeach() endforeach() +foreach(n .1 .2 .3 .4) + string(REGEX REPLACE "\\.1\\.dat$" "${n}.dat" file "${SeriesMixed}") + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() +endforeach() foreach(n A B) string(REGEX REPLACE "A\\.dat$" "${n}.dat" file "${Paired}") if(NOT EXISTS "${file}") diff --git a/Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0 b/Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0 new file mode 100644 index 0000000000..362d4b4f2b --- /dev/null +++ b/Tests/Module/ExternalData/MD5/ce38ea6c3c1e00fa6405dd64b8bf6da0 @@ -0,0 +1 @@ +SeriesMixed.1 diff --git a/Tests/Module/ExternalData/SHA1/.gitattributes b/Tests/Module/ExternalData/SHA1/.gitattributes new file mode 100644 index 0000000000..3e51d39dba --- /dev/null +++ b/Tests/Module/ExternalData/SHA1/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1 b/Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1 new file mode 100644 index 0000000000..a388540608 --- /dev/null +++ b/Tests/Module/ExternalData/SHA1/2af59a7022024974f3b8521b7ed8137c996a79f1 @@ -0,0 +1 @@ +SeriesMixed.2 diff --git a/Tests/Module/ExternalData/SHA224/.gitattributes b/Tests/Module/ExternalData/SHA224/.gitattributes new file mode 100644 index 0000000000..3e51d39dba --- /dev/null +++ b/Tests/Module/ExternalData/SHA224/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174 b/Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174 new file mode 100644 index 0000000000..e806d98532 --- /dev/null +++ b/Tests/Module/ExternalData/SHA224/3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174 @@ -0,0 +1 @@ +SeriesMixed.3 diff --git a/Tests/Module/ExternalData/SHA256/.gitattributes b/Tests/Module/ExternalData/SHA256/.gitattributes new file mode 100644 index 0000000000..3e51d39dba --- /dev/null +++ b/Tests/Module/ExternalData/SHA256/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133 b/Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133 new file mode 100644 index 0000000000..e3d1e0cc74 --- /dev/null +++ b/Tests/Module/ExternalData/SHA256/969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133 @@ -0,0 +1 @@ +SeriesMixed.4 diff --git a/Tests/Module/ExternalData/SeriesMixed.1.dat.md5 b/Tests/Module/ExternalData/SeriesMixed.1.dat.md5 new file mode 100644 index 0000000000..f962d8f79e --- /dev/null +++ b/Tests/Module/ExternalData/SeriesMixed.1.dat.md5 @@ -0,0 +1 @@ +ce38ea6c3c1e00fa6405dd64b8bf6da0 diff --git a/Tests/Module/ExternalData/SeriesMixed.2.dat.sha1 b/Tests/Module/ExternalData/SeriesMixed.2.dat.sha1 new file mode 100644 index 0000000000..43a354086a --- /dev/null +++ b/Tests/Module/ExternalData/SeriesMixed.2.dat.sha1 @@ -0,0 +1 @@ +2af59a7022024974f3b8521b7ed8137c996a79f1 diff --git a/Tests/Module/ExternalData/SeriesMixed.3.dat.sha224 b/Tests/Module/ExternalData/SeriesMixed.3.dat.sha224 new file mode 100644 index 0000000000..a18e40e4c6 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesMixed.3.dat.sha224 @@ -0,0 +1 @@ +3b679da7908562fe1cc28db47ffb89bae025f4551dceb343a5869174 diff --git a/Tests/Module/ExternalData/SeriesMixed.4.dat.sha256 b/Tests/Module/ExternalData/SeriesMixed.4.dat.sha256 new file mode 100644 index 0000000000..67fc3c2f1b --- /dev/null +++ b/Tests/Module/ExternalData/SeriesMixed.4.dat.sha256 @@ -0,0 +1 @@ +969171a0dd70d49ce096bd3e8178c7e26c711c9b20dbcaa3853d869d3871f133 diff --git a/Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt b/Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt new file mode 100644 index 0000000000..9a8eb2e3db --- /dev/null +++ b/Tests/RunCMake/ExternalData/LinkContentSHA1-stdout.txt @@ -0,0 +1,3 @@ +-- Linked ToLink.txt.sha1 to ExternalData SHA1/114ee5dda251457fd2df63bec91d3b8db43aba58 +-- Raw data correctly transformed to content link! +-- Staged content exists! diff --git a/Tests/RunCMake/ExternalData/LinkContentSHA1.cmake b/Tests/RunCMake/ExternalData/LinkContentSHA1.cmake new file mode 100644 index 0000000000..f78501cf57 --- /dev/null +++ b/Tests/RunCMake/ExternalData/LinkContentSHA1.cmake @@ -0,0 +1,22 @@ +include(ExternalData) +set(ExternalData_LINK_CONTENT SHA1) +set(ExternalData_SOURCE_ROOT ${CMAKE_CURRENT_BINARY_DIR}) +set(ExternalData_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR}/ExternalData) +set(input ${CMAKE_CURRENT_BINARY_DIR}/ToLink.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/ExternalData/ToLink.txt) +set(staged "${CMAKE_CURRENT_BINARY_DIR}/.ExternalData_SHA1_114ee5dda251457fd2df63bec91d3b8db43aba58") +file(REMOVE ${staged}) +file(REMOVE ${input}.sha1) +file(WRITE ${input} "To be transformed into a content link.") +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Raw data correctly transformed to content link!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() +if(EXISTS "${staged}") + message(STATUS "Staged content exists!") +else() + message(FATAL_ERROR "Staged content missing!") +endif() diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake index fc85a21257..5ee46c97cb 100644 --- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -12,6 +12,7 @@ run_cmake(Directory3) run_cmake(Directory4) run_cmake(Directory5) run_cmake(LinkContentMD5) +run_cmake(LinkContentSHA1) run_cmake(MissingData) run_cmake(NoLinkInSource) run_cmake(NoURLTemplates) From e2e0d2e3c7108d5ce41f032ad9089155c6b4735c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Jan 2013 14:44:49 -0500 Subject: [PATCH 65/94] ExternalData: Collapse ../ components in DATA{} paths Relative path components need to be normalized out even if they appear in the middle of a caller-supplied string. --- Modules/ExternalData.cmake | 3 ++- Tests/Module/ExternalData/Data2/CMakeLists.txt | 1 + Tests/Module/ExternalData/Data2/Data2Check.cmake | 9 ++++++--- Tests/Module/ExternalData/Data2b.dat.md5 | 1 + Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt | 3 ++- .../ExternalData/SubDirectory1/CMakeLists.txt | 12 +++++++++++- 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 Tests/Module/ExternalData/Data2b.dat.md5 diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 26b0f99ab1..825b7b8716 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -334,8 +334,9 @@ function(_ExternalData_arg target arg options var_file) if(IS_ABSOLUTE "${data}") set(absdata "${data}") else() - get_filename_component(absdata "${CMAKE_CURRENT_SOURCE_DIR}/${data}" ABSOLUTE) + set(absdata "${CMAKE_CURRENT_SOURCE_DIR}/${data}") endif() + get_filename_component(absdata "${absdata}" ABSOLUTE) # Convert to relative path under the source tree. if(NOT ExternalData_SOURCE_ROOT) diff --git a/Tests/Module/ExternalData/Data2/CMakeLists.txt b/Tests/Module/ExternalData/Data2/CMakeLists.txt index e6d8767a66..c5b79ac05a 100644 --- a/Tests/Module/ExternalData/Data2/CMakeLists.txt +++ b/Tests/Module/ExternalData/Data2/CMakeLists.txt @@ -4,6 +4,7 @@ ExternalData_Add_Test(Data2 NAME Data2Check COMMAND ${CMAKE_COMMAND} -D Data2=DATA{../Data2.dat} + -D Data2b=DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data2b.dat} -D SeriesC=DATA{SeriesC_1_.my.dat,:} -P ${CMAKE_CURRENT_SOURCE_DIR}/Data2Check.cmake ) diff --git a/Tests/Module/ExternalData/Data2/Data2Check.cmake b/Tests/Module/ExternalData/Data2/Data2Check.cmake index a1dd5091d1..d5b0c7b68c 100644 --- a/Tests/Module/ExternalData/Data2/Data2Check.cmake +++ b/Tests/Module/ExternalData/Data2/Data2Check.cmake @@ -1,6 +1,9 @@ -if(NOT EXISTS "${Data2}") - message(SEND_ERROR "Input file:\n ${Data2}\ndoes not exist!") -endif() +foreach(d "${Data2}" "${Data2b}") + file(STRINGS "${d}" lines LIMIT_INPUT 1024) + if(NOT "x${lines}" STREQUAL "xInput file already transformed.") + message(SEND_ERROR "Input file:\n ${d}\ndoes not have expected content, but [[${lines}]]") + endif() +endforeach() foreach(n 1 2 3) string(REGEX REPLACE "_1_\\.my\\.dat$" "_${n}_.my.dat" SeriesCFile "${SeriesC}") if(NOT EXISTS "${SeriesCFile}") diff --git a/Tests/Module/ExternalData/Data2b.dat.md5 b/Tests/Module/ExternalData/Data2b.dat.md5 new file mode 100644 index 0000000000..70e39bd5d1 --- /dev/null +++ b/Tests/Module/ExternalData/Data2b.dat.md5 @@ -0,0 +1 @@ +8c018830e3efa5caf3c7415028335a57 diff --git a/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt index 35a8cc172a..03924cb5b7 100644 --- a/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt +++ b/Tests/RunCMake/ExternalData/SubDirectory1-stdout.txt @@ -1,2 +1,3 @@ --- Data reference correctly transformed in parent dir! +-- Data reference correctly transformed in parent dir 1! +-- Data reference correctly transformed in parent dir 2! -- Data reference correctly transformed in current dir! diff --git a/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt index 07824608cd..881ff5c2c0 100644 --- a/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt +++ b/Tests/RunCMake/ExternalData/SubDirectory1/CMakeLists.txt @@ -2,7 +2,17 @@ set(input ../Data.txt) set(output ${CMAKE_BINARY_DIR}/Data.txt) ExternalData_Expand_Arguments(Data args DATA{${input}}) if("x${args}" STREQUAL "x${output}") - message(STATUS "Data reference correctly transformed in parent dir!") + message(STATUS "Data reference correctly transformed in parent dir 1!") +else() + message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() + +set(input ${CMAKE_CURRENT_SOURCE_DIR}/../Data.txt) +set(output ${CMAKE_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Data reference correctly transformed in parent dir 2!") else() message(FATAL_ERROR "Data reference transformed to:\n ${args}\n" "but we expected:\n ${output}") From fc2638f0b43f88683b6d8251be92119f4a3b3f1b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 31 Jan 2013 00:01:16 -0500 Subject: [PATCH 66/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2010f63d01..7e9cc407a1 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130130) +set(CMake_VERSION_TWEAK 20130131) #set(CMake_VERSION_RC 1) From 30268b46f8237f25c82858693c000f5da8ede6ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 31 Jan 2013 11:18:49 +0100 Subject: [PATCH 67/94] Handle reading empty properties defined by the link interface. This was segfaulting before. --- Source/cmGeneratorExpressionEvaluator.cxx | 4 +++- Tests/CompatibleInterface/CMakeLists.txt | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index f74b69e5f4..55f54e464c 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -465,9 +465,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (target->IsLinkInterfaceDependentStringProperty(propertyName, context->Config)) { - return target->GetLinkInterfaceDependentStringProperty( + const char *propContent = + target->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); + return propContent ? propContent : ""; } return std::string(); diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 259b5a1860..329510b058 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -48,10 +48,22 @@ target_compile_definitions(CompatibleInterface add_library(iface2 SHARED iface2.cpp) generate_export_header(iface2) +set_property(TARGET iface2 APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING + Iface2_PROP +) + # For the LINK_LIBRARIES and related properties, we should not evaluate # properties defined only in the interface - they should be implicitly zero set_property(TARGET iface2 APPEND PROPERTY LINK_INTERFACE_LIBRARIES $<$>:nonexistant> ) -target_link_libraries(CompatibleInterface iface2) +target_link_libraries(CompatibleInterface iface2 + $<$>:nonexistant> +) +# Test that this does not segfault: +target_compile_definitions(CompatibleInterface + PRIVATE + $<$>:SOME_DEFINE> +) From 7ceeba992b4fb35ca05760b3170e68f41dfc1bb5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 30 Jan 2013 23:31:54 +0100 Subject: [PATCH 68/94] Advance more when preprocessing exported strings. When evaluating TARGET_PROPERTY here, we can skip to the comma location. We need to calculate it though as the string may have just been changed. --- Source/cmExportFileGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index dbe64e97e5..e7723279ec 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -391,7 +391,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( { input.replace(nameStartPos, commaPos - nameStartPos, targetName); } - lastPos = pos + targetName.size(); + lastPos = nameStartPos + targetName.size() + 1; } std::string errorString; From 19f3208a0662113acbbb42178bf83a1f7ce73cac Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Jan 2013 14:18:22 -0500 Subject: [PATCH 69/94] Tests: Avoid CTestLimitDashJ crash on Borland 5.8 builds The test added by commit e378ba5f (Add CTestLimitDashJ test, 2012-12-26) crashes with CTest compiled by Borland 5.8. There seems to be interaction among the large number of internal ctest runs. It is probably related to the undiscovered underlying issue mentioned in commit 32478069 (CTest: Prevent creation of unbounded number of tests in ctest, 2012-12-18) when fixing the symptom covered by the CTestLimitDashJ test. Add --force-new-ctest-process to avoid the crash. Further investigation will still be needed to identify the true problem. --- Tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0c75892384..10291f7afa 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1977,6 +1977,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" ) + set(CTestLimitDashJ_EXTRA_OPTIONS --force-new-ctest-process) add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4 --output-on-failure -C "\${CTestTest_CONFIG}") From 9397270d73dc239cde41ddaa9a3f05a75a2cd873 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 31 Jan 2013 09:31:58 -0500 Subject: [PATCH 70/94] Fix use of cmTypeMacro in new command classes Both commit 8a37ebec (Add the target_include_directories command, 2013-01-01) and commit fc61a7a7 (Add the target_compile_definitions command, 2013-01-08) added command implementations deriving from the new cmTargetPropCommandBase class. Fix cmTypeMacro declarations of the inheritance relationship. --- Source/cmTargetCompileDefinitionsCommand.h | 2 +- Source/cmTargetIncludeDirectoriesCommand.h | 2 +- Source/cmTargetPropCommandBase.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 3b438207c4..c93cacb3f5 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -75,7 +75,7 @@ public: ; } - cmTypeMacro(cmTargetCompileDefinitionsCommand, cmCommand); + cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase); private: virtual void HandleImportedTarget(const std::string &tgt); diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index d02cb4a2f1..2bc7bef058 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -79,7 +79,7 @@ public: ; } - cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmCommand); + cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase); private: virtual void HandleImportedTarget(const std::string &tgt); diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index a5b4ff8235..8047a48aa3 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -31,6 +31,7 @@ public: bool HandleArguments(std::vector const& args, const char *prop, ArgumentFlags flags = NO_FLAGS); + cmTypeMacro(cmTargetPropCommandBase, cmCommand); protected: std::string Property; cmTarget *Target; From df4d2b28b24a3172daf1290070199633f7c46cf0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 30 Jan 2013 17:49:47 +0100 Subject: [PATCH 71/94] Make it an error for INSTALL_PREFIX to be evaluated. An empty string is not likely going to produce expected results in any evaluation context. It is replaced by preprocessing currently. --- Source/cmGeneratorExpressionEvaluator.cxx | 9 ++++++--- Tests/GeneratorExpression/CMakeLists.txt | 1 - Tests/GeneratorExpression/check-part2.cmake | 1 - .../GeneratorExpression/BadInstallPrefix-result.txt | 1 + .../GeneratorExpression/BadInstallPrefix-stderr.txt | 9 +++++++++ .../RunCMake/GeneratorExpression/BadInstallPrefix.cmake | 3 +++ Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake | 1 + 7 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 Tests/RunCMake/GeneratorExpression/BadInstallPrefix-result.txt create mode 100644 Tests/RunCMake/GeneratorExpression/BadInstallPrefix-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/BadInstallPrefix.cmake diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 55f54e464c..fff7dab096 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -621,14 +621,17 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode { InstallPrefixNode() {} - virtual bool GeneratesContent() const { return false; } + virtual bool GeneratesContent() const { return true; } virtual int NumExpectedParameters() const { return 0; } std::string Evaluate(const std::vector &, - cmGeneratorExpressionContext *, - const GeneratorExpressionContent *, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *) const { + reportError(context, content->GetOriginalExpression(), + "INSTALL_PREFIX is a marker for install(EXPORT) only. It " + "should never be evaluated."); return std::string(); } diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index a40a54124a..ecbbedf446 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -89,7 +89,6 @@ add_custom_target(check-part2 ALL -Dtest_install_interface=$ -Dtest_target_name_1=$ -Dtest_target_name_2=$ - -Dtest_install_prefix=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 2)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part2.cmake b/Tests/GeneratorExpression/check-part2.cmake index 0b502045d7..8855a977c5 100644 --- a/Tests/GeneratorExpression/check-part2.cmake +++ b/Tests/GeneratorExpression/check-part2.cmake @@ -26,4 +26,3 @@ check(test_build_interface "build") check(test_install_interface "") check(test_target_name_1 "tgt,ok") check(test_target_name_2 "tgt:ok") -check(test_install_prefix "") diff --git a/Tests/RunCMake/GeneratorExpression/BadInstallPrefix-result.txt b/Tests/RunCMake/GeneratorExpression/BadInstallPrefix-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadInstallPrefix-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/BadInstallPrefix-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadInstallPrefix-stderr.txt new file mode 100644 index 0000000000..271eb6e6fb --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadInstallPrefix-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at BadInstallPrefix.cmake:1 \(add_custom_target\): + Error evaluating generator expression: + + \$ + + INSTALL_PREFIX is a marker for install\(EXPORT\) only. It should never be + evaluated. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadInstallPrefix.cmake b/Tests/RunCMake/GeneratorExpression/BadInstallPrefix.cmake new file mode 100644 index 0000000000..fcfc3ebaae --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadInstallPrefix.cmake @@ -0,0 +1,3 @@ +add_custom_target(check ALL COMMAND check + $/include + VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 8a69675943..62bf29bc92 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -7,3 +7,4 @@ run_cmake(BadNOT) run_cmake(BadStrEqual) run_cmake(BadZero) run_cmake(BadTargetName) +run_cmake(BadInstallPrefix) From d4297d5697cd10114f8accb7a233aa1f5ebc50ab Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 30 Jan 2013 08:24:59 +0100 Subject: [PATCH 72/94] Export targets to a targets file, not a Config file. --- Tests/ExportImport/Export/CMakeLists.txt | 4 ++-- Tests/ExportImport/Import/A/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 47521d8ba8..ae44c28417 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -234,10 +234,10 @@ install(TARGETS testLibRequired testLibIncludeRequired6 testSharedLibRequired EXPORT RequiredExp DESTINATION lib ) -install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired) +install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired) install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib ) -install(EXPORT DependsExp FILE testLibDependsConfig.cmake DESTINATION lib/cmake/testLibDepends) +install(EXPORT DependsExp FILE testLibDependsTargets.cmake DESTINATION lib/cmake/testLibDepends) # Install and export from install tree. diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index e9bd2bac03..067559466f 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -5,8 +5,8 @@ include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake) include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake) # Import two exports, where the Depends one depends on an exported target from the Required one: -include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredConfig.cmake) -include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsConfig.cmake) +include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredTargets.cmake) +include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsTargets.cmake) # Try referencing an executable imported from the install tree. add_custom_command( From 2c3654c3de718fe822f8960063373774fc019494 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 29 Jan 2013 16:32:51 +0100 Subject: [PATCH 73/94] Add a way to exclude INTERFACE properties from exported targets. Projects set interface requirements upstream, and existing downstreams use of target_link_libraries will consume those interfaces. This can create a backward compatibility concern as the result may be changing the order of include directories of downstreams, or another side-effect of using the INTERFACE properties. Provide a way for them to emulate the behavior of a version-based policy in the config file. --- Source/cmExportFileGenerator.cxx | 7 ++++--- Source/cmFindPackageCommand.cxx | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e7723279ec..2ecac8477f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -264,15 +264,16 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, { if (!properties.empty()) { + os << "if(NOT ${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES)\n"; std::string targetName = this->Namespace; targetName += target->GetName(); - os << "set_target_properties(" << targetName << " PROPERTIES\n"; + os << " set_target_properties(" << targetName << " PROPERTIES\n"; for(ImportPropertyMap::const_iterator pi = properties.begin(); pi != properties.end(); ++pi) { - os << " " << pi->first << " \"" << pi->second << "\"\n"; + os << " " << pi->first << " \"" << pi->second << "\"\n"; } - os << ")\n\n"; + os << " )\nendif()\n\n"; } } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 470cecabec..e9b6ab6369 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -376,6 +376,27 @@ void cmFindPackageCommand::GenerateDocumentation() "The package configuration file may set _FOUND to false " "to tell find_package that component requirements are not satisfied." "\n" + "Targets exported by the install() command may have additional INTERFACE " + "properties set for include directories, compile definitions etc. As " + "these may create a backward compatibility concern for consumers of " + "existing projects, it is possible to set the _NO_INTERFACES " + "variable to disable populating those interfaces. It is possible to " + "emulate a version-based policy for whether the interfaces should be " + "enabled in the config file before including the imported targets file. " + "This allows consumers to decide when to enable the new interfaces when " + "upgrading. The upstream project is responsible for adding code similar " + "to this in the version which generates the INTERFACE content:\n" + " if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3\n" + " AND NOT ${CMAKE_FIND_PACKAGE_NAME}_INTERFACES)\n" + " set(${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1)\n" + " endif()\n" + " include(\"${CMAKE_CURRENT_LIST_DIR}/Targets.cmake\")\n" + "\n" + "Downstream users may then choose to use the new interfaces by finding " + "the newer version of upstream. They can also choose to not use the new " + "interfaces by setting _INTERFACES to false before finding the " + "package.\n" + "\n" "See the cmake_policy() command documentation for discussion of the " "NO_POLICY_SCOPE option." ; From 0fa7f69c0e2cdcd8b7ece400651ee7821b2ede4b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 30 Jan 2013 23:35:22 +0100 Subject: [PATCH 74/94] Add API to check if we're reading a includes or defines property. This will allow the implementation of the LINKED generator expression. --- Source/cmGeneratorExpressionDAGChecker.cxx | 16 ++++++++++++++++ Source/cmGeneratorExpressionDAGChecker.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 269211b92b..bcb082071f 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -125,3 +125,19 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries() || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 26) == 0 || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 35) == 0); } + +//---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::EvaluatingIncludeDirectories() +{ + const char *prop = this->Property.c_str(); + return (strcmp(prop, "INCLUDE_DIRECTORIES") == 0 + || strcmp(prop, "INTERFACE_INCLUDE_DIRECTORIES") == 0 ); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() +{ + const char *prop = this->Property.c_str(); + return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 + || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 ); +} diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 31692910da..7e9c62a792 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -37,6 +37,8 @@ struct cmGeneratorExpressionDAGChecker const std::string &expr); bool EvaluatingLinkLibraries(); + bool EvaluatingIncludeDirectories(); + bool EvaluatingCompileDefinitions(); private: Result checkGraph() const; From 0b92602b816e2584db3781b120a1e5200da72ada Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 30 Jan 2013 23:38:04 +0100 Subject: [PATCH 75/94] Add the $ generator expression. This is both a short form of using a TARGET_DEFINED expression together with a TARGET_PROPERTY definition, and a way to strip non-target content from interface properties when exporting. --- Source/cmDocumentGeneratorExpressions.h | 8 ++ Source/cmExportFileGenerator.cxx | 66 ++++++++++++-- Source/cmExportFileGenerator.h | 4 +- Source/cmGeneratorExpressionEvaluator.cxx | 85 +++++++++++++++++++ .../target_compile_definitions/CMakeLists.txt | 6 ++ .../target_compile_definitions/consumer.cpp | 4 + .../target_include_directories/CMakeLists.txt | 11 ++- .../target_include_directories/consumer.cpp | 5 ++ .../BadLinked-result.txt | 1 + .../BadLinked-stderr.txt | 7 ++ .../BadLinked.cmake | 7 ++ .../RunCMakeTest.cmake | 1 + 12 files changed, 196 insertions(+), 9 deletions(-) create mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt create mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt create mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index 8b80a8a321..3993f7d72c 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -51,6 +51,14 @@ "on the target tgt.\n" \ "Note that tgt is not added as a dependency of the target this " \ "expression is evaluated on.\n" \ + " $ = An empty string if item is not a " \ + "target. If item is a target then the " \ + "INTERFACE_INCLUDE_DIRECTORIES or INTERFACE_COMPILE_DEFINITIONS " \ + "content is read from the target. " \ + "This generator expression can only be used in evaluation of the " \ + "INCLUDE_DIRECTORIES or COMPILE_DEFINITIONS property. Note that " \ + "this expression is for internal use and may be changed or removed " \ + "in the future.\n" \ " $ = '1' if the policy was NEW when " \ "the 'head' target was created, else '0'. If the policy was not " \ "set, the warning message for the policy will be emitted. This " \ diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 2ecac8477f..7e4c3dfe5a 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -25,6 +25,8 @@ #include +#include "assert.h" + //---------------------------------------------------------------------------- cmExportFileGenerator::cmExportFileGenerator() { @@ -160,7 +162,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, propName, missingTargets); properties[outputName] = prepro; } @@ -324,13 +326,14 @@ static bool isGeneratorExpression(const std::string &lib) void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, - cmTarget* target, + cmTarget* target, const char *propName, std::vector &missingTargets, FreeTargetsReplace replace) { if (replace == NoReplaceFreeTargets) { - this->ResolveTargetsInGeneratorExpression(input, target, missingTargets); + this->ResolveTargetsInGeneratorExpression(input, target, propName, + missingTargets); return; } std::vector parts; @@ -349,7 +352,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( { this->ResolveTargetsInGeneratorExpression( *li, - target, + target, propName, missingTargets); } input += sep + *li; @@ -361,7 +364,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string &input, - cmTarget* target, + cmTarget* target, const char *propName, std::vector &missingTargets) { std::string::size_type pos = 0; @@ -396,6 +399,57 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( } std::string errorString; + pos = 0; + lastPos = pos; + while((pos = input.find("$", nameStartPos); + if (endPos == input.npos) + { + errorString = "$ expression incomplete"; + break; + } + std::string targetName = input.substr(nameStartPos, + endPos - nameStartPos); + if(targetName.find("$<") != input.npos) + { + errorString = "$ requires its parameter to be a " + "literal."; + break; + } + if (this->AddTargetNamespace(targetName, target, missingTargets)) + { + assert(propName); // The link libraries strings will + // never contain $ + std::string replacement = "$IssueMessage(cmake::FATAL_ERROR, errorString); + return; + } + pos = 0; lastPos = pos; while((pos = input.find("$ResolveTargetsInGeneratorExpressions(prepro, target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, 0, missingTargets, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 776be614d3..5ad27bfaf7 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -119,7 +119,7 @@ protected: }; void ResolveTargetsInGeneratorExpressions(std::string &input, - cmTarget* target, + cmTarget* target, const char *propName, std::vector &missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); @@ -150,7 +150,7 @@ private: std::vector &missingTargets); void ResolveTargetsInGeneratorExpression(std::string &input, - cmTarget* target, + cmTarget* target, const char *propName, std::vector &missingTargets); virtual void ReplaceInstallPrefix(std::string &input); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index fff7dab096..cbea1d9f51 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -637,6 +637,89 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode } installPrefixNode; +//---------------------------------------------------------------------------- +static const struct LinkedNode : public cmGeneratorExpressionNode +{ + LinkedNode() {} + + virtual bool GeneratesContent() const { return true; } + virtual int NumExpectedParameters() const { return 1; } + virtual bool RequiresLiteralInput() const { return true; } + + std::string Evaluate(const std::vector ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *dagChecker) const + { + if (dagChecker->EvaluatingIncludeDirectories()) + { + return this->GetInterfaceProperty(parameters.front(), + "INCLUDE_DIRECTORIES", + context, content, dagChecker); + } + if (dagChecker->EvaluatingCompileDefinitions()) + { + return this->GetInterfaceProperty(parameters.front(), + "COMPILE_DEFINITIONS", + context, content, dagChecker); + } + + reportError(context, content->GetOriginalExpression(), + "$ may only be used in INCLUDE_DIRECTORIES and " + "COMPILE_DEFINITIONS properties."); + + return std::string(); + } + +private: + std::string GetInterfaceProperty(const std::string &item, + const std::string &prop, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *dagCheckerParent) const + { + cmTarget *target = context->CurrentTarget + ->GetMakefile()->FindTargetToUse(item.c_str()); + if (!target) + { + return std::string(); + } + std::string propertyName = "INTERFACE_" + prop; + const char *propContent = target->GetProperty(propertyName.c_str()); + if (!propContent) + { + return std::string(); + } + + cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, + target->GetName(), + propertyName, + content, + dagCheckerParent); + + switch (dagChecker.check()) + { + case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: + dagChecker.reportError(context, content->GetOriginalExpression()); + return std::string(); + case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: + // No error. We just skip cyclic references. + return std::string(); + case cmGeneratorExpressionDAGChecker::DAG: + break; + } + + cmGeneratorExpression ge(context->Backtrace); + return ge.Parse(propContent)->Evaluate(context->Makefile, + context->Config, + context->Quiet, + context->HeadTarget, + target, + &dagChecker); + } + +} linkedNode; + //---------------------------------------------------------------------------- template struct TargetFilesystemArtifactResultCreator @@ -874,6 +957,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &targetDefinedNode; else if (identifier == "INSTALL_PREFIX") return &installPrefixNode; + else if (identifier == "LINKED") + return &linkedNode; return 0; } diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 8a4437ba54..0bfcc1b1b9 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -16,9 +16,15 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) +add_library(linked UNKNOWN IMPORTED) +set_property(TARGET linked PROPERTY + INTERFACE_COMPILE_DEFINITIONS "MY_LINKED_DEFINE") + + target_compile_definitions(consumer PRIVATE $ $<$:SHOULD_NOT_BE_DEFINED> $<$:SHOULD_BE_DEFINED> + $ -DDASH_D_DEFINE ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index 1a46aa50cf..c077593583 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -23,4 +23,8 @@ #error Expected DASH_D_DEFINE #endif +#ifndef MY_LINKED_DEFINE +#error Expected MY_LINKED_DEFINE +#endif + int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 7529283783..a564918073 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -17,6 +17,9 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be i file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cure") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cure/common.h" "#define CURE_DEFINE\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/linkedinclude") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/linkedinclude/linkedinclude.h" "#define LINKEDINCLUDE_DEFINE\n") + add_executable(target_include_directories "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ) @@ -42,7 +45,13 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) +add_library(linked UNKNOWN IMPORTED) +set_property(TARGET linked PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/linkedinclude") + target_include_directories(consumer - PRIVATE $ + PRIVATE + $ + $ relative_dir ) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 82b800a40a..ccffd9cabb 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -3,6 +3,7 @@ #include "publicinclude.h" #include "interfaceinclude.h" #include "relative_dir.h" +#include "linkedinclude.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -24,4 +25,8 @@ #error Expected RELATIVE_DIR_DEFINE #endif +#ifndef LINKEDINCLUDE_DEFINE +#error Expected LINKEDINCLUDE_DEFINE +#endif + int main() { return 0; } diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt new file mode 100644 index 0000000000..4cd9cdd156 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt @@ -0,0 +1,7 @@ +CMake Error: + Error evaluating generator expression: + + \$ + + \$ may only be used in INCLUDE_DIRECTORIES and + COMPILE_DEFINITIONS properties.$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake new file mode 100644 index 0000000000..542ea760e7 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake @@ -0,0 +1,7 @@ + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "int main(int, char **) { return 0; }\n") + +add_executable(TargetPropertyGeneratorExpressions + "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(TargetPropertyGeneratorExpressions "$") diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index 0ee32387d6..ea48f61a84 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -15,3 +15,4 @@ run_cmake(BadInvalidName5) run_cmake(BadInvalidName6) run_cmake(BadInvalidName7) run_cmake(BadInvalidName8) +run_cmake(BadLinked) From 77cecb778ff1882d87401c1055ec06585462f787 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 5 Nov 2012 12:43:28 +0100 Subject: [PATCH 76/94] Add includes and compile definitions with target_link_libraries. This establishes that linking is used to propagate usage-requirements between targets in CMake code. The use of the target_link_libraries command as the API for this is chosen because introducing a new command would introduce confusion due to multiple commands which differ only in a subtle way. --- Source/cmTarget.h | 6 +-- Source/cmTargetLinkLibrariesCommand.cxx | 53 +++++++++++++++++++ Source/cmTargetLinkLibrariesCommand.h | 9 ++++ .../target_link_libraries/CMakeLists.txt | 25 +++++++-- .../target_link_libraries/depG.cpp | 7 +++ .../target_link_libraries/depG.h | 7 +++ .../target_link_libraries/targetC.cpp | 16 ++++++ Tests/ExportImport/Export/CMakeLists.txt | 37 +++++++------ Tests/ExportImport/Import/A/CMakeLists.txt | 14 +---- Tests/ExportImport/Import/CMakeLists.txt | 5 ++ .../Import/package_new_new/CMakeLists.txt | 23 ++++++++ .../Import/package_new_old/CMakeLists.txt | 24 +++++++++ .../Import/package_old_old/CMakeLists.txt | 24 +++++++++ Tests/Qt4Targets/CMakeLists.txt | 19 ------- 14 files changed, 213 insertions(+), 56 deletions(-) create mode 100644 Tests/CMakeCommands/target_link_libraries/depG.cpp create mode 100644 Tests/CMakeCommands/target_link_libraries/depG.h create mode 100644 Tests/CMakeCommands/target_link_libraries/targetC.cpp create mode 100644 Tests/ExportImport/Import/package_new_new/CMakeLists.txt create mode 100644 Tests/ExportImport/Import/package_new_old/CMakeLists.txt create mode 100644 Tests/ExportImport/Import/package_old_old/CMakeLists.txt diff --git a/Source/cmTarget.h b/Source/cmTarget.h index cf2d4c4638..7577a59413 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -514,6 +514,9 @@ public: const char *GetLinkInterfaceDependentStringProperty(const std::string &p, const char *config); + + std::string GetDebugGeneratorExpressions(const std::string &value, + cmTarget::LinkLibraryType llt); private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. @@ -659,9 +662,6 @@ private: void ProcessSourceExpression(std::string const& expr); - std::string GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt); - // The cmMakefile instance that owns this target. This should // always be set. cmMakefile* Makefile; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index f42b0f6874..cb913f57a5 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -249,11 +249,52 @@ cmTargetLinkLibrariesCommand this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); } +//---------------------------------------------------------------------------- +static std::string compileProperty(cmTarget *tgt, const std::string &lib, + bool isGenex, + const std::string &property, + cmTarget::LinkLibraryType llt) +{ + std::string value = !isGenex ? "$" + : "$<$:" + + "$" + ">"; + + return tgt->GetDebugGeneratorExpressions(value, llt); +} + +//---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + //---------------------------------------------------------------------------- void cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt) { + const bool isGenex = isGeneratorExpression(lib); + + cmsys::RegularExpression targetNameValidator; + targetNameValidator.compile("^[A-Za-z0-9_.:-]+$"); + const bool potentialTargetName = targetNameValidator.find(lib); + + if (potentialTargetName || isGenex) + { + this->Target->AppendProperty("INCLUDE_DIRECTORIES", + compileProperty(this->Target, lib, + isGenex, + "INCLUDE_DIRECTORIES", llt).c_str()); + this->Target->AppendProperty("COMPILE_DEFINITIONS", + compileProperty(this->Target, lib, + isGenex, + "COMPILE_DEFINITIONS", llt).c_str()); + } + // Handle normal case first. if(this->CurrentProcessingState != ProcessingLinkInterface) { @@ -266,6 +307,18 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, } } + if (potentialTargetName || isGenex) + { + this->Target->AppendProperty("INTERFACE_COMPILE_DEFINITIONS", + compileProperty(this->Target, lib, + isGenex, + "COMPILE_DEFINITIONS", llt).c_str()); + this->Target->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", + compileProperty(this->Target, lib, + isGenex, + "INCLUDE_DIRECTORIES", llt).c_str()); + } + // Get the list of configurations considered to be DEBUG. std::vector const& debugConfigs = this->Makefile->GetCMakeInstance()->GetDebugConfigs(); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 3da395089a..aaabdfa3aa 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -97,6 +97,15 @@ public: "Calls to other signatures of this command may set the property " "making any libraries linked exclusively by this signature private." "\n" + "Target usage requirements are also consumed by this command. If the " + " is linked to another target which has " + "a populated INTERFACE_INCLUDE_DIRECTORIES, the content of it is " + "appended to the INCLUDE_DIRECTORIES of . Similarly, the " + "INTERFACE_COMPILE_DEFINITONS of a dependee are added to the " + "COMPILE_DEFINITONS of , and the " + "INTERFACE_POSITION_INDEPENDENT_CODE property is used to determine the " + "POSITION_INDEPENDENT_CODE property of ." + "\n" " target_link_libraries( LINK_INTERFACE_LIBRARIES\n" " [[debug|optimized|general] ] ...)\n" "The LINK_INTERFACE_LIBRARIES mode appends the libraries " diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index 1d0e342f3b..cd0fe1129d 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -62,10 +62,6 @@ assert_property(targetA LINK_INTERFACE_LIBRARIES "") add_subdirectory(subdir) target_link_libraries(targetA subdirlib) -set_property(TARGET targetA APPEND PROPERTY - INCLUDE_DIRECTORIES - $ -) target_link_libraries(targetA depB depC) @@ -87,3 +83,24 @@ set_property(TARGET depD APPEND PROPERTY add_executable(targetB targetB.cpp) target_link_libraries(targetB depD) + +macro(create_header _name) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" "//${_name}.h\n") +endmacro() + +create_header(foo) +create_header(bar) + +add_library(depG SHARED depG.cpp) +generate_export_header(depG) +target_include_directories(depG INTERFACE + "${CMAKE_CURRENT_BINARY_DIR}/foo" + "${CMAKE_CURRENT_BINARY_DIR}/bar" +) +target_compile_definitions(depG INTERFACE + TEST_DEF +) + +add_executable(targetC targetC.cpp) +target_link_libraries(targetC depG) diff --git a/Tests/CMakeCommands/target_link_libraries/depG.cpp b/Tests/CMakeCommands/target_link_libraries/depG.cpp new file mode 100644 index 0000000000..65b9655c56 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depG.cpp @@ -0,0 +1,7 @@ + +#include "depG.h" + +int DepG::foo() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depG.h b/Tests/CMakeCommands/target_link_libraries/depG.h new file mode 100644 index 0000000000..1a36589141 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depG.h @@ -0,0 +1,7 @@ + +#include "depg_export.h" + +struct DEPG_EXPORT DepG +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/targetC.cpp b/Tests/CMakeCommands/target_link_libraries/targetC.cpp new file mode 100644 index 0000000000..ff6ba660ff --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/targetC.cpp @@ -0,0 +1,16 @@ + +#include "depG.h" + +#include "foo.h" +#include "bar.h" + +#ifndef TEST_DEF +#error Expected TEST_DEF definition +#endif + +int main(int argc, char **argv) +{ + DepG g; + + return g.foo(); +} diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index ae44c28417..ae938cd54f 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -90,23 +90,7 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3) # Test exporting dependent libraries into different exports add_library(testLibRequired testLibRequired.c) add_library(testLibDepends testLibDepends.c) -set_property(TARGET testLibDepends APPEND PROPERTY - INCLUDE_DIRECTORIES - $ -) -set_property(TARGET testLibDepends APPEND PROPERTY - COMPILE_DEFINITIONS - $ -) -set_property(TARGET testLibDepends APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES - $ -) -set_property(TARGET testLibDepends APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS - $ -) -target_link_libraries(testLibDepends testLibRequired) +target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired) macro(add_include_lib _libName) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "// no content\n") @@ -239,6 +223,25 @@ install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DES install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib ) install(EXPORT DependsExp FILE testLibDependsTargets.cmake DESTINATION lib/cmake/testLibDepends) +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfig.cmake" + " +if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3 AND NOT \${CMAKE_FIND_PACKAGE_NAME}_INTERFACES) + set(\${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1) +endif() +include(\"\${CMAKE_CURRENT_LIST_DIR}/testLibRequiredTargets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS \"${CMAKE_CURRENT_BINARY_DIR}\" \"${CMAKE_CURRENT_SOURCE_DIR}\" ) +" +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( testLibRequiredConfigVersion.cmake VERSION 2.5 COMPATIBILITY AnyNewerVersion) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfigVersion.cmake" + DESTINATION lib/cmake/testLibRequired +) # Install and export from install tree. install( diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 067559466f..0337130f49 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -159,18 +159,11 @@ endif() add_executable(deps_iface deps_iface.c) target_link_libraries(deps_iface testLibDepends) -target_include_directories(deps_iface PRIVATE $) -target_compile_definitions(deps_iface PRIVATE $) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) -target_include_directories(deps_shared_iface - PRIVATE - $ -) target_compile_definitions(deps_shared_iface PRIVATE - $ $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> $<$,testcontent>:CUSTOM_STRING_IS_MATCH> @@ -200,13 +193,8 @@ endif() add_executable(deps_shared_iface2 deps_shared_iface.cpp) target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) -target_include_directories(deps_shared_iface2 - PRIVATE - $ - $ -) target_compile_definitions(deps_shared_iface2 - PRIVATE $ TEST_SUBDIR_LIB + PRIVATE TEST_SUBDIR_LIB $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> $<$,testcontent>:CUSTOM_STRING_IS_MATCH> diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 3fc78a280c..237f8faa88 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -17,3 +17,8 @@ add_executable(imp_testTransExe1 imp_testTransExe1.c) target_link_libraries(imp_testTransExe1 imp_lib1) add_executable(imp_testTransExe1b imp_testTransExe1.c) target_link_libraries(imp_testTransExe1b imp_lib1b) + +# Test package INTERFACE controls +add_subdirectory(package_old_old) +add_subdirectory(package_new_old) +add_subdirectory(package_new_new) diff --git a/Tests/ExportImport/Import/package_new_new/CMakeLists.txt b/Tests/ExportImport/Import/package_new_new/CMakeLists.txt new file mode 100644 index 0000000000..4e6f642d3e --- /dev/null +++ b/Tests/ExportImport/Import/package_new_new/CMakeLists.txt @@ -0,0 +1,23 @@ + +cmake_minimum_required(VERSION 2.8) + +find_package(testLibRequired 2.5 REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + " +#include \"testSharedLibRequired.h\" +int main(int argc, char **argv) +{ + TestSharedLibRequired req; + return req.foo(); +} +" +) + +get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) +if (NOT prop) + message(SEND_ERROR "Interface of Req::testSharedLibRequired should not be empty") +endif() + +add_executable(new_new_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(new_new_test Req::testSharedLibRequired) diff --git a/Tests/ExportImport/Import/package_new_old/CMakeLists.txt b/Tests/ExportImport/Import/package_new_old/CMakeLists.txt new file mode 100644 index 0000000000..e675d64b8a --- /dev/null +++ b/Tests/ExportImport/Import/package_new_old/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 2.8) + +find_package(testLibRequired 2.5 REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + " +#include \"testSharedLibRequired.h\" +int main(int argc, char **argv) +{ + TestSharedLibRequired req; + return req.foo(); +} +" +) + +get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) +if ("${prop}" STREQUAL "") + message(SEND_ERROR "Interface of Req::testSharedLibRequired should not be empty") +endif() + +add_executable(new_old_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(new_old_test Req::testSharedLibRequired) +include_directories(${testLibRequired_INCLUDE_DIRS}) diff --git a/Tests/ExportImport/Import/package_old_old/CMakeLists.txt b/Tests/ExportImport/Import/package_old_old/CMakeLists.txt new file mode 100644 index 0000000000..3b27330423 --- /dev/null +++ b/Tests/ExportImport/Import/package_old_old/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 2.8) + +find_package(testLibRequired 2.1 REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + " +#include \"testSharedLibRequired.h\" +int main(int argc, char **argv) +{ + TestSharedLibRequired req; + return req.foo(); +} +" +) + +get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) +if (prop) + message(SEND_ERROR "Interface of Req::testSharedLibRequired should be empty, but is ${prop}") +endif() + +add_executable(old_old_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(old_old_test Req::testSharedLibRequired) +include_directories(${testLibRequired_INCLUDE_DIRS}) diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index d3aba74f12..d0c9c667a8 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -12,29 +12,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(Qt4Targets WIN32 main.cpp) target_link_libraries(Qt4Targets Qt4::QtGui) -set_property(TARGET Qt4Targets APPEND PROPERTY - INCLUDE_DIRECTORIES - $ -) -set_property(TARGET Qt4Targets APPEND PROPERTY - COMPILE_DEFINITIONS - $ -) - if (WIN32) if (TARGET Qt4::QAxServer) add_executable(activeqtexe WIN32 activeqtexe.cpp) set_property(TARGET activeqtexe PROPERTY QT4_NO_LINK_QTMAIN ON) target_link_libraries(activeqtexe Qt4::QAxServer Qt4::QtGui) - set_property(TARGET activeqtexe APPEND PROPERTY - INCLUDE_DIRECTORIES - $ - $ - ) - set_property(TARGET activeqtexe APPEND PROPERTY - COMPILE_DEFINITIONS - $ - $ - ) endif() endif() From e7b579bd01690f27c82ee9cbda4b7023f4a3d6c9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 21 Dec 2012 18:28:58 +0100 Subject: [PATCH 77/94] Test workaround of bad interface include directories from depends. --- .../TargetIncludeDirectories/CMakeLists.txt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 21159e0446..538737732d 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -82,3 +82,44 @@ add_custom_target(test_custom_target $ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bad") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bad/common.h" "#error Should not be included\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/good") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/good/common.h" "#include \"othergood.h\"\n") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/othergood") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/othergood/othergood.h" "// No error\n") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libothergood.cpp" "// No content \n") +add_library(libothergood "${CMAKE_CURRENT_BINARY_DIR}/libothergood.cpp") +set_property(TARGET libothergood APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/othergood" +) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libgood.cpp" "// No content \n") +add_library(libgood "${CMAKE_CURRENT_BINARY_DIR}/libgood.cpp") +set_property(TARGET libgood APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_BINARY_DIR}/good;$" +) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libbad.cpp" "// No content \n") +add_library(libbad "${CMAKE_CURRENT_BINARY_DIR}/libbad.cpp") +set_property(TARGET libbad APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bad" +) + + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib5.cpp" "#include \"common.h\"\n") +add_library(lib5 "${CMAKE_CURRENT_BINARY_DIR}/lib5.cpp") + +# Assuming the link order must be: +target_link_libraries(lib5 libbad libgood) + +# Oops!. +# As include directory order and link order are the same when using target_link_libraries, we have to +# get the libgood includes in before the libbad includes. +# We do that with this command: +target_include_directories(lib5 + BEFORE PRIVATE $ +) From 163812468054601c95ac894703a6299d3b324e22 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 1 Feb 2013 00:01:16 -0500 Subject: [PATCH 78/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7e9cc407a1..188a3dbad6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130131) +set(CMake_VERSION_TWEAK 20130201) #set(CMake_VERSION_RC 1) From 23ae48412093e4acbd5270536aace226d5869679 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 31 Jan 2013 08:21:49 -0500 Subject: [PATCH 79/94] KWSys 2013-01-31 (5b0d1bd9) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 5b0d1bd9 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 6fa1c99f..5b0d1bd9 Alan Hourihane (2): e81e2b72 DynamicLoader: Implement on Atari FreeMINT 5c4dcb2b ProcessUNIX: No select on Atari FreeMINT Sean McBride (2): bff2ea07 Glob: Fix clang -Wdocumentation warning 5b0d1bd9 Fix clang -Weverything warnings Change-Id: I8b342bea8bc9c7b92a856ddc948e1b56f5e74b98 --- DynamicLoader.cxx | 52 ++++++++++++++++++++++++++++++++++++ Glob.cxx | 2 +- IOStream.cxx | 1 + ProcessUNIX.c | 2 +- SystemInformation.cxx | 5 +++- SystemTools.cxx | 4 +-- testCommandLineArguments.cxx | 16 +++++------ testDynamicLoader.cxx | 2 +- testProcess.c | 22 +++++++-------- testSystemTools.cxx | 26 +++++++++--------- 10 files changed, 94 insertions(+), 38 deletions(-) diff --git a/DynamicLoader.cxx b/DynamicLoader.cxx index c4ee095519..fd83752c00 100644 --- a/DynamicLoader.cxx +++ b/DynamicLoader.cxx @@ -428,6 +428,58 @@ const char* DynamicLoader::LastError() } // namespace KWSYS_NAMESPACE #endif +#ifdef __MINT__ +#define DYNAMICLOADER_DEFINED 1 +#define _GNU_SOURCE /* for program_invocation_name */ +#include +#include +#include +#include + +namespace KWSYS_NAMESPACE +{ + +//---------------------------------------------------------------------------- +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +{ + char *name = (char *)calloc(1, strlen(libname) + 1); + dld_init(program_invocation_name); + strncpy(name, libname, strlen(libname)); + dld_link(libname); + return (void *)name; +} + +//---------------------------------------------------------------------------- +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + dld_unlink_by_file((char *)lib, 0); + free(lib); + return 0; +} + +//---------------------------------------------------------------------------- +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const char* sym) +{ + // Hack to cast pointer-to-data to pointer-to-function. + union + { + void* pvoid; + DynamicLoader::SymbolPointer psym; + } result; + result.pvoid = dld_get_symbol(sym); + return result.psym; +} + +//---------------------------------------------------------------------------- +const char* DynamicLoader::LastError() +{ + return dld_strerror(dld_errno); +} + +} // namespace KWSYS_NAMESPACE +#endif + // --------------------------------------------------------------- // 6. Implementation for default UNIX machines. // if nothing has been defined then use this diff --git a/Glob.cxx b/Glob.cxx index 513eb64086..46a7e4f44d 100644 --- a/Glob.cxx +++ b/Glob.cxx @@ -399,7 +399,7 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr) if ( last_slash > 0 ) { //kwsys_ios::cout << "I can skip: " << fexpr.substr(0, last_slash) - //<< kwsys_ios::endl; + // << kwsys_ios::endl; skip = last_slash; } if ( skip == 0 ) diff --git a/IOStream.cxx b/IOStream.cxx index 57b696eb35..a31f8c846a 100644 --- a/IOStream.cxx +++ b/IOStream.cxx @@ -272,6 +272,7 @@ namespace KWSYS_NAMESPACE // Create one public symbol in this object file to avoid warnings from // archivers. +void IOStreamSymbolToAvoidWarning(); void IOStreamSymbolToAvoidWarning() { } diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 2db12544ce..fc9e8bf670 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -102,7 +102,7 @@ static inline void kwsysProcess_usleep(unsigned int msec) * pipes' file handles to be non-blocking and just poll them directly * without select(). */ -#if !defined(__BEOS__) && !defined(__VMS) +#if !defined(__BEOS__) && !defined(__VMS) && !defined(__MINT__) # define KWSYSPE_USE_SELECT 1 #endif diff --git a/SystemInformation.cxx b/SystemInformation.cxx index b20d724589..f057e0fcb8 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -2466,7 +2466,9 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement() #endif } -void SystemInformationStripLeadingSpace(kwsys_stl::string& str) +#if USE_CPUID +// Used only in USE_CPUID implementation below. +static void SystemInformationStripLeadingSpace(kwsys_stl::string& str) { // Because some manufacturers have leading white space - we have to post-process the name. kwsys_stl::string::size_type pos = str.find_first_not_of(" "); @@ -2475,6 +2477,7 @@ void SystemInformationStripLeadingSpace(kwsys_stl::string& str) str = str.substr(pos); } } +#endif /** */ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() diff --git a/SystemTools.cxx b/SystemTools.cxx index b75993ea6a..881c49a37b 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3037,7 +3037,7 @@ void SystemTools::CheckTranslationPath(kwsys_stl::string & path) path.erase(path.end()-1, path.end()); } -void +static void SystemToolsAppendComponents( kwsys_stl::vector& out_components, kwsys_stl::vector::const_iterator first, @@ -4704,7 +4704,7 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL, // ---------------------------------------------------------------------- // These must NOT be initialized. Default initialization to zero is // necessary. -unsigned int SystemToolsManagerCount; +static unsigned int SystemToolsManagerCount; SystemToolsTranslationMap *SystemTools::TranslationMap; SystemToolsTranslationMap *SystemTools::LongPathMap; #ifdef __CYGWIN__ diff --git a/testCommandLineArguments.cxx b/testCommandLineArguments.cxx index e75a87e867..72e65447b1 100644 --- a/testCommandLineArguments.cxx +++ b/testCommandLineArguments.cxx @@ -24,9 +24,9 @@ #include /* size_t */ #include /* strcmp */ -void* random_ptr = reinterpret_cast(0x123); +static void* random_ptr = reinterpret_cast(0x123); -int argument(const char* arg, const char* value, void* call_data) +static int argument(const char* arg, const char* value, void* call_data) { kwsys_ios::cout << "Got argument: \"" << arg << "\" value: \"" << (value?value:"(null)") << "\"" << kwsys_ios::endl; if ( call_data != random_ptr ) @@ -37,7 +37,7 @@ int argument(const char* arg, const char* value, void* call_data) return 1; } -int unknown_argument(const char* argument, void* call_data) +static int unknown_argument(const char* argument, void* call_data) { kwsys_ios::cout << "Got unknown argument: \"" << argument << "\"" << kwsys_ios::endl; if ( call_data != random_ptr ) @@ -48,12 +48,12 @@ int unknown_argument(const char* argument, void* call_data) return 1; } -bool CompareTwoItemsOnList(bool i1, bool i2) { return i1 == i2; } -bool CompareTwoItemsOnList(int i1, int i2) { return i1 == i2; } -bool CompareTwoItemsOnList(double i1, double i2) { return i1 == i2; } -bool CompareTwoItemsOnList(const char* i1, +static bool CompareTwoItemsOnList(bool i1, bool i2) { return i1 == i2; } +static bool CompareTwoItemsOnList(int i1, int i2) { return i1 == i2; } +static bool CompareTwoItemsOnList(double i1, double i2) { return i1 == i2; } +static bool CompareTwoItemsOnList(const char* i1, const char* i2) { return strcmp(i1, i2) == 0; } -bool CompareTwoItemsOnList(const kwsys_stl::string& i1, +static bool CompareTwoItemsOnList(const kwsys_stl::string& i1, const kwsys_stl::string& i2) { return i1 == i2; } int testCommandLineArguments(int argc, char* argv[]) diff --git a/testDynamicLoader.cxx b/testDynamicLoader.cxx index cbfb65b1c1..61c157291e 100644 --- a/testDynamicLoader.cxx +++ b/testDynamicLoader.cxx @@ -35,7 +35,7 @@ // left on disk. #include -kwsys_stl::string GetLibName(const char* lname) +static kwsys_stl::string GetLibName(const char* lname) { // Construct proper name of lib kwsys_stl::string slname; diff --git a/testProcess.c b/testProcess.c index 269b84ba8f..6d5eb71fdb 100644 --- a/testProcess.c +++ b/testProcess.c @@ -47,7 +47,7 @@ int runChild(const char* cmd[], int state, int exception, int value, int share, int output, int delay, double timeout, int poll, int repeat, int disown); -int test1(int argc, const char* argv[]) +static int test1(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout from test returning 0.\n"); @@ -55,7 +55,7 @@ int test1(int argc, const char* argv[]) return 0; } -int test2(int argc, const char* argv[]) +static int test2(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout from test returning 123.\n"); @@ -63,7 +63,7 @@ int test2(int argc, const char* argv[]) return 123; } -int test3(int argc, const char* argv[]) +static int test3(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output before sleep on stdout from timeout test.\n"); @@ -80,7 +80,7 @@ int test3(int argc, const char* argv[]) return 0; } -int test4(int argc, const char* argv[]) +static int test4(int argc, const char* argv[]) { /* Prepare a pointer to an invalid address. Don't use null, because dereferencing null is undefined behaviour and compilers are free to @@ -109,7 +109,7 @@ int test4(int argc, const char* argv[]) return 0; } -int test5(int argc, const char* argv[]) +static int test5(int argc, const char* argv[]) { int r; const char* cmd[4]; @@ -132,7 +132,7 @@ int test5(int argc, const char* argv[]) } #define TEST6_SIZE (4096*2) -void test6(int argc, const char* argv[]) +static void test6(int argc, const char* argv[]) { int i; char runaway[TEST6_SIZE+1]; @@ -156,7 +156,7 @@ void test6(int argc, const char* argv[]) delaying 1/10th of a second should ever have to poll. */ #define MINPOLL 5 #define MAXPOLL 20 -int test7(int argc, const char* argv[]) +static int test7(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout before sleep.\n"); @@ -176,7 +176,7 @@ int test7(int argc, const char* argv[]) return 0; } -int test8(int argc, const char* argv[]) +static int test8(int argc, const char* argv[]) { /* Create a disowned grandchild to test handling of processes that exit before their children. */ @@ -200,7 +200,7 @@ int test8(int argc, const char* argv[]) return r; } -int test8_grandchild(int argc, const char* argv[]) +static int test8_grandchild(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout from grandchild before sleep.\n"); @@ -221,7 +221,7 @@ int test8_grandchild(int argc, const char* argv[]) return 0; } -int runChild2(kwsysProcess* kp, +static int runChild2(kwsysProcess* kp, const char* cmd[], int state, int exception, int value, int share, int output, int delay, double timeout, int poll, int disown) @@ -505,7 +505,7 @@ int main(int argc, const char* argv[]) fprintf(stderr, "Output on stderr after test %d.\n", n); fflush(stdout); fflush(stderr); -#if _WIN32 +#if defined(_WIN32) if(argv0) { free(argv0); } #endif return r; diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 3ac0cb399b..1690fd51ae 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -32,7 +32,7 @@ #include /* strcmp */ //---------------------------------------------------------------------------- -const char* toUnixPaths[][2] = +static const char* toUnixPaths[][2] = { { "/usr/local/bin/passwd", "/usr/local/bin/passwd" }, { "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" }, @@ -52,8 +52,8 @@ const char* toUnixPaths[][2] = {0, 0} }; -bool CheckConvertToUnixSlashes(kwsys_stl::string input, - kwsys_stl::string output) +static bool CheckConvertToUnixSlashes(kwsys_stl::string input, + kwsys_stl::string output) { kwsys_stl::string result = input; kwsys::SystemTools::ConvertToUnixSlashes(result); @@ -69,17 +69,17 @@ bool CheckConvertToUnixSlashes(kwsys_stl::string input, } //---------------------------------------------------------------------------- -const char* checkEscapeChars[][4] = +static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2"}, { " {} ", "{}", "#", " #{#} "}, {0, 0, 0, 0} }; -bool CheckEscapeChars(kwsys_stl::string input, - const char *chars_to_escape, - char escape_char, - kwsys_stl::string output) +static bool CheckEscapeChars(kwsys_stl::string input, + const char *chars_to_escape, + char escape_char, + kwsys_stl::string output) { kwsys_stl::string result = kwsys::SystemTools::EscapeChars( input.c_str(), chars_to_escape, escape_char); @@ -95,7 +95,7 @@ bool CheckEscapeChars(kwsys_stl::string input, } //---------------------------------------------------------------------------- -bool CheckFileOperations() +static bool CheckFileOperations() { bool res = true; @@ -129,7 +129,7 @@ bool CheckFileOperations() } //---------------------------------------------------------------------------- -bool CheckStringOperations() +static bool CheckStringOperations() { bool res = true; @@ -329,7 +329,7 @@ bool CheckStringOperations() //---------------------------------------------------------------------------- -bool CheckPutEnv(const char* env, const char* name, const char* value) +static bool CheckPutEnv(const char* env, const char* name, const char* value) { if(!kwsys::SystemTools::PutEnv(env)) { @@ -348,7 +348,7 @@ bool CheckPutEnv(const char* env, const char* name, const char* value) return true; } -bool CheckUnPutEnv(const char* env, const char* name) +static bool CheckUnPutEnv(const char* env, const char* name) { if(!kwsys::SystemTools::UnPutEnv(env)) { @@ -365,7 +365,7 @@ bool CheckUnPutEnv(const char* env, const char* name) return true; } -bool CheckEnvironmentOperations() +static bool CheckEnvironmentOperations() { bool res = true; res &= CheckPutEnv("A=B", "A", "B"); From 179f49560286e2e322b9b0cf5d0a277b7634540f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 1 Feb 2013 10:30:57 -0500 Subject: [PATCH 80/94] find_package: Reword _NO_INTERFACES documentation --- Source/cmFindPackageCommand.cxx | 35 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index e9b6ab6369..6e78bd7e59 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -376,26 +376,25 @@ void cmFindPackageCommand::GenerateDocumentation() "The package configuration file may set _FOUND to false " "to tell find_package that component requirements are not satisfied." "\n" - "Targets exported by the install() command may have additional INTERFACE " - "properties set for include directories, compile definitions etc. As " - "these may create a backward compatibility concern for consumers of " - "existing projects, it is possible to set the _NO_INTERFACES " - "variable to disable populating those interfaces. It is possible to " - "emulate a version-based policy for whether the interfaces should be " - "enabled in the config file before including the imported targets file. " - "This allows consumers to decide when to enable the new interfaces when " - "upgrading. The upstream project is responsible for adding code similar " - "to this in the version which generates the INTERFACE content:\n" - " if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3\n" - " AND NOT ${CMAKE_FIND_PACKAGE_NAME}_INTERFACES)\n" - " set(${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1)\n" + "A package configuration file may include() a Targets.cmake " + "file, created by install(EXPORT) in the upstream source, to import " + "targets into the downstream consumer. " + "When a new version of the upstream adds INTERFACE properties not " + "present in a previous version it can change behavior for existing " + "downstreams. " + "In order to remain source compatible the upstream package configuration " + "file may set _NO_INTERFACES to disable INTERFACE properties. " + "For example, code of the form:\n" + " if(_FIND_VERSION VERSION_LESS \n" + " AND NOT _INTERFACES)\n" + " set(_NO_INTERFACES 1)\n" " endif()\n" " include(\"${CMAKE_CURRENT_LIST_DIR}/Targets.cmake\")\n" - "\n" - "Downstream users may then choose to use the new interfaces by finding " - "the newer version of upstream. They can also choose to not use the new " - "interfaces by setting _INTERFACES to false before finding the " - "package.\n" + "tells Targets.cmake not to provide the INTERFACE properties " + "unless the downstream requests at least or sets " + "_INTERFACES to explicitly request them. " + "This allows consumers to decide when to enable the new interfaces when " + "upgrading." "\n" "See the cmake_policy() command documentation for discussion of the " "NO_POLICY_SCOPE option." From fd2a0d58c5d0aa0529d4ac65cc899f6d1109fb15 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Fri, 1 Feb 2013 23:23:09 +0100 Subject: [PATCH 81/94] Set WINCE to 1 when building for WindowsCE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce a new variable WINCE to make the WindowsCE system more easy to use in if statements. --- Modules/Platform/Windows-MSVC.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 5cbf9ee6bc..3a38d8fe72 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -41,6 +41,7 @@ set(WIN32 1) if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") set(CMAKE_CREATE_WIN32_EXE "/subsystem:windowsce /entry:WinMainCRTStartup") set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:windowsce /entry:mainACRTStartup") + set(WINCE 1) else() set(CMAKE_CREATE_WIN32_EXE "/subsystem:windows") set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:console") @@ -122,7 +123,7 @@ endif() # default to Debug builds set(CMAKE_BUILD_TYPE_INIT Debug) -if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") +if(WINCE) string(TOUPPER "${MSVC_C_ARCHITECTURE_ID}" _MSVC_C_ARCHITECTURE_ID_UPPER) string(TOUPPER "${MSVC_CXX_ARCHITECTURE_ID}" _MSVC_CXX_ARCHITECTURE_ID_UPPER) @@ -170,7 +171,7 @@ set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) if(NOT _MACHINE_ARCH_FLAG) set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) endif() -if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") +if(WINCE) if(_MACHINE_ARCH_FLAG MATCHES "ARM") set(_MACHINE_ARCH_FLAG "THUMB") elseif(_MACHINE_ARCH_FLAG MATCHES "SH") From 425c56788d30d85429f7d068c1d340dee99456a6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 2 Feb 2013 00:01:22 -0500 Subject: [PATCH 82/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 188a3dbad6..c9049caf91 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130201) +set(CMake_VERSION_TWEAK 20130202) #set(CMake_VERSION_RC 1) From 089fe1c13d8fa73be5182162a855c17351d1f918 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 1 Feb 2013 09:38:40 +0100 Subject: [PATCH 83/94] Optimize genex evaluation for includes and defines. While porting boost to use these features, the generation step took too long (several minutes before I stopped it). The reason was that the boost libraries form a large interdependent mesh. The libraries list their dependencies in their INTERFACE such as: $;$;$ As boost::core already depends on the boost::config libraries, that expression has no impact on the end-content, as it is removed after the generation step. There is no DAG issue though, so the generator expression evaluation would fully evaluate them. In the case of the config library, it also depends on the core library, so all depends are followed through that again, despite the fact that they've just been evaluated. After this patch, the evaluation skips libraries if they have already been seen via depends or directly in the content. This patch keeps track of targets whose INTERFACE has been consumed already. The INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS properties are whitelisted because repeated content will be stripped out later during generation. For other properties now and in the future, that may not be the case. --- Source/cmGeneratorExpressionDAGChecker.cxx | 26 ++++++++++++++++++++++ Source/cmGeneratorExpressionDAGChecker.h | 4 +++- Source/cmGeneratorExpressionEvaluator.cxx | 6 +++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index bcb082071f..b9069ef600 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -24,7 +24,33 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( : Parent(parent), Target(target), Property(property), Content(content), Backtrace(backtrace) { + const cmGeneratorExpressionDAGChecker *top = this; + const cmGeneratorExpressionDAGChecker *p = this->Parent; + while (p) + { + top = p; + p = p->Parent; + } this->CheckResult = this->checkGraph(); + + if (CheckResult == DAG && (top->Property == "INCLUDE_DIRECTORIES" + || top->Property == "COMPILE_DEFINITIONS") ) + { + std::map >::const_iterator it + = top->Seen.find(target); + if (it != top->Seen.end()) + { + const std::set &propSet = it->second; + const std::set::const_iterator i = propSet.find(property); + if (i != propSet.end()) + { + this->CheckResult = ALREADY_SEEN; + return; + } + } + const_cast(top) + ->Seen[target].insert(property); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 7e9c62a792..a2e5ce425d 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -28,7 +28,8 @@ struct cmGeneratorExpressionDAGChecker enum Result { DAG, SELF_REFERENCE, - CYCLIC_REFERENCE + CYCLIC_REFERENCE, + ALREADY_SEEN }; Result check() const; @@ -47,6 +48,7 @@ private: const cmGeneratorExpressionDAGChecker * const Parent; const std::string Target; const std::string Property; + std::map > Seen; const GeneratorExpressionContent * const Content; const cmListFileBacktrace Backtrace; Result CheckResult; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index cbea1d9f51..cd4b7d8051 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -435,6 +435,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: // No error. We just skip cyclic references. return std::string(); + case cmGeneratorExpressionDAGChecker::ALREADY_SEEN: + // No error. We're not going to find anything new here. + return std::string(); case cmGeneratorExpressionDAGChecker::DAG: break; } @@ -705,6 +708,9 @@ private: case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: // No error. We just skip cyclic references. return std::string(); + case cmGeneratorExpressionDAGChecker::ALREADY_SEEN: + // No error. We're not going to find anything new here. + return std::string(); case cmGeneratorExpressionDAGChecker::DAG: break; } From a25f26f54ffda4d115bf1768b3469086e10ecb48 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 3 Feb 2013 00:01:21 -0500 Subject: [PATCH 84/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c9049caf91..8f9917f7a0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130202) +set(CMake_VERSION_TWEAK 20130203) #set(CMake_VERSION_RC 1) From 0f24a667152c86982f7296b7df19f058c660d981 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 3 Feb 2013 11:47:52 -0500 Subject: [PATCH 85/94] VS 6: Create .rule file directory before file The VS 6 IDE wants .rule files to exist in order to run the rule attached to it. When creating the dummy .rule file make sure the directory exists. --- Source/cmLocalVisualStudio6Generator.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 6c78ac47ee..418eaa4d15 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -325,6 +325,9 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, if(!cmSystemTools::FileExists(source.c_str())) { cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); + // Make sure the path exists for the file + std::string path = cmSystemTools::GetFilenamePath(source); + cmSystemTools::MakeDirectory(path.c_str()); #if defined(_WIN32) || defined(__CYGWIN__) std::ofstream sourceFout(source.c_str(), std::ios::binary | std::ios::out From e48d84209cde93b43fcfb305897b4f52cd18a55f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 3 Feb 2013 07:33:15 +0100 Subject: [PATCH 86/94] Cache context-independent includes on evaluation. Generator expressions whose output depends on the configuration now record that fact. The GetIncludeDirectories method can use that result to cache the include directories for later calls. GetIncludeDirectories is called multiple times for a target for each configuration, so this should restore performance for multi-config generators. --- Source/cmGeneratorExpression.cxx | 8 ++++- Source/cmGeneratorExpression.h | 5 +++ Source/cmGeneratorExpressionEvaluator.cxx | 25 ++++++++++++-- Source/cmGeneratorExpressionEvaluator.h | 1 + Source/cmTarget.cxx | 41 +++++++++++++++++------ 5 files changed, 66 insertions(+), 14 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 78ae8f2583..7add1bf39f 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -88,6 +88,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( context.Config = config; context.Quiet = quiet; context.HadError = false; + context.HadContextSensitiveCondition = false; context.HeadTarget = headTarget; context.CurrentTarget = currentTarget ? currentTarget : headTarget; context.Backtrace = this->Backtrace; @@ -109,6 +110,10 @@ const char *cmCompiledGeneratorExpression::Evaluate( break; } } + if (!context.HadError) + { + this->HadContextSensitiveCondition = context.HadContextSensitiveCondition; + } this->Targets = context.Targets; // TODO: Return a std::string from here instead? @@ -118,7 +123,8 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, const char *input) - : Backtrace(backtrace), Input(input ? input : "") + : Backtrace(backtrace), Input(input ? input : ""), + HadContextSensitiveCondition(false) { cmGeneratorExpressionLexer l; std::vector tokens = diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 8f1aef6772..700fe033bb 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -100,6 +100,10 @@ public: { return this->Backtrace; } + bool GetHadContextSensitiveCondition() const + { + return this->HadContextSensitiveCondition; + } private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, @@ -118,6 +122,7 @@ private: mutable std::set Targets; mutable std::map SeenTargetProperties; mutable std::string Output; + mutable bool HadContextSensitiveCondition; }; #endif diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index cd4b7d8051..5d94718832 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -238,6 +238,7 @@ static const struct ConfigurationNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { + context->HadContextSensitiveCondition = true; return context->Config ? context->Config : ""; } } configurationNode; @@ -262,6 +263,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode "Expression syntax not recognized."); return std::string(); } + context->HadContextSensitiveCondition = true; if (!context->Config) { return parameters.front().empty() ? "1" : "0"; @@ -455,12 +457,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if (propertyName == "POSITION_INDEPENDENT_CODE") { + context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", context->Config) ? "1" : "0"; } if (target->IsLinkInterfaceDependentBoolProperty(propertyName, context->Config)) { + context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; @@ -468,6 +472,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (target->IsLinkInterfaceDependentStringProperty(propertyName, context->Config)) { + context->HadContextSensitiveCondition = true; const char *propContent = target->GetLinkInterfaceDependentStringProperty( propertyName, @@ -486,12 +491,19 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (targetPropertyTransitiveWhitelist[i] == propertyName) { cmGeneratorExpression ge(context->Backtrace); - return ge.Parse(prop)->Evaluate(context->Makefile, + cmsys::auto_ptr cge = ge.Parse(prop); + std::string result = cge->Evaluate(context->Makefile, context->Config, context->Quiet, context->HeadTarget, target, &dagChecker); + + if (cge->GetHadContextSensitiveCondition()) + { + context->HadContextSensitiveCondition = true; + } + return result; } } return prop; @@ -585,6 +597,9 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode "be used with add_custom_command."); return std::string(); } + + context->HadContextSensitiveCondition = true; + for (size_t i = 0; i < (sizeof(targetPolicyWhitelist) / sizeof(*targetPolicyWhitelist)); @@ -716,12 +731,18 @@ private: } cmGeneratorExpression ge(context->Backtrace); - return ge.Parse(propContent)->Evaluate(context->Makefile, + cmsys::auto_ptr cge = ge.Parse(propContent); + std::string result = cge->Evaluate(context->Makefile, context->Config, context->Quiet, context->HeadTarget, target, &dagChecker); + if (cge->GetHadContextSensitiveCondition()) + { + context->HadContextSensitiveCondition = true; + } + return result; } } linkedNode; diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index fb6c7eee55..37d5c864f8 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -32,6 +32,7 @@ struct cmGeneratorExpressionContext // directly or indirectly in the property. bool Quiet; bool HadError; + bool HadContextSensitiveCondition; }; struct cmGeneratorExpressionDAGChecker; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5669872365..1a6b7ceadc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -134,6 +134,7 @@ public: : ge(cge) {} const cmsys::auto_ptr ge; + std::vector CachedIncludes; }; std::vector IncludeDirectoriesEntries; }; @@ -2778,22 +2779,36 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) end = this->Internal->IncludeDirectoriesEntries.end(); it != end; ++it) { - std::vector entryIncludes; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - entryIncludes); + + bool testIsOff = true; + bool cacheIncludes = false; + std::vector entryIncludes = (*it)->CachedIncludes; + if(!entryIncludes.empty()) + { + testIsOff = false; + } + else + { + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker), + entryIncludes); + if (!(*it)->ge->GetHadContextSensitiveCondition()) + { + cacheIncludes = true; + } + } std::string usedIncludes; - for(std::vector::const_iterator + for(std::vector::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) { - std::string inc = *li; - if (!cmSystemTools::IsOff(inc.c_str())) + if (testIsOff && !cmSystemTools::IsOff(li->c_str())) { - cmSystemTools::ConvertToUnixSlashes(inc); + cmSystemTools::ConvertToUnixSlashes(*li); } + std::string inc = *li; if(uniqueIncludes.insert(inc).second) { @@ -2804,6 +2819,10 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) } } } + if (cacheIncludes) + { + (*it)->CachedIncludes = entryIncludes; + } if (!usedIncludes.empty()) { this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, From 8669f64d54f2cd8d6d796487b5a5a9312a76a750 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 4 Feb 2013 00:01:18 -0500 Subject: [PATCH 87/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8f9917f7a0..0863fd6545 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130203) +set(CMake_VERSION_TWEAK 20130204) #set(CMake_VERSION_RC 1) From 59b568e5e8e294345c10789e1b3488391d5cd6f3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 31 Jan 2013 11:42:17 -0500 Subject: [PATCH 88/94] Fix cmSystemTools::RenameFile race on Windows Since commit d46d8df0 (Re-implemented cmGeneratedFileStream to look like a real stream and replace the destination file atomically, 2004-11-03) our RenameFile implementation tries to deal with MoveFile not replacing read-only files. In order to avoid the Get/SetFileAttributes pair we used stat to test for existence of the destination file. This has a race in which the destination could be created between the test for existence and the MoveFile call. Remove the stat call and use GetFileAttributes to detect whether the file exists. This shortens the race but does not eliminate it. Use a loop to try multiple times in case we lose the race. While at it, drop Win9x support and always use MoveFileEx. --- Source/cmSystemTools.cxx | 51 ++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index c2521d99fa..525efb4a56 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1180,46 +1180,35 @@ bool cmSystemTools::CopyFileIfDifferent(const char* source, bool cmSystemTools::RenameFile(const char* oldname, const char* newname) { #ifdef _WIN32 - /* On Windows the move functions will not replace existing files. - Check if the destination exists. */ - struct stat newFile; - if(stat(newname, &newFile) == 0) +# ifndef INVALID_FILE_ATTRIBUTES +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +# endif + /* Windows MoveFileEx may not replace read-only or in-use files. If it + fails then remove the read-only attribute from any existing destination. + Try multiple times since we may be racing against another process + creating/opening the destination file just before our MoveFileEx. */ + int tries = 5; + while(!MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) && --tries) { - /* The destination exists. We have to replace it carefully. The - MoveFileEx function does what we need but is not available on - Win9x. */ - OSVERSIONINFO osv; - DWORD attrs; - - /* Make sure the destination is not read only. */ - attrs = GetFileAttributes(newname); - if(attrs & FILE_ATTRIBUTE_READONLY) + // Try again only if failure was due to access permissions. + if(GetLastError() != ERROR_ACCESS_DENIED) { - SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY); + return false; } - - /* Check the windows version number. */ - osv.dwOSVersionInfoSize = sizeof(osv); - GetVersionEx(&osv); - if(osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + DWORD attrs = GetFileAttributes(newname); + if((attrs != INVALID_FILE_ATTRIBUTES) && + (attrs & FILE_ATTRIBUTE_READONLY)) { - /* This is Win9x. There is no MoveFileEx implementation. We - cannot quite rename the file atomically. Just delete the - destination and then move the file. */ - DeleteFile(newname); - return MoveFile(oldname, newname) != 0; + // Remove the read-only attribute from the destination file. + SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY); } else { - /* This is not Win9x. Use the MoveFileEx implementation. */ - return MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) != 0; + // The file may be temporarily in use so wait a bit. + cmSystemTools::Delay(100); } } - else - { - /* The destination does not exist. Just move the file. */ - return MoveFile(oldname, newname) != 0; - } + return tries > 0; #else /* On UNIX we have an OS-provided call to do this atomically. */ return rename(oldname, newname) == 0; From aed590a7e0c135f2466fb19cfe09674c687432ab Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 3 Feb 2013 11:04:57 -0500 Subject: [PATCH 89/94] Fix Module.ExternalData test on Cygwin In ExternalData_URL_TEMPLATES add a leading slash to the path after file:// only if the path does not already start with one. --- Tests/Module/ExternalData/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index e69713ad51..607e9b9f2a 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -4,8 +4,12 @@ project(ExternalDataTest NONE) include(CTest) include(ExternalData) + +if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/") + set(slash /) +endif() set(ExternalData_URL_TEMPLATES - "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" ) set(ExternalData_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ExternalData") file(REMOVE_RECURSE ${ExternalData_BINARY_ROOT}) # clean test From a6d3ffcb1fa71395cb0d865b3c79450280554651 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 3 Feb 2013 11:44:05 -0500 Subject: [PATCH 90/94] Fix Module.ExternalData test on VS 6 Run the test with the ctest --build-noclean option. The test CMakeLists.txt file already uses file(REMOVE_RECURSE) to clean out downloaded data anyway. Some file removed by "msdev ... /clean" causes CMake to re-run in the middle of the build step and file(REMOVE_RECURSE) wipes out already-generated files. --- Tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c21922e65c..a3044ab797 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -319,6 +319,7 @@ if(BUILD_TESTING) --build-generator ${CMAKE_TEST_GENERATOR} --build-project ExternalDataTest --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean --force-new-ctest-process --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V ) From 1fd8d017e6b548520b7f2aa8dcc6ce39a2ec3137 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 3 Feb 2013 11:49:47 -0500 Subject: [PATCH 91/94] ExternalData: Attach download rules to content links in IDEs Each data file to be created in the build tree corresponds one-to-one with a raw file or content link in the source tree. Use the MAIN_DEPENDENCY of add_custom_command to attach the build rule to the source tree file. This looks much nicer in the IDE project file browser and avoids ".rule" files. --- Modules/ExternalData.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 825b7b8716..9d84f8d135 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -191,7 +191,7 @@ function(ExternalData_add_target target) -DExternalData_ACTION=local -DExternalData_CONFIG=${config} -P ${_ExternalData_SELF} - DEPENDS "${name}" + MAIN_DEPENDENCY "${name}" ) list(APPEND files "${file}") endif() @@ -222,7 +222,7 @@ function(ExternalData_add_target target) -DExternalData_CONFIG=${config} -P ${_ExternalData_SELF} # Update whenever the object hash changes. - DEPENDS "${name}${ext}" + MAIN_DEPENDENCY "${name}${ext}" ) list(APPEND files "${file}${stamp}") endif() From a55d5ca48179d3be4d8406028c0992d45ada8882 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Fri, 1 Feb 2013 23:02:55 +0100 Subject: [PATCH 92/94] Ninja: Avoid LNK1170 linker error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit link.exe has problems with very very long lines in rsp files too. Use $in_newline instead of $in variable for rspcontent which separates the arguments with a newline instead of a simple space and was specially made for this purpose. --- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 65967a517b..7e48cd716e 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -190,7 +190,7 @@ cmNinjaNormalTargetGenerator linkOptionVar += cmTarget::GetTargetTypeName(targetType); const std::string linkOption = GetMakefile()->GetSafeDefinition(linkOptionVar.c_str()); - rspcontent = "$in " + linkOption + " $LINK_PATH $LINK_LIBRARIES"; + rspcontent = "$in_newline "+linkOption+" $LINK_PATH $LINK_LIBRARIES"; vars.Objects = responseFlag.c_str(); vars.LinkLibraries = ""; } From f77a1147f5dc2844437c891ea880c3b754fe9978 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 5 Feb 2013 00:01:16 -0500 Subject: [PATCH 93/94] CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0863fd6545..8a54237279 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130204) +set(CMake_VERSION_TWEAK 20130205) #set(CMake_VERSION_RC 1) From b6f66542674cac75821dfb10677bf52318afcda5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 2 Feb 2013 12:46:30 +0100 Subject: [PATCH 94/94] Use the result of converting to a unix path. The commit 18a3195a ('Keep track of INCLUDE_DIRECTORIES as a vector of structs.', 2012-11-19) moved the handling of includes from cmGeneratorTarget to cmTarget, but in the process introduced this bug. --- Source/cmTarget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5669872365..132154ccc8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2797,10 +2797,10 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) if(uniqueIncludes.insert(inc).second) { - includes.push_back(*li); + includes.push_back(inc); if (debugIncludes) { - usedIncludes += " * " + *li + "\n"; + usedIncludes += " * " + inc + "\n"; } } }