summaryrefslogtreecommitdiffstats
path: root/Lib/test/regex_tests.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-11-24 13:56:09 (GMT)
committerGeorg Brandl <georg@python.org>2007-11-24 13:56:09 (GMT)
commitb67da6ed2b182d2ef0b4e86e1dd402d27c53422d (patch)
tree8246321d090c097728e6bab65bd8d7f21b3ded09 /Lib/test/regex_tests.py
parentce7d10ccc4d04fd96dfd5c0d239ed81357efd3f8 (diff)
downloadcpython-b67da6ed2b182d2ef0b4e86e1dd402d27c53422d.zip
cpython-b67da6ed2b182d2ef0b4e86e1dd402d27c53422d.tar.gz
cpython-b67da6ed2b182d2ef0b4e86e1dd402d27c53422d.tar.bz2
#1735632: add O_NOATIME constant to os module.
Also document a few other O_ constants that were missing from documentation.
Diffstat (limited to 'Lib/test/regex_tests.py')
0 files changed, 0 insertions, 0 deletions
s->Target->GetLinkInformation(cfg)) + std::vector dirs = this->GetLinkedTargetDirectories(); + for (std::vector::iterator i = dirs.begin(); + i != dirs.end(); ++i) { - cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); - for(cmComputeLinkInformation::ItemVector::const_iterator - i = items.begin(); i != items.end(); ++i) - { - cmTarget const* linkee = i->Target; - if(linkee && !linkee->IsImported() - // We can ignore the INTERFACE_LIBRARY items because - // Target->GetLinkInformation already processed their - // link interface and they don't have any output themselves. - && linkee->GetType() != cmTarget::INTERFACE_LIBRARY - && emitted.insert(linkee).second) - { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(linkee); - cmLocalGenerator* lg = gt->GetLocalGenerator(); - cmMakefile* mf = linkee->GetMakefile(); - std::string di = mf->GetCurrentBinaryDirectory(); - di += "/"; - di += lg->GetTargetDirectory(*linkee); - di += "/DependInfo.cmake"; - *this->InfoFileStream << " \"" << di << "\"\n"; - } - } + *this->InfoFileStream << " \"" << *i << "/DependInfo.cmake\"\n"; } *this->InfoFileStream << " )\n"; -- cgit v0.12 From 700d537e60896b1317df3271e3d3673a0920d4c7 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 29 Jul 2015 00:01:05 -0400 Subject: 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 612ab7e..715c4a1 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150728) +set(CMake_VERSION_PATCH 20150729) #set(CMake_VERSION_RC 1) -- cgit v0.12 From aaa322a5cb5603742273282fb12f1e368697a625 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Jul 2015 10:41:30 -0400 Subject: cmMakefile: Return target from all AddUtilityCommand signatures --- Source/cmMakefile.cxx | 23 ++++++++++++----------- Source/cmMakefile.h | 17 +++++++++-------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 57e33df..17bde41 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1205,15 +1205,16 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target, } //---------------------------------------------------------------------------- -void cmMakefile::AddUtilityCommand(const std::string& utilityName, - bool excludeFromAll, - const std::vector& depends, - const char* workingDirectory, - const char* command, - const char* arg1, - const char* arg2, - const char* arg3, - const char* arg4) +cmTarget* +cmMakefile::AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, + const std::vector& depends, + const char* workingDirectory, + const char* command, + const char* arg1, + const char* arg2, + const char* arg3, + const char* arg4) { // Construct the command line for the custom command. cmCustomCommandLine commandLine; @@ -1238,8 +1239,8 @@ void cmMakefile::AddUtilityCommand(const std::string& utilityName, commandLines.push_back(commandLine); // Call the real signature of this method. - this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory, - depends, commandLines); + return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory, + depends, commandLines); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7938fcc..4fa5822 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -194,14 +194,15 @@ public: * Add a utility to the build. A utiltity target is a command that * is run every time the target is built. */ - void AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, - const std::vector& depends, - const char* workingDirectory, - const char* command, - const char* arg1=0, - const char* arg2=0, - const char* arg3=0, - const char* arg4=0); + cmTarget* AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, + const std::vector& depends, + const char* workingDirectory, + const char* command, + const char* arg1=0, + const char* arg2=0, + const char* arg3=0, + const char* arg4=0); cmTarget* AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const char* workingDirectory, -- cgit v0.12 From 34b902a5a6fd55ef3857d74aab986a8d96d57659 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:30:15 +0200 Subject: cmMakefile: Move method out of line. --- Source/cmMakefile.cxx | 5 +++++ Source/cmMakefile.h | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 17bde41..20c56ba 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1906,6 +1906,11 @@ const char* cmMakefile::GetCurrentBinaryDirectory() const return this->StateSnapshot.GetDirectory().GetCurrentBinary(); } +void cmMakefile::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) +{ + this->GeneratorTargets[t] = gt; +} + //---------------------------------------------------------------------------- void cmMakefile::AddIncludeDirectories(const std::vector &incs, bool before) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4fa5822..1e5c301 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -417,10 +417,7 @@ public: { this->GeneratorTargets = targets; } - void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) - { - this->GeneratorTargets[t] = gt; - } + void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; -- cgit v0.12 From 32e4f6beca6f13165ec5a40bf363d005ebda9263 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:37:55 +0200 Subject: Xcode: Skip Global targets when processing. --- Source/cmGlobalXCodeGenerator.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index ba5ff30..d6f5a00 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -502,6 +502,11 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, { cmTarget& target = l->second; + if (target.GetType() == cmTarget::GLOBAL_TARGET) + { + continue; + } + if (regenerate && (l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) { target.AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); -- cgit v0.12 From a1209be550172a95d3254158c121abf184e60bcd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:48:40 +0200 Subject: VisualStudio: Skip global targets when processing. --- Source/cmGlobalVisualStudioGenerator.cxx | 4 ++++ Source/cmLocalVisualStudio6Generator.cxx | 3 ++- Source/cmLocalVisualStudio7Generator.cxx | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 1d583eb..d6973aa 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -108,6 +108,10 @@ void cmGlobalVisualStudioGenerator::Generate() for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { + if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + { + continue; + } if(!this->IsExcluded(gen[0], t->second)) { allBuild->AddUtility(t->second.GetName()); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index f1c8def..cab5a47 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -88,7 +88,8 @@ void cmLocalVisualStudio6Generator::AddCMakeListsRules() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY + || l->second.GetType() == cmTarget::GLOBAL_TARGET) { continue; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f199a41..572dbde 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -108,6 +108,10 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() // Add the rule to targets that need it. for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { + if (l->second.GetType() == cmTarget::GLOBAL_TARGET) + { + continue; + } if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { l->second.AddSource(sf->GetFullPath()); -- cgit v0.12 From 5c14f78005ba5b4a2ccf0899fc50805a9de7b9ee Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 19:08:08 +0200 Subject: cmGlobalGenerator: Remove unused manifest accessor. --- Source/cmGlobalGenerator.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index d486003..e517c5c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -264,11 +264,6 @@ public: const std::string& suffix, std::string& dir); - /** Get the manifest of all targets that will be built for each - configuration. This is valid during generation only. */ - cmTargetManifest const& GetTargetManifest() const - { return this->TargetManifest; } - /** Get the content of a directory. Directory listings are cached and re-loaded from disk only when modified. During the generation step the content will include the target files to be built even if -- cgit v0.12 From 1ef9b2b6007356ab26cdec42bdf9c79d53745bf6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 19:10:44 +0200 Subject: cmGlobalGenerator: Remove the TargetManifest member. --- Source/cmGeneratorTarget.cxx | 10 +++++----- Source/cmGlobalGenerator.cxx | 6 +----- Source/cmGlobalGenerator.h | 6 +----- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index edd89e8..bd57b3d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1150,35 +1150,35 @@ void cmGeneratorTarget::GenerateTargetManifest( f = dir; f += "/"; f += name; - gg->AddToManifest(config, f); + gg->AddToManifest(f); } if(!soName.empty()) { f = dir; f += "/"; f += soName; - gg->AddToManifest(config, f); + gg->AddToManifest(f); } if(!realName.empty()) { f = dir; f += "/"; f += realName; - gg->AddToManifest(config, f); + gg->AddToManifest(f); } if(!pdbName.empty()) { f = dir; f += "/"; f += pdbName; - gg->AddToManifest(config, f); + gg->AddToManifest(f); } if(!impName.empty()) { f = this->Target->GetDirectory(config, true); f += "/"; f += impName; - gg->AddToManifest(config, f); + gg->AddToManifest(f); } } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5599854..06777e6 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2698,12 +2698,8 @@ void cmGlobalGenerator::AddTargetDepends(cmGeneratorTarget const* target, //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddToManifest(const std::string& config, - std::string const& f) +void cmGlobalGenerator::AddToManifest(std::string const& f) { - // Add to the main manifest for this configuration. - this->TargetManifest[config].insert(f); - // Add to the content listing for the file's directory. std::string dir = cmSystemTools::GetFilenamePath(f); std::string file = cmSystemTools::GetFilenameName(f); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index e517c5c..fe99a00 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -200,7 +200,7 @@ public: cmExportSetMap& GetExportSets() {return this->ExportSets;} /** Add a file to the manifest of generated targets for a configuration. */ - void AddToManifest(const std::string& config, std::string const& f); + void AddToManifest(std::string const& f); void EnableInstallTarget(); @@ -424,10 +424,6 @@ protected: std::map BuildExportSets; std::map BuildExportExportSets; - // Manifest of all targets that will be built for each configuration. - // This is computed just before local generators generate. - cmTargetManifest TargetManifest; - // All targets in the entire project. #if defined(CMAKE_BUILD_WITH_CMAKE) #ifdef CMake_HAVE_CXX11_UNORDERED_MAP -- cgit v0.12 From 29e8b7bfcc8b3530fb4fd2dd04dca59744588b61 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 18:43:28 +0200 Subject: cmGlobalGenerator: Create a new Compute step before generation. Replace the DoGenerate method. --- Source/cmGlobalGenerator.cxx | 4 +--- Source/cmGlobalGenerator.h | 5 ++--- Source/cmake.cxx | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 06777e6..390d6b4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1212,7 +1212,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const return false; } -void cmGlobalGenerator::DoGenerate() +void cmGlobalGenerator::Compute() { // Some generators track files replaced during the Generate. // Start with an empty vector: @@ -1220,8 +1220,6 @@ void cmGlobalGenerator::DoGenerate() // clear targets to issue warning CMP0042 for this->CMP0042WarnTargets.clear(); - - this->Generate(); } void cmGlobalGenerator::Generate() diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fe99a00..9c36cca 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -86,6 +86,7 @@ public: */ virtual void Configure(); + void Compute(); enum TargetTypes { AllTargets, @@ -99,7 +100,7 @@ public: * basically creates a series of LocalGenerators for each directory and * requests that they Generate. */ - void DoGenerate(); + virtual void Generate(); /** * Set/Get and Clear the enabled languages. @@ -368,8 +369,6 @@ public: std::string MakeSilentFlag; protected: - virtual void Generate(); - typedef std::vector GeneratorVector; // for a project collect all its targets by following depend // information, and also collect all the targets diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9d2c19e..619374e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1607,7 +1607,8 @@ int cmake::Generate() { return -1; } - this->GlobalGenerator->DoGenerate(); + this->GlobalGenerator->Compute(); + this->GlobalGenerator->Generate(); if ( !this->GraphVizFile.empty() ) { std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; -- cgit v0.12 From fb9355c50e366bd0f7cb6df6ea19118bd7dae899 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 18:44:58 +0200 Subject: cmGlobalGenerator: Return from Compute whether to generate. --- Source/cmGlobalGenerator.cxx | 11 ++++++----- Source/cmGlobalGenerator.h | 2 +- Source/cmake.cxx | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 390d6b4..65d74bd 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1212,7 +1212,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const return false; } -void cmGlobalGenerator::Compute() +bool cmGlobalGenerator::Compute() { // Some generators track files replaced during the Generate. // Start with an empty vector: @@ -1220,16 +1220,17 @@ void cmGlobalGenerator::Compute() // clear targets to issue warning CMP0042 for this->CMP0042WarnTargets.clear(); -} -void cmGlobalGenerator::Generate() -{ // Check whether this generator is allowed to run. if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) { - return; + return false; } + return true; +} +void cmGlobalGenerator::Generate() +{ this->FinalizeTargetCompileInfo(); this->CreateGenerationObjects(); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9c36cca..7bf6b24 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -86,7 +86,7 @@ public: */ virtual void Configure(); - void Compute(); + bool Compute(); enum TargetTypes { AllTargets, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 619374e..ec8276e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1607,7 +1607,10 @@ int cmake::Generate() { return -1; } - this->GlobalGenerator->Compute(); + if (!this->GlobalGenerator->Compute()) + { + return -1; + } this->GlobalGenerator->Generate(); if ( !this->GraphVizFile.empty() ) { -- cgit v0.12 From 2e94cba3565105aaa23720d9ffdcb9fe1ccee6b9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:56:59 +0200 Subject: cmGlobalGenerator: Move FinalizeTargetCompileInfo to Compute(). --- Source/cmGlobalGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 65d74bd..dcbc558 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1226,13 +1226,13 @@ bool cmGlobalGenerator::Compute() { return false; } + this->FinalizeTargetCompileInfo(); + return true; } void cmGlobalGenerator::Generate() { - this->FinalizeTargetCompileInfo(); - this->CreateGenerationObjects(); #ifdef CMAKE_BUILD_WITH_CMAKE -- cgit v0.12 From 610572b7d27e122ebf8e5c5d430019844567a996 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:31:23 +0200 Subject: cmMakefile: Simplify generate-time cmGeneratorTarget creation. --- Source/cmMakefile.cxx | 1 + Source/cmQtAutoGenerators.cxx | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 20c56ba..4bdc9d5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1909,6 +1909,7 @@ const char* cmMakefile::GetCurrentBinaryDirectory() const void cmMakefile::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) { this->GeneratorTargets[t] = gt; + this->GetGlobalGenerator()->AddGeneratorTarget(t, gt); } //---------------------------------------------------------------------------- diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 979db91..1322dea 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -476,7 +476,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, commandLines, false, autogenComment.c_str()); cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); - lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt); makefile->AddGeneratorTarget(autogenTarget, gt); // Set target folder -- cgit v0.12 From aa2407d84d8bcd983b3df294032831bbd54cf25d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:32:40 +0200 Subject: Xcode: Use allBuild target return value. --- Source/cmGlobalXCodeGenerator.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d6f5a00..91b8186 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -449,10 +449,9 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, // Add ALL_BUILD const char* no_working_directory = 0; std::vector no_depends; - mf->AddUtilityCommand("ALL_BUILD", true, no_depends, + cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); - cmTarget* allbuild = mf->FindTarget("ALL_BUILD"); // Refer to the main build configuration file for easy editing. std::string listfile = mf->GetCurrentSourceDirectory(); -- cgit v0.12 From 613bc08ac15b74a395ef0eca7668f7192b438204 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Jul 2015 11:44:25 -0400 Subject: cmDependsFortran: Use string to store module directory --- Source/cmDependsFortran.cxx | 13 +++++-------- Source/cmDependsFortran.h | 3 ++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 13c6409..856dcd4 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -154,14 +154,10 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, const char* stamp_dir = this->TargetDirectory.c_str(); // Get the directory in which module files will be created. - const char* mod_dir; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - if(const char* target_mod_dir = - mf->GetDefinition("CMAKE_Fortran_TARGET_MODULE_DIR")) - { - mod_dir = target_mod_dir; - } - else + std::string mod_dir = + mf->GetSafeDefinition("CMAKE_Fortran_TARGET_MODULE_DIR"); + if (mod_dir.empty()) { mod_dir = this->LocalGenerator->GetMakefile()->GetCurrentBinaryDirectory(); @@ -356,7 +352,8 @@ bool cmDependsFortran ::WriteDependenciesReal(const char *obj, cmFortranSourceInfo const& info, - const char* mod_dir, const char* stamp_dir, + std::string const& mod_dir, + const char* stamp_dir, std::ostream& makeDepends, std::ostream& internalDepends) { diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index d6ec7d7..a8a4013 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -66,7 +66,8 @@ protected: // Actually write the depenencies to the streams. bool WriteDependenciesReal(const char *obj, cmFortranSourceInfo const& info, - const char* mod_dir, const char* stamp_dir, + std::string const& mod_dir, + const char* stamp_dir, std::ostream& makeDepends, std::ostream& internalDepends); -- cgit v0.12 From 7371d8f3b49c020a14f6324ba5264d17c7dbbaee Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Jul 2015 11:49:00 -0400 Subject: cmCommonTargetGenerator: Return string from GetFortranModuleDirectory --- Source/cmCommonTargetGenerator.cxx | 30 ++++++++++++++---------------- Source/cmCommonTargetGenerator.h | 2 +- Source/cmMakefileTargetGenerator.cxx | 13 +++++-------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index c75ac23..eb93ebc 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -101,7 +101,7 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) } //---------------------------------------------------------------------------- -const char* cmCommonTargetGenerator::GetFortranModuleDirectory() +std::string cmCommonTargetGenerator::GetFortranModuleDirectory() { // Compute the module directory. if(!this->FortranModuleDirectoryComputed) @@ -134,14 +134,7 @@ const char* cmCommonTargetGenerator::GetFortranModuleDirectory() } // Return the computed directory. - if(this->FortranModuleDirectory.empty()) - { - return 0; - } - else - { - return this->FortranModuleDirectory.c_str(); - } + return this->FortranModuleDirectory; } //---------------------------------------------------------------------------- @@ -155,19 +148,24 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags) } // Add a module output directory flag if necessary. - const char* mod_dir = this->GetFortranModuleDirectory(); - if(!mod_dir) + std::string mod_dir = this->GetFortranModuleDirectory(); + if (!mod_dir.empty()) + { + mod_dir = this->Convert(mod_dir, + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + } + else { - mod_dir = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_DEFAULT"); + mod_dir = + this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT"); } - if(mod_dir) + if (!mod_dir.empty()) { const char* moddir_flag = this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG"); std::string modflag = moddir_flag; - modflag += this->Convert(mod_dir, - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); + modflag += mod_dir; this->LocalGenerator->AppendFlags(flags, modflag); } diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 166508d..aec3148 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -59,7 +59,7 @@ protected: // Target-wide Fortran module output directory. bool FortranModuleDirectoryComputed; std::string FortranModuleDirectory; - const char* GetFortranModuleDirectory(); + std::string GetFortranModuleDirectory(); // Compute target-specific Fortran language flags. void AddFortranFlags(std::string& flags); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 57ab2ca..5a2333d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1069,14 +1069,11 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << " )\n"; } - // Check for a target-specific module output directory. - if(const char* mdir = this->GetFortranModuleDirectory()) - { - *this->InfoFileStream - << "\n" - << "# Fortran module output directory.\n" - << "set(CMAKE_Fortran_TARGET_MODULE_DIR \"" << mdir << "\")\n"; - } + *this->InfoFileStream + << "\n" + << "# Fortran module output directory.\n" + << "set(CMAKE_Fortran_TARGET_MODULE_DIR \"" + << this->GetFortranModuleDirectory() << "\")\n"; // and now write the rule to use it std::vector depends; -- cgit v0.12 From 70c21301b274a28dde75b4f2adb141f9b170eb80 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Jul 2015 12:55:58 -0400 Subject: cmCommonTargetGenerator: Store working directory for relative paths The Makefile generators run tools with the current working directory set to the subdirectory of the build tree for the each target. The Ninja generator runs tools with the current working directory set to the top of the build tree. Tell cmCommonTargetGenerator where the working directory will be so it can compute proper relative paths. --- Source/cmCommonTargetGenerator.cxx | 10 +++++++--- Source/cmCommonTargetGenerator.h | 4 +++- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index eb93ebc..8a5746a 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -20,8 +20,12 @@ #include "cmSystemTools.h" #include "cmTarget.h" -cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) - : GeneratorTarget(gt) +cmCommonTargetGenerator::cmCommonTargetGenerator( + cmOutputConverter::RelativeRoot wd, + cmGeneratorTarget* gt + ) + : WorkingDirectory(wd) + , GeneratorTarget(gt) , Target(gt->Target) , Makefile(gt->Makefile) , LocalGenerator(static_cast(gt->LocalGenerator)) @@ -152,7 +156,7 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags) if (!mod_dir.empty()) { mod_dir = this->Convert(mod_dir, - cmLocalGenerator::START_OUTPUT, + this->WorkingDirectory, cmLocalGenerator::SHELL); } else diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index aec3148..5fd976d 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -29,7 +29,8 @@ class cmTarget; class cmCommonTargetGenerator { public: - cmCommonTargetGenerator(cmGeneratorTarget* gt); + cmCommonTargetGenerator(cmOutputConverter::RelativeRoot wd, + cmGeneratorTarget* gt); virtual ~cmCommonTargetGenerator(); std::string const& GetConfigName() const; @@ -46,6 +47,7 @@ protected: // Helper to add flag for windows .def file. void AddModuleDefinitionFlag(std::string& flags); + cmOutputConverter::RelativeRoot WorkingDirectory; cmGeneratorTarget* GeneratorTarget; cmTarget* Target; cmMakefile* Makefile; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5a2333d..1304258 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -33,7 +33,7 @@ #include cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) - : cmCommonTargetGenerator(target) + : cmCommonTargetGenerator(cmOutputConverter::START_OUTPUT, target) , OSXBundleGenerator(0) , MacOSXContentGenerator(0) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index addf292..4e4dc3f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -58,7 +58,7 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target) } cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) - : cmCommonTargetGenerator(target), + : cmCommonTargetGenerator(cmOutputConverter::HOME_OUTPUT, target), MacOSXContentGenerator(0), OSXBundleGenerator(0), MacContentFolders(), -- cgit v0.12 From e90372a0db3248d4b78d8d7d7020c66cb5dc3803 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Jul 2015 13:07:02 -0400 Subject: cmCommonTargetGenerator: Factor out Fortran module directory computation Move computation from GetFortranModuleDirectory to a virtual method so it can be customized for each type of generator. --- Source/cmCommonTargetGenerator.cxx | 55 +++++++++++++++++++++----------------- Source/cmCommonTargetGenerator.h | 1 + 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 8a5746a..26ca375 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -105,36 +105,43 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) } //---------------------------------------------------------------------------- +std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const +{ + std::string mod_dir; + const char* target_mod_dir = + this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); + const char* moddir_flag = + this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); + if(target_mod_dir && moddir_flag) + { + // Compute the full path to the module directory. + if(cmSystemTools::FileIsFullPath(target_mod_dir)) + { + // Already a full path. + mod_dir = target_mod_dir; + } + else + { + // Interpret relative to the current output directory. + mod_dir = this->Makefile->GetCurrentBinaryDirectory(); + mod_dir += "/"; + mod_dir += target_mod_dir; + } + + // Make sure the module output directory exists. + cmSystemTools::MakeDirectory(mod_dir); + } + return mod_dir; +} + +//---------------------------------------------------------------------------- std::string cmCommonTargetGenerator::GetFortranModuleDirectory() { // Compute the module directory. if(!this->FortranModuleDirectoryComputed) { - const char* target_mod_dir = - this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); - const char* moddir_flag = - this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); - if(target_mod_dir && moddir_flag) - { - // Compute the full path to the module directory. - if(cmSystemTools::FileIsFullPath(target_mod_dir)) - { - // Already a full path. - this->FortranModuleDirectory = target_mod_dir; - } - else - { - // Interpret relative to the current output directory. - this->FortranModuleDirectory = - this->Makefile->GetCurrentBinaryDirectory(); - this->FortranModuleDirectory += "/"; - this->FortranModuleDirectory += target_mod_dir; - } - - // Make sure the module output directory exists. - cmSystemTools::MakeDirectory(this->FortranModuleDirectory.c_str()); - } this->FortranModuleDirectoryComputed = true; + this->FortranModuleDirectory = this->ComputeFortranModuleDirectory(); } // Return the computed directory. diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 5fd976d..0a49e12 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -62,6 +62,7 @@ protected: bool FortranModuleDirectoryComputed; std::string FortranModuleDirectory; std::string GetFortranModuleDirectory(); + virtual std::string ComputeFortranModuleDirectory() const; // Compute target-specific Fortran language flags. void AddFortranFlags(std::string& flags); -- cgit v0.12 From 3a755559d1e865189d78bef8e5abd06d7fb8724e Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 30 Jul 2015 00:01:06 -0400 Subject: 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 715c4a1..7df8600 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150729) +set(CMake_VERSION_PATCH 20150730) #set(CMake_VERSION_RC 1) -- cgit v0.12 From ff1019bfac1380681989242fa904c2d9fe13fd38 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:57:29 +0200 Subject: cmGlobalGenerator: Move generation object creation to Compute(). --- Source/cmGlobalGenerator.cxx | 4 ++-- Source/cmGlobalVisualStudio8Generator.cxx | 2 ++ Source/cmGlobalVisualStudioGenerator.cxx | 2 ++ Source/cmGlobalXCodeGenerator.cxx | 7 ++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index dcbc558..b79576c 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1228,13 +1228,13 @@ bool cmGlobalGenerator::Compute() } this->FinalizeTargetCompileInfo(); + this->CreateGenerationObjects(); + return true; } void cmGlobalGenerator::Generate() { - this->CreateGenerationObjects(); - #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index f3cf36e..16e3f9b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); + mf->AddGeneratorTarget(tgt, gt); // Organize in the "predefined targets" folder: // diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d6973aa..a147eb3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -85,6 +85,8 @@ void cmGlobalVisualStudioGenerator::Generate() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); + allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); #if 0 // Can't activate this code because we want ALL_BUILD diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 91b8186..ffa4c5d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -452,6 +452,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); + cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); + mf->AddGeneratorTarget(allbuild, allBuildGt); // Refer to the main build configuration file for easy editing. std::string listfile = mf->GetCurrentSourceDirectory(); @@ -480,9 +482,12 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::string file = this->ConvertToRelativeForMake( this->CurrentReRunCMakeMakefile.c_str()); cmSystemTools::ReplaceString(file, "\\ ", " "); - mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends, + cmTarget* check = mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, + true, no_depends, no_working_directory, "make", "-f", file.c_str()); + cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); + mf->AddGeneratorTarget(check, checkGt); } // now make the allbuild depend on all the non-utility targets -- cgit v0.12 From 5edb3354854bd2de4f9ea0e2c4af4069f46a4830 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 19:03:51 +0200 Subject: cmGlobalGenerator: Virtualize the Compute step and override it. --- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 11 ++++++++++- Source/cmGlobalVisualStudio10Generator.h | 2 ++ Source/cmGlobalVisualStudio8Generator.cxx | 11 +++++++---- Source/cmGlobalVisualStudio8Generator.h | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 11 +++++++---- Source/cmGlobalVisualStudioGenerator.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 13 ++++++++++++- Source/cmGlobalXCodeGenerator.h | 1 + 9 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7bf6b24..9492372 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -86,7 +86,7 @@ public: */ virtual void Configure(); - bool Compute(); + virtual bool Compute(); enum TargetTypes { AllTargets, diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 4e8ada4..8ec4fd9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -314,9 +314,18 @@ cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent, } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator::Generate() +bool cmGlobalVisualStudio10Generator::Compute() { + if (!cmGlobalVisualStudio8Generator::Compute()) + { + return false; + } this->LongestSource = LongestSourcePath(); + return true; +} + +void cmGlobalVisualStudio10Generator::Generate() +{ this->cmGlobalVisualStudio8Generator::Generate(); if(this->LongestSource.Length > 0) { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 74d5022..3d34a3f 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -45,6 +45,8 @@ public: std::vector const& makeOptions = std::vector() ); + virtual bool Compute(); + ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, cmState::Snapshot snapshot); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 16e3f9b..d5a5585 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -347,8 +347,13 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Generator::Generate() +bool cmGlobalVisualStudio8Generator::Compute() { + if (!cmGlobalVisualStudio7Generator::Compute()) + { + return false; + } + if(this->AddCheckTarget()) { // All targets depend on the build-system check target. @@ -362,9 +367,7 @@ void cmGlobalVisualStudio8Generator::Generate() } } } - - // Now perform the main generation. - this->cmGlobalVisualStudio7Generator::Generate(); + return true; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index cc02b78..1c61103 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -67,7 +67,7 @@ public: return !this->WindowsCEVersion.empty(); } protected: - virtual void Generate(); + virtual bool Compute(); virtual const char* GetIDEVersion() { return "8.0"; } virtual std::string FindDevEnvCommand(); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index a147eb3..2f9d79a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -64,8 +64,13 @@ std::string cmGlobalVisualStudioGenerator::GetRegistryBase( } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::Generate() +bool cmGlobalVisualStudioGenerator::Compute() { + if (!cmGlobalGenerator::Compute()) + { + return false; + } + // Add a special target that depends on ALL projects for easy build // of one configuration only. const char* no_working_dir = 0; @@ -136,9 +141,7 @@ void cmGlobalVisualStudioGenerator::Generate() static_cast(*lgi); lg->AddCMakeListsRules(); } - - // Run all the local generators. - this->cmGlobalGenerator::Generate(); + return true; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 8e2d6a4..64440ad 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -108,7 +108,7 @@ public: cmGeneratorTarget*, std::vector& commands, std::string const& configName); protected: - virtual void Generate(); + virtual bool Compute(); // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index ffa4c5d..7dea107 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -378,8 +378,13 @@ cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent, } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::Generate() +bool cmGlobalXCodeGenerator::Compute() { + if (!cmGlobalGenerator::Compute()) + { + return false; + } + std::map >::iterator it; // make sure extra targets are added before calling // the parent generate which will call trace depends @@ -390,11 +395,17 @@ void cmGlobalXCodeGenerator::Generate() // add ALL_BUILD, INSTALL, etc this->AddExtraTargets(root, it->second); } + return true; +} + +void cmGlobalXCodeGenerator::Generate() +{ this->cmGlobalGenerator::Generate(); if(cmSystemTools::GetErrorOccuredFlag()) { return; } + std::map >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { cmLocalGenerator* root = it->second[0]; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c36e4af..ee8bf2c 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -88,6 +88,7 @@ public: virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); void AppendFlag(std::string& flags, std::string const& flag); protected: + virtual bool Compute(); virtual void Generate(); private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, -- cgit v0.12 From 0368552d7fcdd35a0cb52043a8567e66d62bccd3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:58:26 +0200 Subject: cmGlobalGenerator: Move QtAutogen handling to Compute(). --- Source/cmGlobalGenerator.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b79576c..463f526 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1230,11 +1230,6 @@ bool cmGlobalGenerator::Compute() this->CreateGenerationObjects(); - return true; -} - -void cmGlobalGenerator::Generate() -{ #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set @@ -1265,6 +1260,13 @@ void cmGlobalGenerator::Generate() } #endif + return true; +} + +void cmGlobalGenerator::Generate() +{ + unsigned int i; + // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly for (i = 0; i < this->LocalGenerators.size(); ++i) -- cgit v0.12 From 5f662b3887c3e92adfcad1bc92eabfd86db263b7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 18:12:03 +0200 Subject: cmScriptGenerator: Remove unused method. --- Source/cmScriptGenerator.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index 9ab04f1..bc9372f 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -54,9 +54,6 @@ public: void Generate(std::ostream& os, const std::string& config, std::vector const& configurationTypes); - const std::vector& GetConfigurations() const - { return this->Configurations; } - protected: typedef cmScriptGeneratorIndent Indent; virtual void GenerateScript(std::ostream& os); -- cgit v0.12 From 3ef8aaaa71786b32ed88a29e48dd17d32f5a8a79 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 22:00:27 +0200 Subject: cmInstallCommand: Move the SetHaveInstallRule invocation. Remove the call from cmInstallTargetGenerator because that is to be ported away from cmTarget. --- Source/cmInstallCommand.cxx | 6 ++++++ Source/cmInstallTargetGenerator.cxx | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 899b088..a33acad 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -752,6 +752,12 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) installsPublicHeader = installsPublicHeader || publicHeaderGenerator != 0; installsResource = installsResource || resourceGenerator; + if (installsArchive || installsRuntime || installsFramework + || installsLibrary || installsBundle) + { + target.SetHaveInstallRule(true); + } + this->Makefile->AddInstallGenerator(archiveGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); this->Makefile->AddInstallGenerator(runtimeGenerator); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 5115788..09af56e 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -35,7 +35,6 @@ cmInstallTargetGenerator { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; - this->Target->SetHaveInstallRule(true); } //---------------------------------------------------------------------------- -- cgit v0.12 From e5e529701812bdfe7ea1c3ffe682bd576b9c05a8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 19:49:16 +0200 Subject: cmInstallGenerator: Add a Compute() virtual hook. --- Source/cmGlobalGenerator.cxx | 12 ++++++++++++ Source/cmInstallGenerator.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 463f526..1d6608b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -34,6 +34,7 @@ #include "cmExportBuildFileGenerator.h" #include "cmCPackPropertiesGenerator.h" #include "cmAlgorithms.h" +#include "cmInstallGenerator.h" #include #include @@ -1260,6 +1261,17 @@ bool cmGlobalGenerator::Compute() } #endif + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); + std::vector& gens = mf->GetInstallGenerators(); + for (std::vector::const_iterator git = gens.begin(); + git != gens.end(); ++git) + { + (*git)->Compute(this->LocalGenerators[i]); + } + } + return true; } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c4191e4..b8e5b53 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -62,6 +62,8 @@ public: /** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */ static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false); + virtual void Compute(cmLocalGenerator*) {} + protected: virtual void GenerateScript(std::ostream& os); -- cgit v0.12 From 4e41913f9acb6a33f6a4eb1b88577fb7499e99d6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 19:32:03 +0200 Subject: cmInstallCommand: Store only a targetName, not a cmTarget. Compute the cmTarget at Compute() time. --- Source/cmInstallCommand.cxx | 3 ++- Source/cmInstallTargetGenerator.cxx | 12 ++++++++++-- Source/cmInstallTargetGenerator.h | 6 +++++- Source/cmLocalGenerator.cxx | 18 +++++++++++------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index a33acad..f548f5d 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -27,7 +27,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, { cmInstallGenerator::MessageLevel message = cmInstallGenerator::SelectMessageLevel(target.GetMakefile()); - return new cmInstallTargetGenerator(target, args.GetDestination().c_str(), + return new cmInstallTargetGenerator(target.GetName(), + args.GetDestination().c_str(), impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), message, diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 09af56e..a5d8a74 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -22,13 +22,16 @@ //---------------------------------------------------------------------------- cmInstallTargetGenerator -::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, +::cmInstallTargetGenerator(const std::string& targetName, + const char* dest, bool implib, const char* file_permissions, std::vector const& configurations, const char* component, MessageLevel message, bool optional): - cmInstallGenerator(dest, configurations, component, message), Target(&t), + cmInstallGenerator(dest, configurations, component, message), + TargetName(targetName), + Target(0), FilePermissions(file_permissions), ImportLibrary(implib), Optional(optional) @@ -430,6 +433,11 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, return fname; } +void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg) +{ + this->Target = lg->GetMakefile()->FindTarget(this->TargetName); +} + //---------------------------------------------------------------------------- void cmInstallTargetGenerator diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index db69220..128e1a2 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -22,7 +22,7 @@ class cmInstallTargetGenerator: public cmInstallGenerator { public: cmInstallTargetGenerator( - cmTarget& t, const char* dest, bool implib, + std::string const& targetName, const char* dest, bool implib, const char* file_permissions, std::vector const& configurations, const char* component, @@ -56,7 +56,10 @@ public: const std::string& config, NameType nameType = NameNormal); + void Compute(cmLocalGenerator* lg); + cmTarget* GetTarget() const { return this->Target; } + bool IsImportLibrary() const { return this->ImportLibrary; } std::string GetDestination(std::string const& config) const; @@ -98,6 +101,7 @@ protected: void AddRanlibRule(std::ostream& os, Indent const& indent, const std::string& toDestDirPath); + std::string TargetName; cmTarget* Target; std::string FilePermissions; NamelinkModeType NamelinkMode; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2e20ee2..6b48a44 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2375,11 +2375,15 @@ cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg, class cmInstallTargetGeneratorLocal: public cmInstallTargetGenerator { public: - cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib): + cmInstallTargetGeneratorLocal(cmLocalGenerator* lg, std::string const& t, + const char* dest, bool implib): cmInstallTargetGenerator( t, dest, implib, "", std::vector(), "Unspecified", - cmInstallGenerator::SelectMessageLevel(t.GetMakefile()), - false) {} + cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()), + false) + { + this->Compute(lg); + } }; //---------------------------------------------------------------------------- @@ -2428,7 +2432,7 @@ cmLocalGenerator { // Use a target install generator. cmInstallTargetGeneratorLocal - g(l->second, destination.c_str(), false); + g(this, l->first, destination.c_str(), false); g.Generate(os, config, configurationTypes); } break; @@ -2439,18 +2443,18 @@ cmLocalGenerator // to the normal destination and the DLL to the runtime // destination. cmInstallTargetGeneratorLocal - g1(l->second, destination.c_str(), true); + g1(this, l->first, destination.c_str(), true); g1.Generate(os, config, configurationTypes); // We also skip over the leading slash given by the user. destination = l->second.GetRuntimeInstallPath().substr(1); cmSystemTools::ConvertToUnixSlashes(destination); cmInstallTargetGeneratorLocal - g2(l->second, destination.c_str(), false); + g2(this, l->first, destination.c_str(), false); g2.Generate(os, config, configurationTypes); #else // Use a target install generator. cmInstallTargetGeneratorLocal - g(l->second, destination.c_str(), false); + g(this, l->first, destination.c_str(), false); g.Generate(os, config, configurationTypes); #endif } -- cgit v0.12 From a23fcc9558f9f2788fc828f7473060ea1f035f55 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 19:58:52 +0200 Subject: cmInstallTargetGenerator: Port to cmGeneratorTarget. --- Source/cmExportInstallFileGenerator.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 78 +++++++++++++++++++-------------- Source/cmInstallTargetGenerator.h | 8 ++-- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 6c7d97e..1d75f43 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -398,7 +398,7 @@ cmExportInstallFileGenerator } // Get the target to be installed. - cmTarget* target = itgen->GetTarget(); + cmTarget* target = itgen->GetTarget()->Target; // Construct the installed location of the target. std::string dest = itgen->GetDestination(config); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index a5d8a74..01d4b77 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include @@ -71,15 +72,17 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->Target->NeedRelinkBeforeInstall(config)) { - fromDirConfig = this->Target->GetMakefile()->GetCurrentBinaryDirectory(); + fromDirConfig = + this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); fromDirConfig += cmake::GetCMakeFilesDirectory(); fromDirConfig += "/CMakeRelink.dir/"; } else { - fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); + fromDirConfig = + this->Target->Target->GetDirectory(config, this->ImportLibrary); fromDirConfig += "/"; } std::string toDir = @@ -90,7 +93,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::vector filesFrom; std::vector filesTo; std::string literal_args; - cmTarget::TargetType targetType = this->Target->GetType(); + cmTarget::TargetType targetType = + static_cast(this->Target->GetType()); cmInstallType type = cmInstallType(); switch(targetType) { @@ -107,7 +111,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: case cmTarget::UNKNOWN_LIBRARY: - this->Target->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, + this->Target->Target->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, "cmInstallTargetGenerator created with non-installable target."); return; } @@ -120,7 +124,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -130,7 +134,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -146,7 +150,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetName; // Handle OSX Bundles. - if(this->Target->IsAppBundleOnApple()) + if(this->Target->Target->IsAppBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; @@ -180,7 +184,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + this->Target->Target->GetLibraryNames(targetName, targetNameSO, + targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -193,7 +198,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -203,7 +208,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; } - else if(this->Target->IsFrameworkOnApple()) + else if(this->Target->Target->IsFrameworkOnApple()) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -221,7 +226,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); } - else if(this->Target->IsCFBundleOnApple()) + else if(this->Target->Target->IsCFBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; @@ -345,7 +350,7 @@ cmInstallTargetGenerator::GetDestination(std::string const& config) const { cmGeneratorExpression ge; return ge.Parse(this->Destination) - ->Evaluate(this->Target->GetMakefile(), config); + ->Evaluate(this->Target->Target->GetMakefile(), config); } //---------------------------------------------------------------------------- @@ -354,7 +359,7 @@ cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const { NameType nameType = this->ImportLibrary? NameImplib : NameNormal; return - cmInstallTargetGenerator::GetInstallFilename(this->Target, config, + cmInstallTargetGenerator::GetInstallFilename(this->Target->Target, config, nameType); } @@ -435,7 +440,8 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg) { - this->Target = lg->GetMakefile()->FindTarget(this->TargetName); + this->Target = lg->GetGlobalGenerator()->GetGeneratorTarget( + lg->GetMakefile()->FindTarget(this->TargetName)); } //---------------------------------------------------------------------------- @@ -540,8 +546,8 @@ cmInstallTargetGenerator } // Fix the install_name settings in installed binaries. - std::string installNameTool = - this->Target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL"); + std::string installNameTool = this->Target->Target->GetMakefile() + ->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL"); if(installNameTool.empty()) { @@ -551,7 +557,8 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = + this->Target->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -595,11 +602,11 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->GetInstallNameDirForBuildTree(config); + this->Target->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->GetInstallNameDirForInstallTree(); + this->Target->Target->GetInstallNameDirForInstallTree(); - if(this->Target->IsFrameworkOnApple() && for_install.empty()) + if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { // Frameworks seem to have an id corresponding to their own full // path. @@ -613,7 +620,7 @@ cmInstallTargetGenerator { // Prepare to refer to the install-tree install_name. new_id = for_install; - new_id += this->GetInstallFilename(this->Target, config, NameSO); + new_id += this->GetInstallFilename(this->Target->Target, config, NameSO); } } @@ -646,20 +653,22 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) { return; } // Skip if on Apple - if(this->Target->GetMakefile()->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + if(this->Target->Target->GetMakefile() + ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { return; } // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = + this->Target->Target->GetLinkInformation(config); if(!cli) { return; @@ -684,20 +693,21 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) { return; } // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = + this->Target->Target->GetLinkInformation(config); if(!cli) { return; } - cmMakefile* mf = this->Target->GetMakefile(); + cmMakefile* mf = this->Target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { @@ -809,20 +819,20 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os, } // Don't handle OSX Bundles. - if(this->Target->GetMakefile()->IsOn("APPLE") && - this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) + if(this->Target->Target->GetMakefile()->IsOn("APPLE") && + this->Target->Target->GetPropertyAsBool("MACOSX_BUNDLE")) { return; } - if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP")) + if(! this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP")) { return; } os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n"; os << indent << " execute_process(COMMAND \"" - << this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP") + << this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP") << "\" \"" << toDestDirPath << "\")\n"; os << indent << "endif()\n"; } @@ -841,13 +851,13 @@ cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, // Perform post-installation processing on the file depending // on its type. - if(!this->Target->GetMakefile()->IsOn("APPLE")) + if(!this->Target->Target->GetMakefile()->IsOn("APPLE")) { return; } std::string ranlib = - this->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB"); + this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB"); if(ranlib.empty()) { return; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 128e1a2..a8f4a75 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -13,7 +13,9 @@ #define cmInstallTargetGenerator_h #include "cmInstallGenerator.h" -#include "cmTarget.h" + +class cmTarget; +class cmGeneratorTarget; /** \class cmInstallTargetGenerator * \brief Generate target installation rules. @@ -58,7 +60,7 @@ public: void Compute(cmLocalGenerator* lg); - cmTarget* GetTarget() const { return this->Target; } + cmGeneratorTarget* GetTarget() const { return this->Target; } bool IsImportLibrary() const { return this->ImportLibrary; } @@ -102,7 +104,7 @@ protected: const std::string& toDestDirPath); std::string TargetName; - cmTarget* Target; + cmGeneratorTarget* Target; std::string FilePermissions; NamelinkModeType NamelinkMode; bool ImportLibrary; -- cgit v0.12 From 4c10461a877d8ca8f18c952c2c143320337d04a7 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Thu, 30 Jul 2015 16:09:34 +0200 Subject: FindOpenSSL: Remove extra whitespace --- Modules/FindOpenSSL.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 3adc269..ad22580 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -155,9 +155,9 @@ if(WIN32 AND NOT CYGWIN) mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE) - set( OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} ) - set( OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} ) - set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) + set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} ) + set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) elseif(MINGW) # same player, for MinGW set(LIB_EAY_NAMES libeay32) @@ -185,9 +185,9 @@ if(WIN32 AND NOT CYGWIN) ) mark_as_advanced(SSL_EAY LIB_EAY) - set( OPENSSL_SSL_LIBRARY ${SSL_EAY} ) - set( OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) - set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + set(OPENSSL_SSL_LIBRARY ${SSL_EAY} ) + set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) unset(LIB_EAY_NAMES) unset(SSL_EAY_NAMES) else() @@ -213,9 +213,9 @@ if(WIN32 AND NOT CYGWIN) ) mark_as_advanced(SSL_EAY LIB_EAY) - set( OPENSSL_SSL_LIBRARY ${SSL_EAY} ) - set( OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) - set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + set(OPENSSL_SSL_LIBRARY ${SSL_EAY} ) + set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) endif() else() -- cgit v0.12 From fbcbf7f29d630c8a291f0d0e543defbf1b8208df Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Thu, 30 Jul 2015 16:09:34 +0200 Subject: FindOpenSSL: De-duplicate find_library path suffixes on Windows Store the path suffixes in a variable and reference it in each find_library call. --- Modules/FindOpenSSL.cmake | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index ad22580..7545d94 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -99,15 +99,20 @@ if(WIN32 AND NOT CYGWIN) # We are using the libraries located in the VC subdir instead of the parent directory eventhough : # libeay32MD.lib is identical to ../libeay32.lib, and # ssleay32MD.lib is identical to ../ssleay32.lib + + set(_OPENSSL_PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + find_library(LIB_EAY_DEBUG NAMES libeay32MDd libeay32d ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + ${_OPENSSL_PATH_SUFFIXES} ) find_library(LIB_EAY_RELEASE @@ -116,9 +121,7 @@ if(WIN32 AND NOT CYGWIN) libeay32 ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + ${_OPENSSL_PATH_SUFFIXES} ) find_library(SSL_EAY_DEBUG @@ -127,9 +130,7 @@ if(WIN32 AND NOT CYGWIN) ssleay32d ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + ${_OPENSSL_PATH_SUFFIXES} ) find_library(SSL_EAY_RELEASE @@ -139,9 +140,7 @@ if(WIN32 AND NOT CYGWIN) ssl ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + ${_OPENSSL_PATH_SUFFIXES} ) set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}") -- cgit v0.12 From 22809b1665dd2b561fda280d486d099bad6ac877 Mon Sep 17 00:00:00 2001 From: Justin Cook Date: Thu, 30 Jul 2015 11:57:10 -0400 Subject: Cray: Fix compiler version detection (#15664) --- Modules/Compiler/Cray-DetermineCompiler.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/Cray-DetermineCompiler.cmake b/Modules/Compiler/Cray-DetermineCompiler.cmake index 881b82c..6602294 100644 --- a/Modules/Compiler/Cray-DetermineCompiler.cmake +++ b/Modules/Compiler/Cray-DetermineCompiler.cmake @@ -2,5 +2,5 @@ set(_compiler_id_pp_test "defined(_CRAYC)") set(_compiler_id_version_compute " -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_RELEASE) +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_RELEASE_MAJOR) # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_RELEASE_MINOR)") -- cgit v0.12 From fe2e503ea4abe83ce091bfa2c8cf4d977fba388a Mon Sep 17 00:00:00 2001 From: James Johnston Date: Thu, 30 Jul 2015 15:54:21 +0000 Subject: Help: Document string(FIND) return value when no match is found --- Help/command/string.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/command/string.rst b/Help/command/string.rst index bc4399c..20f8094 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -96,7 +96,7 @@ random number generator. ``FIND`` will return the position where the given substring was found in the supplied string. If the ``REVERSE`` flag was used, the command will search for the position of the last occurrence of the specified -substring. +substring. If the substring is not found, a position of -1 is returned. The following characters have special meaning in regular expressions: -- cgit v0.12 From 60fe4b540b40330e050dbd755204cecbc62d6a37 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jul 2015 13:57:22 -0400 Subject: SunOS: Drop special case for linking C++ shared libraries with gcc (#15673) Since commit v2.4.0~4325 (...use gcc -shared, even for C++ libraries, 2003-03-13) we use the C compiler "gcc" to link C++ shared libraries compiled with "g++". At the time "g++" did not know how to link shared libraries correctly. This has long since been fixed so simply drop the special case. --- Modules/Platform/SunOS.cmake | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index aaa79c4..77946f2 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -7,14 +7,6 @@ if(CMAKE_SYSTEM MATCHES "SunOS-4") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") endif() -if(CMAKE_COMPILER_IS_GNUCXX) - if(CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_CXX_CREATE_SHARED_LIBRARY - " -o ") - else() - # Take default rule from CMakeDefaultMakeRuleVariables.cmake. - endif() -endif() include(Platform/UnixPaths) # Add the compiler's implicit link directories. -- cgit v0.12 From 1687060b587ded9e65153280c8ab364b05614b64 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 31 Jul 2015 00:01:06 -0400 Subject: 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 7df8600..34779a5 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150730) +set(CMake_VERSION_PATCH 20150731) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f7a9ed7e90cd2661b279d0bcd44d43620b8eeda1 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Fri, 31 Jul 2015 13:41:15 +0200 Subject: Xcode: Quote strings containing a tilde (#15672) Since commit v3.3.0-rc1~183^2 (Xcode: Refine quoting rules for Strings, 2015-04-09) we no longer quote strings containing a period ('.'). However, file names like "icon29x29~ipad.png" still need quoting because they contain a tilde ('~'). Add tilde to our explicit list of characters that need quoting because such file names will no longer happen to be quoted because they contain a period. --- Source/cmXCodeObject.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index e72d315..ba6e395 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,7 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},") != String.npos); + String.find_first_of(" <>+-*=@[](){},~") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. -- cgit v0.12 From d4736d53cd61f2cbbb36bec682663b74b01dddce Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jul 2015 13:44:31 -0400 Subject: Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1 (#15674) The GetVersionEx API is deprecated, so try RtlGetVersion first. Co-Author: Christian Maaser --- Source/cmGlobalGenerator.cxx | 56 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cd05c54..1c8d5ea 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -14,6 +14,20 @@ #if defined(_MSC_VER) && _MSC_VER >= 1800 # define KWSYS_WINDOWS_DEPRECATED_GetVersionEx #endif +typedef struct { + ULONG dwOSVersionInfoSize; + ULONG dwMajorVersion; + ULONG dwMinorVersion; + ULONG dwBuildNumber; + ULONG dwPlatformId; + WCHAR szCSDVersion[128]; + USHORT wServicePackMajor; + USHORT wServicePackMinor; + USHORT wSuiteMask; + UCHAR wProductType; + UCHAR wReserved; +} CMRTL_OSVERSIONINFOEXW; + #endif #include "cmGlobalGenerator.h" @@ -437,23 +451,45 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, if (!mf->GetDefinition("CMAKE_SYSTEM")) { #if defined(_WIN32) && !defined(__CYGWIN__) - /* Windows version number data. */ - OSVERSIONINFO osvi; - ZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + CMRTL_OSVERSIONINFOEXW osviex; + ZeroMemory(&osviex, sizeof(osviex)); + osviex.dwOSVersionInfoSize = sizeof(osviex); + + typedef LONG (FAR WINAPI *cmRtlGetVersion)(CMRTL_OSVERSIONINFOEXW*); + cmRtlGetVersion rtlGetVersion = reinterpret_cast( + GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion")); + if (rtlGetVersion && rtlGetVersion(&osviex) == 0) + { + std::ostringstream windowsVersionString; + windowsVersionString << osviex.dwMajorVersion << "." + << osviex.dwMinorVersion << "." + << osviex.dwBuildNumber; + windowsVersionString.str(); + mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", + windowsVersionString.str().c_str()); + } + else + { + // RtlGetVersion failed, so use the deprecated GetVersionEx function. + /* Windows version number data. */ + OSVERSIONINFO osvi; + ZeroMemory(&osvi, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx # pragma warning (push) # pragma warning (disable:4996) #endif - GetVersionEx (&osvi); + GetVersionEx (&osvi); #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx # pragma warning (pop) #endif - std::ostringstream windowsVersionString; - windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; - windowsVersionString.str(); - mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", - windowsVersionString.str().c_str()); + std::ostringstream windowsVersionString; + windowsVersionString << osvi.dwMajorVersion << "." + << osvi.dwMinorVersion; + windowsVersionString.str(); + mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", + windowsVersionString.str().c_str()); + } #endif // Read the DetermineSystem file std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake"); -- cgit v0.12 From 1feafc643b1c50fd0fa8171a4170065ca39d4d4c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 30 Jul 2015 09:08:41 -0400 Subject: KWSys 2015-07-30 (f63febb7) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ f63febb7 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' c9336bcf..f63febb7 Brad King (1): 83b4a6b8 Process: Fix conversion warning in testProcess.c James Johnston (7): 4cd8846c Process: Remove trailing whitespace in ProcessUNIX.c b1c44c58 Process: Refactor sleeping code in testProcess.c. faff2ab0 Process: Wait for children to terminate on Ctrl+C. ef517b19 Process: Added initial support for process groups. 906c2cae Process: Added test cases for testing Ctrl+C and process groups. 52874e6a Process: Fix leaked file descriptor in ProcessUNIX f63febb7 Process: Fix error message for startup failure on Windows --- CMakeLists.txt | 6 +- CTestCustom.cmake.in | 15 ++ Process.h.in | 131 +++++++++------ ProcessUNIX.c | 357 +++++++++++++++++++++++++++++++++------ ProcessWin32.c | 462 +++++++++++++++++++++++++++++++++++++++++++++------ testProcess.c | 267 ++++++++++++++++++++++++----- 6 files changed, 1038 insertions(+), 200 deletions(-) create mode 100644 CTestCustom.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7eb678b..017d619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1237,7 +1237,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) IF(NOT CYGWIN) SET(KWSYS_TEST_PROCESS_7 7) ENDIF() - FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7}) + FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10) ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n}) SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120) @@ -1270,6 +1270,10 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}") ENDIF() + # Set up ctest custom configuration file. + CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/CTestCustom.cmake.in + ${PROJECT_BINARY_DIR}/CTestCustom.cmake @ONLY) + # Suppress known consistent failures on buggy systems. IF(KWSYS_TEST_BOGUS_FAILURES) SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in new file mode 100644 index 0000000..d6f802e --- /dev/null +++ b/CTestCustom.cmake.in @@ -0,0 +1,15 @@ +# kwsys.testProcess-10 involves sending SIGINT to a child process, which then +# exits abnormally via a call to _exit(). (On Windows, a call to ExitProcess). +# Naturally, this results in plenty of memory being "leaked" by this child +# process - the memory check results are not meaningful in this case. +# +# kwsys.testProcess-9 also tests sending SIGINT to a child process. However, +# normal operation of that test involves the child process timing out, and the +# host process kills (SIGKILL) it as a result. Since it was SIGKILL'ed, the +# resulting memory leaks are not logged by valgrind anyway. Therefore, we +# don't have to exclude it. + +set(CTEST_CUSTOM_MEMCHECK_IGNORE + ${CTEST_CUSTOM_MEMCHECK_IGNORE} + kwsys.testProcess-10 + ) diff --git a/Process.h.in b/Process.h.in index e35939f..c5ebc97 100644 --- a/Process.h.in +++ b/Process.h.in @@ -23,58 +23,60 @@ # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT #endif #if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS -# define kwsysProcess kwsys_ns(Process) -# define kwsysProcess_s kwsys_ns(Process_s) -# define kwsysProcess_New kwsys_ns(Process_New) -# define kwsysProcess_Delete kwsys_ns(Process_Delete) -# define kwsysProcess_SetCommand kwsys_ns(Process_SetCommand) -# define kwsysProcess_AddCommand kwsys_ns(Process_AddCommand) -# define kwsysProcess_SetTimeout kwsys_ns(Process_SetTimeout) -# define kwsysProcess_SetWorkingDirectory kwsys_ns(Process_SetWorkingDirectory) -# define kwsysProcess_SetPipeFile kwsys_ns(Process_SetPipeFile) -# define kwsysProcess_SetPipeNative kwsys_ns(Process_SetPipeNative) -# define kwsysProcess_SetPipeShared kwsys_ns(Process_SetPipeShared) -# define kwsysProcess_Option_Detach kwsys_ns(Process_Option_Detach) -# define kwsysProcess_Option_HideWindow kwsys_ns(Process_Option_HideWindow) -# define kwsysProcess_Option_MergeOutput kwsys_ns(Process_Option_MergeOutput) -# define kwsysProcess_Option_Verbatim kwsys_ns(Process_Option_Verbatim) -# define kwsysProcess_GetOption kwsys_ns(Process_GetOption) -# define kwsysProcess_SetOption kwsys_ns(Process_SetOption) -# define kwsysProcess_Option_e kwsys_ns(Process_Option_e) -# define kwsysProcess_State_Starting kwsys_ns(Process_State_Starting) -# define kwsysProcess_State_Error kwsys_ns(Process_State_Error) -# define kwsysProcess_State_Exception kwsys_ns(Process_State_Exception) -# define kwsysProcess_State_Executing kwsys_ns(Process_State_Executing) -# define kwsysProcess_State_Exited kwsys_ns(Process_State_Exited) -# define kwsysProcess_State_Expired kwsys_ns(Process_State_Expired) -# define kwsysProcess_State_Killed kwsys_ns(Process_State_Killed) -# define kwsysProcess_State_Disowned kwsys_ns(Process_State_Disowned) -# define kwsysProcess_GetState kwsys_ns(Process_GetState) -# define kwsysProcess_State_e kwsys_ns(Process_State_e) -# define kwsysProcess_Exception_None kwsys_ns(Process_Exception_None) -# define kwsysProcess_Exception_Fault kwsys_ns(Process_Exception_Fault) -# define kwsysProcess_Exception_Illegal kwsys_ns(Process_Exception_Illegal) -# define kwsysProcess_Exception_Interrupt kwsys_ns(Process_Exception_Interrupt) -# define kwsysProcess_Exception_Numerical kwsys_ns(Process_Exception_Numerical) -# define kwsysProcess_Exception_Other kwsys_ns(Process_Exception_Other) -# define kwsysProcess_GetExitException kwsys_ns(Process_GetExitException) -# define kwsysProcess_Exception_e kwsys_ns(Process_Exception_e) -# define kwsysProcess_GetExitCode kwsys_ns(Process_GetExitCode) -# define kwsysProcess_GetExitValue kwsys_ns(Process_GetExitValue) -# define kwsysProcess_GetErrorString kwsys_ns(Process_GetErrorString) -# define kwsysProcess_GetExceptionString kwsys_ns(Process_GetExceptionString) -# define kwsysProcess_Execute kwsys_ns(Process_Execute) -# define kwsysProcess_Disown kwsys_ns(Process_Disown) -# define kwsysProcess_WaitForData kwsys_ns(Process_WaitForData) -# define kwsysProcess_Pipes_e kwsys_ns(Process_Pipes_e) -# define kwsysProcess_Pipe_None kwsys_ns(Process_Pipe_None) -# define kwsysProcess_Pipe_STDIN kwsys_ns(Process_Pipe_STDIN) -# define kwsysProcess_Pipe_STDOUT kwsys_ns(Process_Pipe_STDOUT) -# define kwsysProcess_Pipe_STDERR kwsys_ns(Process_Pipe_STDERR) -# define kwsysProcess_Pipe_Timeout kwsys_ns(Process_Pipe_Timeout) -# define kwsysProcess_Pipe_Handle kwsys_ns(Process_Pipe_Handle) -# define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit) -# define kwsysProcess_Kill kwsys_ns(Process_Kill) +# define kwsysProcess kwsys_ns(Process) +# define kwsysProcess_s kwsys_ns(Process_s) +# define kwsysProcess_New kwsys_ns(Process_New) +# define kwsysProcess_Delete kwsys_ns(Process_Delete) +# define kwsysProcess_SetCommand kwsys_ns(Process_SetCommand) +# define kwsysProcess_AddCommand kwsys_ns(Process_AddCommand) +# define kwsysProcess_SetTimeout kwsys_ns(Process_SetTimeout) +# define kwsysProcess_SetWorkingDirectory kwsys_ns(Process_SetWorkingDirectory) +# define kwsysProcess_SetPipeFile kwsys_ns(Process_SetPipeFile) +# define kwsysProcess_SetPipeNative kwsys_ns(Process_SetPipeNative) +# define kwsysProcess_SetPipeShared kwsys_ns(Process_SetPipeShared) +# define kwsysProcess_Option_Detach kwsys_ns(Process_Option_Detach) +# define kwsysProcess_Option_HideWindow kwsys_ns(Process_Option_HideWindow) +# define kwsysProcess_Option_MergeOutput kwsys_ns(Process_Option_MergeOutput) +# define kwsysProcess_Option_Verbatim kwsys_ns(Process_Option_Verbatim) +# define kwsysProcess_Option_CreateProcessGroup kwsys_ns(Process_Option_CreateProcessGroup) +# define kwsysProcess_GetOption kwsys_ns(Process_GetOption) +# define kwsysProcess_SetOption kwsys_ns(Process_SetOption) +# define kwsysProcess_Option_e kwsys_ns(Process_Option_e) +# define kwsysProcess_State_Starting kwsys_ns(Process_State_Starting) +# define kwsysProcess_State_Error kwsys_ns(Process_State_Error) +# define kwsysProcess_State_Exception kwsys_ns(Process_State_Exception) +# define kwsysProcess_State_Executing kwsys_ns(Process_State_Executing) +# define kwsysProcess_State_Exited kwsys_ns(Process_State_Exited) +# define kwsysProcess_State_Expired kwsys_ns(Process_State_Expired) +# define kwsysProcess_State_Killed kwsys_ns(Process_State_Killed) +# define kwsysProcess_State_Disowned kwsys_ns(Process_State_Disowned) +# define kwsysProcess_GetState kwsys_ns(Process_GetState) +# define kwsysProcess_State_e kwsys_ns(Process_State_e) +# define kwsysProcess_Exception_None kwsys_ns(Process_Exception_None) +# define kwsysProcess_Exception_Fault kwsys_ns(Process_Exception_Fault) +# define kwsysProcess_Exception_Illegal kwsys_ns(Process_Exception_Illegal) +# define kwsysProcess_Exception_Interrupt kwsys_ns(Process_Exception_Interrupt) +# define kwsysProcess_Exception_Numerical kwsys_ns(Process_Exception_Numerical) +# define kwsysProcess_Exception_Other kwsys_ns(Process_Exception_Other) +# define kwsysProcess_GetExitException kwsys_ns(Process_GetExitException) +# define kwsysProcess_Exception_e kwsys_ns(Process_Exception_e) +# define kwsysProcess_GetExitCode kwsys_ns(Process_GetExitCode) +# define kwsysProcess_GetExitValue kwsys_ns(Process_GetExitValue) +# define kwsysProcess_GetErrorString kwsys_ns(Process_GetErrorString) +# define kwsysProcess_GetExceptionString kwsys_ns(Process_GetExceptionString) +# define kwsysProcess_Execute kwsys_ns(Process_Execute) +# define kwsysProcess_Disown kwsys_ns(Process_Disown) +# define kwsysProcess_WaitForData kwsys_ns(Process_WaitForData) +# define kwsysProcess_Pipes_e kwsys_ns(Process_Pipes_e) +# define kwsysProcess_Pipe_None kwsys_ns(Process_Pipe_None) +# define kwsysProcess_Pipe_STDIN kwsys_ns(Process_Pipe_STDIN) +# define kwsysProcess_Pipe_STDOUT kwsys_ns(Process_Pipe_STDOUT) +# define kwsysProcess_Pipe_STDERR kwsys_ns(Process_Pipe_STDERR) +# define kwsysProcess_Pipe_Timeout kwsys_ns(Process_Pipe_Timeout) +# define kwsysProcess_Pipe_Handle kwsys_ns(Process_Pipe_Handle) +# define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit) +# define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt) +# define kwsysProcess_Kill kwsys_ns(Process_Kill) #endif #if defined(__cplusplus) @@ -199,6 +201,15 @@ kwsysEXPORT void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, * and ignore the rest of the arguments. * 0 = No (default) * 1 = Yes + * + * kwsysProcess_Option_CreateProcessGroup = Whether to place the process in a + * new process group. This is + * useful if you want to send Ctrl+C + * to the process. On UNIX, also + * places the process in a new + * session. + * 0 = No (default) + * 1 = Yes */ kwsysEXPORT int kwsysProcess_GetOption(kwsysProcess* cp, int optionId); kwsysEXPORT void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, @@ -208,7 +219,8 @@ enum kwsysProcess_Option_e kwsysProcess_Option_HideWindow, kwsysProcess_Option_Detach, kwsysProcess_Option_MergeOutput, - kwsysProcess_Option_Verbatim + kwsysProcess_Option_Verbatim, + kwsysProcess_Option_CreateProcessGroup }; /** @@ -363,6 +375,17 @@ enum kwsysProcess_Pipes_e kwsysEXPORT int kwsysProcess_WaitForExit(kwsysProcess* cp, double* timeout); /** + * Interrupt the process group for the child process that is currently + * running by sending it the appropriate operating-system specific signal. + * The caller should call WaitForExit after this returns to wait for the + * child to terminate. + * + * WARNING: If you didn't specify kwsysProcess_Option_CreateProcessGroup, + * you will interrupt your own process group. + */ +kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp); + +/** * Forcefully terminate the child process that is currently running. * The caller should call WaitForExit after this returns to wait for * the child to terminate. @@ -394,6 +417,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); # undef kwsysProcess_Option_HideWindow # undef kwsysProcess_Option_MergeOutput # undef kwsysProcess_Option_Verbatim +# undef kwsysProcess_Option_CreateProcessGroup # undef kwsysProcess_GetOption # undef kwsysProcess_SetOption # undef kwsysProcess_Option_e @@ -430,6 +454,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); # undef kwsysProcess_Pipe_Timeout # undef kwsysProcess_Pipe_Handle # undef kwsysProcess_WaitForExit +# undef kwsysProcess_Interrupt # undef kwsysProcess_Kill # endif #endif diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 0393a6d..6d9b109 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -88,7 +88,7 @@ typedef ssize_t kwsysProcess_ssize_t; typedef int kwsysProcess_ssize_t; #endif -#if defined(__BEOS__) && !defined(__ZETA__) +#if defined(__BEOS__) && !defined(__ZETA__) /* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */ # include static inline void kwsysProcess_usleep(unsigned int msec) @@ -151,6 +151,7 @@ typedef struct kwsysProcessCreateInformation_s } kwsysProcessCreateInformation; /*--------------------------------------------------------------------------*/ +static void kwsysProcessVolatileFree(volatile void* p); static int kwsysProcessInitialize(kwsysProcess* cp); static void kwsysProcessCleanup(kwsysProcess* cp, int error); static void kwsysProcessCleanupDescriptor(int* pfd); @@ -197,7 +198,7 @@ struct kwsysProcess_s { /* The command lines to execute. */ char*** Commands; - int NumberOfCommands; + volatile int NumberOfCommands; /* Descriptors for the read ends of the child's output pipes and the signal pipe. */ @@ -213,8 +214,10 @@ struct kwsysProcess_s /* Buffer for pipe data. */ char PipeBuffer[KWSYSPE_PIPE_BUFFER_SIZE]; - /* Process IDs returned by the calls to fork. */ - pid_t* ForkPIDs; + /* Process IDs returned by the calls to fork. Everything is volatile + because the signal handler accesses them. You must be very careful + when reaping PIDs or modifying this array to avoid race conditions. */ + volatile pid_t* volatile ForkPIDs; /* Flag for whether the children were terminated by a faild select. */ int SelectError; @@ -237,6 +240,9 @@ struct kwsysProcess_s /* Whether to merge stdout/stderr of the child. */ int MergeOutput; + /* Whether to create the process in a new process group. */ + volatile sig_atomic_t CreateProcessGroup; + /* Time at which the child started. Negative for no timeout. */ kwsysProcessTime StartTime; @@ -257,8 +263,9 @@ struct kwsysProcess_s /* The number of children still executing. */ int CommandsLeft; - /* The current status of the child process. */ - int State; + /* The current status of the child process. Must be atomic because + the signal handler checks this to avoid a race. */ + volatile sig_atomic_t State; /* The exceptional behavior that terminated the child process, if * any. */ @@ -271,7 +278,7 @@ struct kwsysProcess_s int ExitValue; /* Whether the process was killed. */ - int Killed; + volatile sig_atomic_t Killed; /* Buffer for error message in case of failure. */ char ErrorMessage[KWSYSPE_PIPE_BUFFER_SIZE+1]; @@ -649,6 +656,8 @@ int kwsysProcess_GetOption(kwsysProcess* cp, int optionId) case kwsysProcess_Option_Detach: return cp->OptionDetach; case kwsysProcess_Option_MergeOutput: return cp->MergeOutput; case kwsysProcess_Option_Verbatim: return cp->Verbatim; + case kwsysProcess_Option_CreateProcessGroup: + return cp->CreateProcessGroup; default: return 0; } } @@ -666,6 +675,8 @@ void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value) case kwsysProcess_Option_Detach: cp->OptionDetach = value; break; case kwsysProcess_Option_MergeOutput: cp->MergeOutput = value; break; case kwsysProcess_Option_Verbatim: cp->Verbatim = value; break; + case kwsysProcess_Option_CreateProcessGroup: + cp->CreateProcessGroup = value; break; default: break; } } @@ -1490,6 +1501,45 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout) } /*--------------------------------------------------------------------------*/ +void kwsysProcess_Interrupt(kwsysProcess* cp) +{ + int i; + /* Make sure we are executing a process. */ + if(!cp || cp->State != kwsysProcess_State_Executing || cp->TimeoutExpired || + cp->Killed) + { + return; + } + + /* Interrupt the children. */ + if (cp->CreateProcessGroup) + { + if(cp->ForkPIDs) + { + for(i=0; i < cp->NumberOfCommands; ++i) + { + /* Make sure the PID is still valid. */ + if(cp->ForkPIDs[i]) + { + /* The user created a process group for this process. The group ID + is the process ID for the original process in the group. */ + kill(-cp->ForkPIDs[i], SIGINT); + } + } + } + } + else + { + /* No process group was created. Kill our own process group. + NOTE: While one could argue that we could call kill(cp->ForkPIDs[i], + SIGINT) as a way to still interrupt the process even though it's not in + a special group, this is not an option on Windows. Therefore, we kill + the current process group for consistency with Windows. */ + kill(0, SIGINT); + } +} + +/*--------------------------------------------------------------------------*/ void kwsysProcess_Kill(kwsysProcess* cp) { int i; @@ -1539,10 +1589,28 @@ void kwsysProcess_Kill(kwsysProcess* cp) } /*--------------------------------------------------------------------------*/ +/* Call the free() function with a pointer to volatile without causing + compiler warnings. */ +static void kwsysProcessVolatileFree(volatile void* p) +{ + /* clang has made it impossible to free memory that points to volatile + without first using special pragmas to disable a warning... */ +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcast-qual" +#endif + free((void*)p); /* The cast will silence most compilers, but not clang. */ +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} + +/*--------------------------------------------------------------------------*/ /* Initialize a process control structure for kwsysProcess_Execute. */ static int kwsysProcessInitialize(kwsysProcess* cp) { int i; + volatile pid_t* oldForkPIDs; for(i=0; i < KWSYSPE_PIPE_COUNT; ++i) { cp->PipeReadEnds[i] = -1; @@ -1571,16 +1639,21 @@ static int kwsysProcessInitialize(kwsysProcess* cp) cp->ErrorMessage[0] = 0; strcpy(cp->ExitExceptionString, "No exception"); - if(cp->ForkPIDs) + oldForkPIDs = cp->ForkPIDs; + cp->ForkPIDs = (volatile pid_t*)malloc( + sizeof(volatile pid_t)*(size_t)(cp->NumberOfCommands)); + if(oldForkPIDs) { - free(cp->ForkPIDs); + kwsysProcessVolatileFree(oldForkPIDs); } - cp->ForkPIDs = (pid_t*)malloc(sizeof(pid_t)*(size_t)(cp->NumberOfCommands)); if(!cp->ForkPIDs) { return 0; } - memset(cp->ForkPIDs, 0, sizeof(pid_t)*(size_t)(cp->NumberOfCommands)); + for(i=0; i < cp->NumberOfCommands; ++i) + { + cp->ForkPIDs[i] = 0; /* can't use memset due to volatile */ + } if(cp->CommandExitCodes) { @@ -1671,7 +1744,7 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error) /* Free memory. */ if(cp->ForkPIDs) { - free(cp->ForkPIDs); + kwsysProcessVolatileFree(cp->ForkPIDs); cp->ForkPIDs = 0; } if(cp->RealWorkingDirectory) @@ -1758,15 +1831,49 @@ int decc$set_child_standard_streams(int fd1, int fd2, int fd3); static int kwsysProcessCreate(kwsysProcess* cp, int prIndex, kwsysProcessCreateInformation* si) { + sigset_t mask, old_mask; + int pgidPipe[2]; + char tmp; + ssize_t readRes; + /* Create the error reporting pipe. */ if(pipe(si->ErrorPipe) < 0) { return 0; } - /* Set close-on-exec flag on the error pipe's write end. */ - if(fcntl(si->ErrorPipe[1], F_SETFD, FD_CLOEXEC) < 0) + /* Create a pipe for detecting that the child process has created a process + group and session. */ + if(pipe(pgidPipe) < 0) { + kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]); + kwsysProcessCleanupDescriptor(&si->ErrorPipe[1]); + return 0; + } + + /* Set close-on-exec flag on the pipe's write end. */ + if(fcntl(si->ErrorPipe[1], F_SETFD, FD_CLOEXEC) < 0 || + fcntl(pgidPipe[1], F_SETFD, FD_CLOEXEC) < 0) + { + kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]); + kwsysProcessCleanupDescriptor(&si->ErrorPipe[1]); + kwsysProcessCleanupDescriptor(&pgidPipe[0]); + kwsysProcessCleanupDescriptor(&pgidPipe[1]); + return 0; + } + + /* Block SIGINT / SIGTERM while we start. The purpose is so that our signal + handler doesn't get called from the child process after the fork and + before the exec, and subsequently start kill()'ing PIDs from ForkPIDs. */ + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGTERM); + if(sigprocmask(SIG_BLOCK, &mask, &old_mask) < 0) + { + kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]); + kwsysProcessCleanupDescriptor(&si->ErrorPipe[1]); + kwsysProcessCleanupDescriptor(&pgidPipe[0]); + kwsysProcessCleanupDescriptor(&pgidPipe[1]); return 0; } @@ -1774,13 +1881,19 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex, #if defined(__VMS) /* VMS needs vfork and execvp to be in the same function because they use setjmp/longjmp to run the child startup code in the - parent! TODO: OptionDetach. */ + parent! TODO: OptionDetach. Also + TODO: CreateProcessGroup. */ cp->ForkPIDs[prIndex] = vfork(); #else cp->ForkPIDs[prIndex] = kwsysProcessFork(cp, si); #endif if(cp->ForkPIDs[prIndex] < 0) { + sigprocmask(SIG_SETMASK, &old_mask, 0); + kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]); + kwsysProcessCleanupDescriptor(&si->ErrorPipe[1]); + kwsysProcessCleanupDescriptor(&pgidPipe[0]); + kwsysProcessCleanupDescriptor(&pgidPipe[1]); return 0; } @@ -1790,8 +1903,10 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex, /* Specify standard pipes for child process. */ decc$set_child_standard_streams(si->StdIn, si->StdOut, si->StdErr); #else - /* Close the read end of the error reporting pipe. */ + /* Close the read end of the error reporting / process group + setup pipe. */ close(si->ErrorPipe[0]); + close(pgidPipe[0]); /* Setup the stdin, stdout, and stderr pipes. */ if(si->StdIn > 0) @@ -1819,11 +1934,25 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex, /* Restore all default signal handlers. */ kwsysProcessRestoreDefaultSignalHandlers(); + + /* Now that we have restored default signal handling and created the + process group, restore mask. */ + sigprocmask(SIG_SETMASK, &old_mask, 0); + + /* Create new process group. We use setsid instead of setpgid to avoid + the child getting hung up on signals like SIGTTOU. (In the real world, + this has been observed where "git svn" ends up calling the "resize" + program which opens /dev/tty. */ + if(cp->CreateProcessGroup && setsid() < 0) + { + kwsysProcessChildErrorExit(si->ErrorPipe[1]); + } #endif /* Execute the real process. If successful, this does not return. */ execvp(cp->Commands[prIndex][0], cp->Commands[prIndex]); /* TODO: What does VMS do if the child fails to start? */ + /* TODO: On VMS, how do we put the process in a new group? */ /* Failure. Report error to parent and terminate. */ kwsysProcessChildErrorExit(si->ErrorPipe[1]); @@ -1834,12 +1963,34 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex, decc$set_child_standard_streams(0, 1, 2); #endif + /* We are done with the error reporting pipe and process group setup pipe + write end. */ + kwsysProcessCleanupDescriptor(&si->ErrorPipe[1]); + kwsysProcessCleanupDescriptor(&pgidPipe[1]); + + /* Make sure the child is in the process group before we proceed. This + avoids race conditions with calls to the kill function that we make for + signalling process groups. */ + while((readRes = read(pgidPipe[0], &tmp, 1)) > 0); + if(readRes < 0) + { + sigprocmask(SIG_SETMASK, &old_mask, 0); + kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]); + kwsysProcessCleanupDescriptor(&pgidPipe[0]); + return 0; + } + kwsysProcessCleanupDescriptor(&pgidPipe[0]); + + /* Unmask signals. */ + if(sigprocmask(SIG_SETMASK, &old_mask, 0) < 0) + { + kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]); + return 0; + } + /* A child has been created. */ ++cp->CommandsLeft; - /* We are done with the error reporting pipe write end. */ - kwsysProcessCleanupDescriptor(&si->ErrorPipe[1]); - /* Block until the child's exec call succeeds and closes the error pipe or writes data to the pipe to report an error. */ { @@ -1877,6 +2028,17 @@ static void kwsysProcessDestroy(kwsysProcess* cp) /* A child process has terminated. Reap it if it is one handled by this object. */ int i; + /* Temporarily disable signals that access ForkPIDs. We don't want them to + read a reaped PID, and writes to ForkPIDs are not atomic. */ + sigset_t mask, old_mask; + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGTERM); + if(sigprocmask(SIG_BLOCK, &mask, &old_mask) < 0) + { + return; + } + for(i=0; i < cp->NumberOfCommands; ++i) { if(cp->ForkPIDs[i]) @@ -1910,6 +2072,9 @@ static void kwsysProcessDestroy(kwsysProcess* cp) } } } + + /* Re-enable signals. */ + sigprocmask(SIG_SETMASK, &old_mask, 0); } /*--------------------------------------------------------------------------*/ @@ -1938,7 +2103,7 @@ static int kwsysProcessSetupOutputPipeFile(int* p, const char* name) /* Assign the replacement descriptor. */ *p = fout; - return 1; + return 1; } /*--------------------------------------------------------------------------*/ @@ -2582,19 +2747,23 @@ typedef struct kwsysProcessInstances_s } kwsysProcessInstances; static kwsysProcessInstances kwsysProcesses; -/* The old SIGCHLD handler. */ +/* The old SIGCHLD / SIGINT / SIGTERM handlers. */ static struct sigaction kwsysProcessesOldSigChldAction; +static struct sigaction kwsysProcessesOldSigIntAction; +static struct sigaction kwsysProcessesOldSigTermAction; /*--------------------------------------------------------------------------*/ static void kwsysProcessesUpdate(kwsysProcessInstances* newProcesses) { - /* Block SIGCHLD while we update the set of pipes to check. + /* Block signals while we update the set of pipes to check. TODO: sigprocmask is undefined for threaded apps. See pthread_sigmask. */ sigset_t newset; sigset_t oldset; sigemptyset(&newset); sigaddset(&newset, SIGCHLD); + sigaddset(&newset, SIGINT); + sigaddset(&newset, SIGTERM); sigprocmask(SIG_BLOCK, &newset, &oldset); /* Store the new set in that seen by the signal handler. */ @@ -2686,21 +2855,36 @@ static int kwsysProcessesAdd(kwsysProcess* cp) { /* Install our handler for SIGCHLD. Repeat call until it is not interrupted. */ - struct sigaction newSigChldAction; - memset(&newSigChldAction, 0, sizeof(struct sigaction)); + struct sigaction newSigAction; + memset(&newSigAction, 0, sizeof(struct sigaction)); #if KWSYSPE_USE_SIGINFO - newSigChldAction.sa_sigaction = kwsysProcessesSignalHandler; - newSigChldAction.sa_flags = SA_NOCLDSTOP | SA_SIGINFO; + newSigAction.sa_sigaction = kwsysProcessesSignalHandler; + newSigAction.sa_flags = SA_NOCLDSTOP | SA_SIGINFO; # ifdef SA_RESTART - newSigChldAction.sa_flags |= SA_RESTART; + newSigAction.sa_flags |= SA_RESTART; # endif #else - newSigChldAction.sa_handler = kwsysProcessesSignalHandler; - newSigChldAction.sa_flags = SA_NOCLDSTOP; + newSigAction.sa_handler = kwsysProcessesSignalHandler; + newSigAction.sa_flags = SA_NOCLDSTOP; #endif - while((sigaction(SIGCHLD, &newSigChldAction, + sigemptyset(&newSigAction.sa_mask); + while((sigaction(SIGCHLD, &newSigAction, &kwsysProcessesOldSigChldAction) < 0) && (errno == EINTR)); + + /* Install our handler for SIGINT / SIGTERM. Repeat call until + it is not interrupted. */ + sigemptyset(&newSigAction.sa_mask); + sigaddset(&newSigAction.sa_mask, SIGTERM); + while((sigaction(SIGINT, &newSigAction, + &kwsysProcessesOldSigIntAction) < 0) && + (errno == EINTR)); + + sigemptyset(&newSigAction.sa_mask); + sigaddset(&newSigAction.sa_mask, SIGINT); + while((sigaction(SIGTERM, &newSigAction, + &kwsysProcessesOldSigIntAction) < 0) && + (errno == EINTR)); } } @@ -2734,10 +2918,14 @@ static void kwsysProcessesRemove(kwsysProcess* cp) /* If this was the last process, disable the signal handler. */ if(newProcesses.Count == 0) { - /* Restore the SIGCHLD handler. Repeat call until it is not + /* Restore the signal handlers. Repeat call until it is not interrupted. */ while((sigaction(SIGCHLD, &kwsysProcessesOldSigChldAction, 0) < 0) && (errno == EINTR)); + while((sigaction(SIGINT, &kwsysProcessesOldSigIntAction, 0) < 0) && + (errno == EINTR)); + while((sigaction(SIGTERM, &kwsysProcessesOldSigTermAction, 0) < 0) && + (errno == EINTR)); /* Free the table of process pointers since it is now empty. This is safe because the signal handler has been removed. */ @@ -2763,39 +2951,108 @@ static void kwsysProcessesSignalHandler(int signum #endif ) { - (void)signum; + int i, j, procStatus, old_errno = errno; #if KWSYSPE_USE_SIGINFO (void)info; (void)ucontext; #endif /* Signal all process objects that a child has terminated. */ - { - int i; - for(i=0; i < kwsysProcesses.Count; ++i) + switch(signum) { - /* Set the pipe in a signalled state. */ - char buf = 1; - kwsysProcess* cp = kwsysProcesses.Processes[i]; - kwsysProcess_ssize_t status= - read(cp->PipeReadEnds[KWSYSPE_PIPE_SIGNAL], &buf, 1); - (void)status; - status=write(cp->SignalPipe, &buf, 1); - (void)status; + case SIGCHLD: + for(i=0; i < kwsysProcesses.Count; ++i) + { + /* Set the pipe in a signalled state. */ + char buf = 1; + kwsysProcess* cp = kwsysProcesses.Processes[i]; + kwsysProcess_ssize_t pipeStatus= + read(cp->PipeReadEnds[KWSYSPE_PIPE_SIGNAL], &buf, 1); + (void)pipeStatus; + pipeStatus=write(cp->SignalPipe, &buf, 1); + (void)pipeStatus; + } + break; + case SIGINT: + case SIGTERM: + /* Signal child processes that are running in new process groups. */ + for(i=0; i < kwsysProcesses.Count; ++i) + { + kwsysProcess* cp = kwsysProcesses.Processes[i]; + /* Check Killed to avoid data race condition when killing. + Check State to avoid data race condition in kwsysProcessCleanup + when there is an error (it leaves a reaped PID). */ + if(cp->CreateProcessGroup && !cp->Killed && + cp->State != kwsysProcess_State_Error && cp->ForkPIDs) + { + for(j=0; j < cp->NumberOfCommands; ++j) + { + /* Make sure the PID is still valid. */ + if(cp->ForkPIDs[j]) + { + /* The user created a process group for this process. The group ID + is the process ID for the original process in the group. */ + kill(-cp->ForkPIDs[j], SIGINT); + } + } + } + } + + /* Wait for all processes to terminate. */ + while(wait(&procStatus) >= 0 || errno != ECHILD) + { + } + + /* Terminate the process, which is now in an inconsistent state + because we reaped all the PIDs that it may have been reaping + or may have reaped in the future. Reraise the signal so that + the proper exit code is returned. */ + { + /* Install default signal handler. */ + struct sigaction defSigAction; + sigset_t unblockSet; + memset(&defSigAction, 0, sizeof(defSigAction)); + defSigAction.sa_handler = SIG_DFL; + sigemptyset(&defSigAction.sa_mask); + while((sigaction(signum, &defSigAction, 0) < 0) && + (errno == EINTR)); + /* Unmask the signal. */ + sigemptyset(&unblockSet); + sigaddset(&unblockSet, signum); + sigprocmask(SIG_UNBLOCK, &unblockSet, 0); + /* Raise the signal again. */ + raise(signum); + /* We shouldn't get here... but if we do... */ + _exit(1); + } + /* break omitted to silence unreachable code clang compiler warning. */ } - } #if !KWSYSPE_USE_SIGINFO - /* Re-Install our handler for SIGCHLD. Repeat call until it is not - interrupted. */ + /* Re-Install our handler. Repeat call until it is not interrupted. */ { - struct sigaction newSigChldAction; - memset(&newSigChldAction, 0, sizeof(struct sigaction)); + struct sigaction newSigAction; + struct sigaction &oldSigAction; + memset(&newSigAction, 0, sizeof(struct sigaction)); newSigChldAction.sa_handler = kwsysProcessesSignalHandler; newSigChldAction.sa_flags = SA_NOCLDSTOP; - while((sigaction(SIGCHLD, &newSigChldAction, - &kwsysProcessesOldSigChldAction) < 0) && + sigemptyset(&newSigAction.sa_mask); + switch(signum) + { + case SIGCHLD: oldSigAction = &kwsysProcessesOldSigChldAction; break; + case SIGINT: + sigaddset(&newSigAction.sa_mask, SIGTERM); + oldSigAction = &kwsysProcessesOldSigIntAction; break; + case SIGTERM: + sigaddset(&newSigAction.sa_mask, SIGINT); + oldSigAction = &kwsysProcessesOldSigTermAction; break; + default: return 0; + } + while((sigaction(signum, &newSigAction, + oldSigAction) < 0) && (errno == EINTR)); } #endif + + errno = old_errno; } diff --git a/ProcessWin32.c b/ProcessWin32.c index a7dd2ca..1f8749f 100644 --- a/ProcessWin32.c +++ b/ProcessWin32.c @@ -109,14 +109,15 @@ static DWORD WINAPI kwsysProcessPipeThreadWake(LPVOID ptd); static void kwsysProcessPipeThreadWakePipe(kwsysProcess* cp, kwsysProcessPipeData* td); static int kwsysProcessInitialize(kwsysProcess* cp); -static int kwsysProcessCreate(kwsysProcess* cp, int index, - kwsysProcessCreateInformation* si); +static DWORD kwsysProcessCreate(kwsysProcess* cp, int index, + kwsysProcessCreateInformation* si); static void kwsysProcessDestroy(kwsysProcess* cp, int event); -static int kwsysProcessSetupOutputPipeFile(PHANDLE handle, const char* name); +static DWORD kwsysProcessSetupOutputPipeFile(PHANDLE handle, + const char* name); static void kwsysProcessSetupSharedPipe(DWORD nStdHandle, PHANDLE handle); static void kwsysProcessSetupPipeNative(HANDLE native, PHANDLE handle); static void kwsysProcessCleanupHandle(PHANDLE h); -static void kwsysProcessCleanup(kwsysProcess* cp, int error); +static void kwsysProcessCleanup(kwsysProcess* cp, DWORD error); static void kwsysProcessCleanErrorMessage(kwsysProcess* cp); static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout, kwsysProcessTime* timeoutTime); @@ -133,6 +134,13 @@ static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1, kwsysProc static void kwsysProcessSetExitException(kwsysProcess* cp, int code); static void kwsysProcessKillTree(int pid); static void kwsysProcessDisablePipeThreads(kwsysProcess* cp); +static int kwsysProcessesInitialize(void); +static int kwsysTryEnterCreateProcessSection(void); +static void kwsysLeaveCreateProcessSection(void); +static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessId, + int newProcessGroup); +static void kwsysProcessesRemove(HANDLE hProcess); +static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType); /*--------------------------------------------------------------------------*/ /* A structure containing synchronization data for each thread. */ @@ -222,6 +230,9 @@ struct kwsysProcess_s /* Whether to merge stdout/stderr of the child. */ int MergeOutput; + /* Whether to create the process in a new process group. */ + int CreateProcessGroup; + /* Mutex to protect the shared index used by threads to report data. */ HANDLE SharedIndexMutex; @@ -321,6 +332,16 @@ kwsysProcess* kwsysProcess_New(void) /* Windows version number data. */ OSVERSIONINFO osv; + /* Initialize list of processes before we get any farther. It's especially + important that the console Ctrl handler be added BEFORE starting the + first process. This prevents the risk of an orphaned process being + started by the main thread while the default Ctrl handler is in + progress. */ + if(!kwsysProcessesInitialize()) + { + return 0; + } + /* Allocate a process control structure. */ cp = (kwsysProcess*)malloc(sizeof(kwsysProcess)); if(!cp) @@ -836,6 +857,8 @@ int kwsysProcess_GetOption(kwsysProcess* cp, int optionId) case kwsysProcess_Option_HideWindow: return cp->HideWindow; case kwsysProcess_Option_MergeOutput: return cp->MergeOutput; case kwsysProcess_Option_Verbatim: return cp->Verbatim; + case kwsysProcess_Option_CreateProcessGroup: + return cp->CreateProcessGroup; default: return 0; } } @@ -854,6 +877,8 @@ void kwsysProcess_SetOption(kwsysProcess* cp, int optionId, int value) case kwsysProcess_Option_HideWindow: cp->HideWindow = value; break; case kwsysProcess_Option_MergeOutput: cp->MergeOutput = value; break; case kwsysProcess_Option_Verbatim: cp->Verbatim = value; break; + case kwsysProcess_Option_CreateProcessGroup: + cp->CreateProcessGroup = value; break; default: break; } } @@ -945,7 +970,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) if(!GetCurrentDirectoryW(cp->RealWorkingDirectoryLength, cp->RealWorkingDirectory)) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, GetLastError()); return; } SetCurrentDirectoryW(cp->WorkingDirectory); @@ -957,14 +982,16 @@ void kwsysProcess_Execute(kwsysProcess* cp) { /* Create a handle to read a file for stdin. */ wchar_t* wstdin = kwsysEncoding_DupToWide(cp->PipeFileSTDIN); + DWORD error; cp->PipeChildStd[0] = CreateFileW(wstdin, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); + error = GetLastError(); /* Check now in case free changes this. */ free(wstdin); if(cp->PipeChildStd[0] == INVALID_HANDLE_VALUE) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, error); return; } } @@ -990,17 +1017,18 @@ void kwsysProcess_Execute(kwsysProcess* cp) if(!CreatePipe(&cp->Pipe[KWSYSPE_PIPE_STDOUT].Read, &cp->Pipe[KWSYSPE_PIPE_STDOUT].Write, 0, 0)) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, GetLastError()); return; } if(cp->PipeFileSTDOUT) { /* Use a file for stdout. */ - if(!kwsysProcessSetupOutputPipeFile(&cp->PipeChildStd[1], - cp->PipeFileSTDOUT)) + DWORD error = kwsysProcessSetupOutputPipeFile(&cp->PipeChildStd[1], + cp->PipeFileSTDOUT); + if(error) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, error); return; } } @@ -1023,7 +1051,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) GetCurrentProcess(), &cp->PipeChildStd[1], 0, FALSE, DUPLICATE_SAME_ACCESS)) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, GetLastError()); return; } } @@ -1034,17 +1062,18 @@ void kwsysProcess_Execute(kwsysProcess* cp) if(!CreatePipe(&cp->Pipe[KWSYSPE_PIPE_STDERR].Read, &cp->Pipe[KWSYSPE_PIPE_STDERR].Write, 0, 0)) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, GetLastError()); return; } if(cp->PipeFileSTDERR) { /* Use a file for stderr. */ - if(!kwsysProcessSetupOutputPipeFile(&cp->PipeChildStd[2], - cp->PipeFileSTDERR)) + DWORD error = kwsysProcessSetupOutputPipeFile(&cp->PipeChildStd[2], + cp->PipeFileSTDERR); + if(error) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, error); return; } } @@ -1067,7 +1096,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) GetCurrentProcess(), &cp->PipeChildStd[2], 0, FALSE, DUPLICATE_SAME_ACCESS)) { - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, GetLastError()); return; } } @@ -1106,11 +1135,12 @@ void kwsysProcess_Execute(kwsysProcess* cp) HANDLE p[2] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}; if (!CreatePipe(&p[0], &p[1], 0, 0)) { + DWORD error = GetLastError(); if (nextStdInput != cp->PipeChildStd[0]) { kwsysProcessCleanupHandle(&nextStdInput); } - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, error); return; } nextStdInput = p[0]; @@ -1119,7 +1149,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) si.hStdError = cp->MergeOutput? cp->PipeChildStd[1] : cp->PipeChildStd[2]; { - int res = kwsysProcessCreate(cp, i, &si); + DWORD error = kwsysProcessCreate(cp, i, &si); /* Close our copies of pipes used between children. */ if (si.hStdInput != cp->PipeChildStd[0]) @@ -1134,7 +1164,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) { kwsysProcessCleanupHandle(&si.hStdError); } - if (res) + if (!error) { cp->ProcessEvents[i+1] = cp->ProcessInformation[i].hProcess; } @@ -1144,7 +1174,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) { kwsysProcessCleanupHandle(&nextStdInput); } - kwsysProcessCleanup(cp, 1); + kwsysProcessCleanup(cp, error); return; } } @@ -1460,6 +1490,52 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout) } /*--------------------------------------------------------------------------*/ +void kwsysProcess_Interrupt(kwsysProcess* cp) +{ + int i; + /* Make sure we are executing a process. */ + if(!cp || cp->State != kwsysProcess_State_Executing || cp->TimeoutExpired || + cp->Killed) + { + KWSYSPE_DEBUG((stderr, "interrupt: child not executing\n")); + return; + } + + /* Skip actually interrupting the child if it has already terminated. */ + if(cp->Terminated) + { + KWSYSPE_DEBUG((stderr, "interrupt: child already terminated\n")); + return; + } + + /* Interrupt the children. */ + if (cp->CreateProcessGroup) + { + if(cp->ProcessInformation) + { + for(i=0; i < cp->NumberOfCommands; ++i) + { + /* Make sure the process handle isn't closed (e.g. from disowning). */ + if(cp->ProcessInformation[i].hProcess) + { + /* The user created a process group for this process. The group ID + is the process ID for the original process in the group. Note + that we have to use Ctrl+Break: Ctrl+C is not allowed for process + groups. */ + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, + cp->ProcessInformation[i].dwProcessId); + } + } + } + } + else + { + /* No process group was created. Kill our own process group... */ + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0); + } +} + +/*--------------------------------------------------------------------------*/ void kwsysProcess_Kill(kwsysProcess* cp) { int i; @@ -1487,7 +1563,8 @@ void kwsysProcess_Kill(kwsysProcess* cp) for(i=0; i < cp->NumberOfCommands; ++i) { kwsysProcessKillTree(cp->ProcessInformation[i].dwProcessId); - // close the handle if we kill it + /* Remove from global list of processes and close handles. */ + kwsysProcessesRemove(cp->ProcessInformation[i].hProcess); kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hThread); kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hProcess); } @@ -1686,7 +1763,7 @@ int kwsysProcessInitialize(kwsysProcess* cp) } /*--------------------------------------------------------------------------*/ -static int kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn) +static DWORD kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn) { DWORD flags; @@ -1697,13 +1774,19 @@ static int kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn) if (flags & HANDLE_FLAG_INHERIT) { *out = in; - return 1; + return ERROR_SUCCESS; } /* Create an inherited copy of this handle. */ - return DuplicateHandle(GetCurrentProcess(), in, - GetCurrentProcess(), out, - 0, TRUE, DUPLICATE_SAME_ACCESS); + if (DuplicateHandle(GetCurrentProcess(), in, GetCurrentProcess(), out, + 0, TRUE, DUPLICATE_SAME_ACCESS)) + { + return ERROR_SUCCESS; + } + else + { + return GetLastError(); + } } else { @@ -1719,29 +1802,46 @@ static int kwsysProcessCreateChildHandle(PHANDLE out, HANDLE in, int isStdIn) (GENERIC_WRITE | FILE_READ_ATTRIBUTES)), FILE_SHARE_READ|FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, 0); - return *out != INVALID_HANDLE_VALUE; + return (*out != INVALID_HANDLE_VALUE) ? ERROR_SUCCESS : GetLastError(); } - } /*--------------------------------------------------------------------------*/ -int kwsysProcessCreate(kwsysProcess* cp, int index, - kwsysProcessCreateInformation* si) +DWORD kwsysProcessCreate(kwsysProcess* cp, int index, + kwsysProcessCreateInformation* si) { - int res = + DWORD creationFlags; + DWORD error = ERROR_SUCCESS; + + /* Check if we are currently exiting. */ + if (!kwsysTryEnterCreateProcessSection()) + { + /* The Ctrl handler is currently working on exiting our process. Rather + than return an error code, which could cause incorrect conclusions to be + reached by the caller, we simply hang. (For example, a CMake try_run + configure step might cause the project to configure wrong.) */ + Sleep(INFINITE); + } - /* Create inherited copies the handles. */ - kwsysProcessCreateChildHandle(&si->StartupInfo.hStdInput, - si->hStdInput, 1) && - kwsysProcessCreateChildHandle(&si->StartupInfo.hStdOutput, - si->hStdOutput, 0) && - kwsysProcessCreateChildHandle(&si->StartupInfo.hStdError, - si->hStdError, 0) && + /* Create the child in a suspended state so we can wait until all + children have been created before running any one. */ + creationFlags = CREATE_SUSPENDED; + if (cp->CreateProcessGroup) + { + creationFlags |= CREATE_NEW_PROCESS_GROUP; + } - /* Create the child in a suspended state so we can wait until all - children have been created before running any one. */ - CreateProcessW(0, cp->Commands[index], 0, 0, TRUE, CREATE_SUSPENDED, 0, - 0, &si->StartupInfo, &cp->ProcessInformation[index]); + /* Create inherited copies of the handles. */ + (error = kwsysProcessCreateChildHandle(&si->StartupInfo.hStdInput, + si->hStdInput, 1)) || + (error = kwsysProcessCreateChildHandle(&si->StartupInfo.hStdOutput, + si->hStdOutput, 0)) || + (error = kwsysProcessCreateChildHandle(&si->StartupInfo.hStdError, + si->hStdError, 0)) || + /* Create the process. */ + (!CreateProcessW(0, cp->Commands[index], 0, 0, TRUE, creationFlags, 0, + 0, &si->StartupInfo, &cp->ProcessInformation[index]) && + (error = GetLastError())); /* Close the inherited copies of the handles. */ if (si->StartupInfo.hStdInput != si->hStdInput) @@ -1757,7 +1857,23 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, kwsysProcessCleanupHandle(&si->StartupInfo.hStdError); } - return res; + /* Add the process to the global list of processes. */ + if (!error && + !kwsysProcessesAdd(cp->ProcessInformation[index].hProcess, + cp->ProcessInformation[index].dwProcessId, cp->CreateProcessGroup)) + { + /* This failed for some reason. Kill the suspended process. */ + TerminateProcess(cp->ProcessInformation[index].hProcess, 1); + /* And clean up... */ + kwsysProcessCleanupHandle(&cp->ProcessInformation[index].hProcess); + kwsysProcessCleanupHandle(&cp->ProcessInformation[index].hThread); + strcpy(cp->ErrorMessage, "kwsysProcessesAdd function failed"); + error = ERROR_NOT_ENOUGH_MEMORY; /* Most likely reason. */ + } + + /* If the console Ctrl handler is waiting for us, this will release it... */ + kwsysLeaveCreateProcessSection(); + return error; } /*--------------------------------------------------------------------------*/ @@ -1779,6 +1895,9 @@ void kwsysProcessDestroy(kwsysProcess* cp, int event) GetExitCodeProcess(cp->ProcessInformation[index].hProcess, &cp->CommandExitCodes[index]); + /* Remove from global list of processes. */ + kwsysProcessesRemove(cp->ProcessInformation[index].hProcess); + /* Close the process handle for the terminated process. */ kwsysProcessCleanupHandle(&cp->ProcessInformation[index].hProcess); @@ -1813,13 +1932,14 @@ void kwsysProcessDestroy(kwsysProcess* cp, int event) } /*--------------------------------------------------------------------------*/ -int kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) +DWORD kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) { HANDLE fout; wchar_t* wname; + DWORD error; if(!name) { - return 1; + return ERROR_INVALID_PARAMETER; } /* Close the existing handle. */ @@ -1829,15 +1949,16 @@ int kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) wname = kwsysEncoding_DupToWide(name); fout = CreateFileW(wname, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0); + error = GetLastError(); free(wname); if(fout == INVALID_HANDLE_VALUE) { - return 0; + return error; } /* Assign the replacement handle. */ *phandle = fout; - return 1; + return ERROR_SUCCESS; } /*--------------------------------------------------------------------------*/ @@ -1876,7 +1997,7 @@ void kwsysProcessCleanupHandle(PHANDLE h) /*--------------------------------------------------------------------------*/ /* Close all handles created by kwsysProcess_Execute. */ -void kwsysProcessCleanup(kwsysProcess* cp, int error) +void kwsysProcessCleanup(kwsysProcess* cp, DWORD error) { int i; /* If this is an error case, report the error. */ @@ -1886,21 +2007,27 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) if(cp->ErrorMessage[0] == 0) { /* Format the error message. */ - DWORD original = GetLastError(); wchar_t err_msg[KWSYSPE_PIPE_BUFFER_SIZE]; DWORD length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, + FORMAT_MESSAGE_IGNORE_INSERTS, 0, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_msg, KWSYSPE_PIPE_BUFFER_SIZE, 0); - WideCharToMultiByte(CP_UTF8, 0, err_msg, -1, cp->ErrorMessage, - KWSYSPE_PIPE_BUFFER_SIZE, NULL, NULL); if(length < 1) { /* FormatMessage failed. Use a default message. */ _snprintf(cp->ErrorMessage, KWSYSPE_PIPE_BUFFER_SIZE, "Process execution failed with error 0x%X. " "FormatMessage failed with error 0x%X", - original, GetLastError()); + error, GetLastError()); + } + if(!WideCharToMultiByte(CP_UTF8, 0, err_msg, -1, cp->ErrorMessage, + KWSYSPE_PIPE_BUFFER_SIZE, NULL, NULL)) + { + /* WideCharToMultiByte failed. Use a default message. */ + _snprintf(cp->ErrorMessage, KWSYSPE_PIPE_BUFFER_SIZE, + "Process execution failed with error 0x%X. " + "WideCharToMultiByte failed with error 0x%X", + error, GetLastError()); } } @@ -1923,6 +2050,8 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) } for(i=0; i < cp->NumberOfCommands; ++i) { + /* Remove from global list of processes and close handles. */ + kwsysProcessesRemove(cp->ProcessInformation[i].hProcess); kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hThread); kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hProcess); } @@ -2659,3 +2788,230 @@ static void kwsysProcessDisablePipeThreads(kwsysProcess* cp) ReleaseSemaphore(cp->Pipe[cp->CurrentIndex].Reader.Go, 1, 0); } } + +/*--------------------------------------------------------------------------*/ +/* Global set of executing processes for use by the Ctrl handler. + This global instance will be zero-initialized by the compiler. + + Note that the console Ctrl handler runs on a background thread and so + everything it does must be thread safe. Here, we track the hProcess + HANDLEs directly instead of kwsysProcess instances, so that we don't have + to make kwsysProcess thread safe. */ +typedef struct kwsysProcessInstance_s +{ + HANDLE hProcess; + DWORD dwProcessId; + int NewProcessGroup; /* Whether the process was created in a new group. */ +} kwsysProcessInstance; + +typedef struct kwsysProcessInstances_s +{ + /* Whether we have initialized key fields below, like critical sections. */ + int Initialized; + + /* Ctrl handler runs on a different thread, so we must sync access. */ + CRITICAL_SECTION Lock; + + int Exiting; + size_t Count; + size_t Size; + kwsysProcessInstance* Processes; +} kwsysProcessInstances; +static kwsysProcessInstances kwsysProcesses; + +/*--------------------------------------------------------------------------*/ +/* Initialize critial section and set up console Ctrl handler. You MUST call + this before using any other kwsysProcesses* functions below. */ +static int kwsysProcessesInitialize(void) +{ + /* Initialize everything if not done already. */ + if(!kwsysProcesses.Initialized) + { + InitializeCriticalSection(&kwsysProcesses.Lock); + + /* Set up console ctrl handler. */ + if(!SetConsoleCtrlHandler(kwsysCtrlHandler, TRUE)) + { + return 0; + } + + kwsysProcesses.Initialized = 1; + } + return 1; +} + +/*--------------------------------------------------------------------------*/ +/* The Ctrl handler waits on the global list of processes. To prevent an + orphaned process, do not create a new process if the Ctrl handler is + already running. Do so by using this function to check if it is ok to + create a process. */ +static int kwsysTryEnterCreateProcessSection(void) +{ + /* Enter main critical section; this means creating a process and the Ctrl + handler are mutually exclusive. */ + EnterCriticalSection(&kwsysProcesses.Lock); + /* Indicate to the caller if they can create a process. */ + if(kwsysProcesses.Exiting) + { + LeaveCriticalSection(&kwsysProcesses.Lock); + return 0; + } + else + { + return 1; + } +} + +/*--------------------------------------------------------------------------*/ +/* Matching function on successful kwsysTryEnterCreateProcessSection return. + Make sure you called kwsysProcessesAdd if applicable before calling this.*/ +static void kwsysLeaveCreateProcessSection(void) +{ + LeaveCriticalSection(&kwsysProcesses.Lock); +} + +/*--------------------------------------------------------------------------*/ +/* Add new process to global process list. The Ctrl handler will wait for + the process to exit before it returns. Do not close the process handle + until after calling kwsysProcessesRemove. The newProcessGroup parameter + must be set if the process was created with CREATE_NEW_PROCESS_GROUP. */ +static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessid, + int newProcessGroup) +{ + if(!kwsysProcessesInitialize() || !hProcess || + hProcess == INVALID_HANDLE_VALUE) + { + return 0; + } + + /* Enter the critical section. */ + EnterCriticalSection(&kwsysProcesses.Lock); + + /* Make sure there is enough space for the new process handle. */ + if(kwsysProcesses.Count == kwsysProcesses.Size) + { + size_t newSize; + kwsysProcessInstance *newArray; + /* Start with enough space for a small number of process handles + and double the size each time more is needed. */ + newSize = kwsysProcesses.Size? kwsysProcesses.Size*2 : 4; + + /* Try allocating the new block of memory. */ + if(newArray = (kwsysProcessInstance*)malloc( + newSize*sizeof(kwsysProcessInstance))) + { + /* Copy the old process handles to the new memory. */ + if(kwsysProcesses.Count > 0) + { + memcpy(newArray, kwsysProcesses.Processes, + kwsysProcesses.Count * sizeof(kwsysProcessInstance)); + } + } + else + { + /* Failed to allocate memory for the new process handle set. */ + LeaveCriticalSection(&kwsysProcesses.Lock); + return 0; + } + + /* Free original array. */ + free(kwsysProcesses.Processes); + + /* Update original structure with new allocation. */ + kwsysProcesses.Size = newSize; + kwsysProcesses.Processes = newArray; + } + + /* Append the new process information to the set. */ + kwsysProcesses.Processes[kwsysProcesses.Count].hProcess = hProcess; + kwsysProcesses.Processes[kwsysProcesses.Count].dwProcessId = dwProcessid; + kwsysProcesses.Processes[kwsysProcesses.Count++].NewProcessGroup = + newProcessGroup; + + /* Leave critical section and return success. */ + LeaveCriticalSection(&kwsysProcesses.Lock); + + return 1; +} + +/*--------------------------------------------------------------------------*/ +/* Removes process to global process list. */ +static void kwsysProcessesRemove(HANDLE hProcess) +{ + size_t i; + + if (!hProcess || hProcess == INVALID_HANDLE_VALUE) + { + return; + } + + EnterCriticalSection(&kwsysProcesses.Lock); + + /* Find the given process in the set. */ + for(i=0; i < kwsysProcesses.Count; ++i) + { + if(kwsysProcesses.Processes[i].hProcess == hProcess) + { + break; + } + } + if(i < kwsysProcesses.Count) + { + /* Found it! Remove the process from the set. */ + --kwsysProcesses.Count; + for(; i < kwsysProcesses.Count; ++i) + { + kwsysProcesses.Processes[i] = kwsysProcesses.Processes[i+1]; + } + + /* If this was the last process, free the array. */ + if(kwsysProcesses.Count == 0) + { + kwsysProcesses.Size = 0; + free(kwsysProcesses.Processes); + kwsysProcesses.Processes = 0; + } + } + + LeaveCriticalSection(&kwsysProcesses.Lock); +} + +/*--------------------------------------------------------------------------*/ +static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType) +{ + size_t i; + (void)dwCtrlType; + /* Enter critical section. */ + EnterCriticalSection(&kwsysProcesses.Lock); + + /* Set flag indicating that we are exiting. */ + kwsysProcesses.Exiting = 1; + + /* If some of our processes were created in a new process group, we must + manually interrupt them. They won't otherwise receive a Ctrl+C/Break. */ + for(i=0; i < kwsysProcesses.Count; ++i) + { + if(kwsysProcesses.Processes[i].NewProcessGroup) + { + DWORD groupId = kwsysProcesses.Processes[i].dwProcessId; + if(groupId) + { + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, groupId); + } + } + } + + /* Wait for each child process to exit. This is the key step that prevents + us from leaving several orphaned children processes running in the + background when the user presses Ctrl+C. */ + for(i=0; i < kwsysProcesses.Count; ++i) + { + WaitForSingleObject(kwsysProcesses.Processes[i].hProcess, INFINITE); + } + + /* Leave critical section. */ + LeaveCriticalSection(&kwsysProcesses.Lock); + + /* Continue on to default Ctrl handler (which calls ExitProcess). */ + return FALSE; +} diff --git a/testProcess.c b/testProcess.c index 47c3fb0..d0e20c1 100644 --- a/testProcess.c +++ b/testProcess.c @@ -29,26 +29,48 @@ # include #else # include +# include #endif #if defined(__BORLANDC__) # pragma warn -8060 /* possibly incorrect assignment */ #endif +/* Platform-specific sleep functions. */ + #if defined(__BEOS__) && !defined(__ZETA__) /* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */ # include -static inline void testProcess_usleep(unsigned int msec) +static inline void testProcess_usleep(unsigned int usec) +{ + snooze(usec); +} +#elif defined(_WIN32) +/* Windows can only sleep in millisecond intervals. */ +static void testProcess_usleep(unsigned int usec) { - snooze(msec); + Sleep(usec / 1000); } #else # define testProcess_usleep usleep #endif +#if defined(_WIN32) +static void testProcess_sleep(unsigned int sec) +{ + Sleep(sec*1000); +} +#else +static void testProcess_sleep(unsigned int sec) +{ + sleep(sec); +} +#endif + 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 repeat, int disown, int createNewGroup, + unsigned int interruptDelay); static int test1(int argc, const char* argv[]) { @@ -73,11 +95,7 @@ static int test3(int argc, const char* argv[]) fprintf(stderr, "Output before sleep on stderr from timeout test.\n"); fflush(stdout); fflush(stderr); -#if defined(_WIN32) - Sleep(15000); -#else - sleep(15); -#endif + testProcess_sleep(15); fprintf(stdout, "Output after sleep on stdout from timeout test.\n"); fprintf(stderr, "Output after sleep on stderr from timeout test.\n"); return 0; @@ -102,7 +120,7 @@ static int test4(int argc, const char* argv[]) #endif (void)argc; (void)argv; fprintf(stdout, "Output before crash on stdout from crash test.\n"); - fprintf(stderr, "Output before crash on stderr from crash test.\n"); + fprintf(stderr, "Output before crash on stderr from crash test.\n"); fflush(stdout); fflush(stderr); assert(invalidAddress); /* Quiet Clang scan-build. */ @@ -127,7 +145,7 @@ static int test5(int argc, const char* argv[]) fflush(stdout); fflush(stderr); r = runChild(cmd, kwsysProcess_State_Exception, - kwsysProcess_Exception_Fault, 1, 1, 1, 0, 15, 0, 1, 0); + kwsysProcess_Exception_Fault, 1, 1, 1, 0, 15, 0, 1, 0, 0, 0); fprintf(stdout, "Output on stdout after recursive test.\n"); fprintf(stderr, "Output on stderr after recursive test.\n"); fflush(stdout); @@ -168,11 +186,7 @@ static int test7(int argc, const char* argv[]) fflush(stdout); fflush(stderr); /* Sleep for 1 second. */ -#if defined(_WIN32) - Sleep(1000); -#else - sleep(1); -#endif + testProcess_sleep(1); fprintf(stdout, "Output on stdout after sleep.\n"); fprintf(stderr, "Output on stderr after sleep.\n"); fflush(stdout); @@ -196,7 +210,7 @@ static int test8(int argc, const char* argv[]) fflush(stdout); fflush(stderr); r = runChild(cmd, kwsysProcess_State_Disowned, kwsysProcess_Exception_None, - 1, 1, 1, 0, 10, 0, 1, 1); + 1, 1, 1, 0, 10, 0, 1, 1, 0, 0); fprintf(stdout, "Output on stdout after grandchild test.\n"); fprintf(stderr, "Output on stderr after grandchild test.\n"); fflush(stdout); @@ -217,18 +231,137 @@ static int test8_grandchild(int argc, const char* argv[]) implemented. */ fclose(stdout); fclose(stderr); + testProcess_sleep(15); + return 0; +} + +static int test9(int argc, const char* argv[]) +{ + /* Test Ctrl+C behavior: the root test program will send a Ctrl+C to this + process. Here, we start a child process that sleeps for a long time + while ignoring signals. The test is successful if this process waits + for the child to return before exiting from the Ctrl+C handler. + + WARNING: This test will falsely pass if the share parameter of runChild + was set to 0 when invoking the test9 process. */ + int r; + const char* cmd[4]; + (void)argc; + cmd[0] = argv[0]; + cmd[1] = "run"; + cmd[2] = "109"; + cmd[3] = 0; + fprintf(stdout, "Output on stdout before grandchild test.\n"); + fprintf(stderr, "Output on stderr before grandchild test.\n"); + fflush(stdout); + fflush(stderr); + r = runChild(cmd, kwsysProcess_State_Exited, + kwsysProcess_Exception_None, + 0, 1, 1, 0, 30, 0, 1, 0, 0, 0); + /* This sleep will avoid a race condition between this function exiting + normally and our Ctrl+C handler exiting abnormally after the process + exits. */ + testProcess_sleep(1); + fprintf(stdout, "Output on stdout after grandchild test.\n"); + fprintf(stderr, "Output on stderr after grandchild test.\n"); + fflush(stdout); + fflush(stderr); + return r; +} + #if defined(_WIN32) - Sleep(15000); +static BOOL WINAPI test9_grandchild_handler(DWORD dwCtrlType) +{ + /* Ignore all Ctrl+C/Break signals. We must use an actual handler function + instead of using SetConsoleCtrlHandler(NULL, TRUE) so that we can also + ignore Ctrl+Break in addition to Ctrl+C. */ + (void)dwCtrlType; + return TRUE; +} +#endif + +static int test9_grandchild(int argc, const char* argv[]) +{ + /* The grandchild just sleeps for a few seconds while ignoring signals. */ + (void)argc; (void)argv; +#if defined(_WIN32) + if(!SetConsoleCtrlHandler(test9_grandchild_handler, TRUE)) + { + return 1; + } #else - sleep(15); + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_IGN; + sigemptyset(&sa.sa_mask); + if(sigaction(SIGINT, &sa, 0) < 0) + { + return 1; + } #endif + fprintf(stdout, "Output on stdout from grandchild before sleep.\n"); + fprintf(stderr, "Output on stderr from grandchild before sleep.\n"); + fflush(stdout); + fflush(stderr); + /* Sleep for 9 seconds. */ + testProcess_sleep(9); + fprintf(stdout, "Output on stdout from grandchild after sleep.\n"); + fprintf(stderr, "Output on stderr from grandchild after sleep.\n"); + fflush(stdout); + fflush(stderr); + return 0; +} + +static int test10(int argc, const char* argv[]) +{ + /* Test Ctrl+C behavior: the root test program will send a Ctrl+C to this + process. Here, we start a child process that sleeps for a long time and + processes signals normally. However, this grandchild is created in a new + process group - ensuring that Ctrl+C we receive is sent to our process + groups. We make sure it exits anyway. */ + int r; + const char* cmd[4]; + (void)argc; + cmd[0] = argv[0]; + cmd[1] = "run"; + cmd[2] = "110"; + cmd[3] = 0; + fprintf(stdout, "Output on stdout before grandchild test.\n"); + fprintf(stderr, "Output on stderr before grandchild test.\n"); + fflush(stdout); + fflush(stderr); + r = runChild(cmd, kwsysProcess_State_Exception, + kwsysProcess_Exception_Interrupt, + 0, 1, 1, 0, 30, 0, 1, 0, 1, 0); + fprintf(stdout, "Output on stdout after grandchild test.\n"); + fprintf(stderr, "Output on stderr after grandchild test.\n"); + fflush(stdout); + fflush(stderr); + return r; +} + +static int test10_grandchild(int argc, const char* argv[]) +{ + /* The grandchild just sleeps for a few seconds and handles signals. */ + (void)argc; (void)argv; + fprintf(stdout, "Output on stdout from grandchild before sleep.\n"); + fprintf(stderr, "Output on stderr from grandchild before sleep.\n"); + fflush(stdout); + fflush(stderr); + /* Sleep for 6 seconds. */ + testProcess_sleep(6); + fprintf(stdout, "Output on stdout from grandchild after sleep.\n"); + fprintf(stderr, "Output on stderr from grandchild after sleep.\n"); + fflush(stdout); + fflush(stderr); return 0; } 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) + int poll, int disown, int createNewGroup, + unsigned int interruptDelay) { int result = 0; char* data = 0; @@ -249,6 +382,10 @@ static int runChild2(kwsysProcess* kp, { kwsysProcess_SetOption(kp, kwsysProcess_Option_Detach, 1); } + if(createNewGroup) + { + kwsysProcess_SetOption(kp, kwsysProcess_Option_CreateProcessGroup, 1); + } kwsysProcess_Execute(kp); if(poll) @@ -256,6 +393,12 @@ static int runChild2(kwsysProcess* kp, pUserTimeout = &userTimeout; } + if(interruptDelay) + { + testProcess_sleep(interruptDelay); + kwsysProcess_Interrupt(kp); + } + if(!share && !disown) { int p; @@ -286,17 +429,13 @@ static int runChild2(kwsysProcess* kp, if(poll) { /* Delay to avoid busy loop during polling. */ -#if defined(_WIN32) - Sleep(100); -#else testProcess_usleep(100000); -#endif } if(delay) { /* Purposely sleeping only on Win32 to let pipe fill up. */ #if defined(_WIN32) - Sleep(100); + testProcess_usleep(100000); #endif } } @@ -337,7 +476,7 @@ static int runChild2(kwsysProcess* kp, printf("Error in administrating child process: [%s]\n", kwsysProcess_GetErrorString(kp)); break; }; - + if(result) { if(exception != kwsysProcess_GetExitException(kp)) @@ -353,7 +492,7 @@ static int runChild2(kwsysProcess* kp, value, kwsysProcess_GetExitValue(kp)); } } - + if(kwsysProcess_GetState(kp) != state) { fprintf(stderr, "Mismatch in state. " @@ -374,9 +513,37 @@ static int runChild2(kwsysProcess* kp, return result; } +/** + * Runs a child process and blocks until it returns. Arguments as follows: + * + * cmd = Command line to run. + * state = Expected return value of kwsysProcess_GetState after exit. + * exception = Expected return value of kwsysProcess_GetExitException. + * value = Expected return value of kwsysProcess_GetExitValue. + * share = Whether to share stdout/stderr child pipes with our pipes + * by way of kwsysProcess_SetPipeShared. If false, new pipes + * are created. + * output = If !share && !disown, whether to write the child's stdout + * and stderr output to our stdout. + * delay = If !share && !disown, adds an additional short delay to + * the pipe loop to allow the pipes to fill up; Windows only. + * timeout = Non-zero to sets a timeout in seconds via + * kwsysProcess_SetTimeout. + * poll = If !share && !disown, we count the number of 0.1 second + * intervals where the child pipes had no new data. We fail + * if not in the bounds of MINPOLL/MAXPOLL. + * repeat = Number of times to run the process. + * disown = If set, the process is disowned. + * createNewGroup = If set, the process is created in a new process group. + * interruptDelay = If non-zero, number of seconds to delay before + * interrupting the process. Note that this delay will occur + * BEFORE any reading/polling of pipes occurs and before any + * detachment occurs. + */ 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 poll, int repeat, int disown, int createNewGroup, + unsigned int interruptDelay) { int result = 1; kwsysProcess* kp = kwsysProcess_New(); @@ -388,7 +555,8 @@ int runChild(const char* cmd[], int state, int exception, int value, while(repeat-- > 0) { result = runChild2(kp, cmd, state, exception, value, share, - output, delay, timeout, poll, disown); + output, delay, timeout, poll, disown, createNewGroup, + interruptDelay); } kwsysProcess_Delete(kp); return result; @@ -435,7 +603,7 @@ int main(int argc, const char* argv[]) n = atoi(argv[2]); } /* Check arguments. */ - if(((n >= 1 && n <= 8) || n == 108) && argc == 3) + if(((n >= 1 && n <= 10) || n == 108 || n == 109 || n == 110) && argc == 3) { /* This is the child process for a requested test number. */ switch (n) @@ -448,15 +616,19 @@ int main(int argc, const char* argv[]) case 6: test6(argc, argv); return 0; case 7: return test7(argc, argv); case 8: return test8(argc, argv); + case 9: return test9(argc, argv); + case 10: return test10(argc, argv); case 108: return test8_grandchild(argc, argv); + case 109: return test9_grandchild(argc, argv); + case 110: return test10_grandchild(argc, argv); } fprintf(stderr, "Invalid test number %d.\n", n); return 1; } - else if(n >= 1 && n <= 8) + else if(n >= 1 && n <= 10) { /* This is the parent process for a requested test number. */ - int states[8] = + int states[10] = { kwsysProcess_State_Exited, kwsysProcess_State_Exited, @@ -465,9 +637,11 @@ int main(int argc, const char* argv[]) kwsysProcess_State_Exited, kwsysProcess_State_Expired, kwsysProcess_State_Exited, - kwsysProcess_State_Exited + kwsysProcess_State_Exited, + kwsysProcess_State_Expired, /* Ctrl+C handler test */ + kwsysProcess_State_Exception /* Process group test */ }; - int exceptions[8] = + int exceptions[10] = { kwsysProcess_Exception_None, kwsysProcess_Exception_None, @@ -476,14 +650,19 @@ int main(int argc, const char* argv[]) kwsysProcess_Exception_None, kwsysProcess_Exception_None, kwsysProcess_Exception_None, - kwsysProcess_Exception_None + kwsysProcess_Exception_None, + kwsysProcess_Exception_None, + kwsysProcess_Exception_Interrupt }; - int values[8] = {0, 123, 1, 1, 0, 0, 0, 0}; - int outputs[8] = {1, 1, 1, 1, 1, 0, 1, 1}; - int delays[8] = {0, 0, 0, 0, 0, 1, 0, 0}; - double timeouts[8] = {10, 10, 10, 30, 30, 10, -1, 10}; - int polls[8] = {0, 0, 0, 0, 0, 0, 1, 0}; - int repeat[8] = {2, 1, 1, 1, 1, 1, 1, 1}; + int values[10] = {0, 123, 1, 1, 0, 0, 0, 0, 1, 1}; + int shares[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; + int outputs[10] = {1, 1, 1, 1, 1, 0, 1, 1, 1, 1}; + int delays[10] = {0, 0, 0, 0, 0, 1, 0, 0, 0, 0}; + double timeouts[10] = {10, 10, 10, 30, 30, 10, -1, 10, 6, 4}; + int polls[10] = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0}; + int repeat[10] = {2, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + int createNewGroups[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; + unsigned int interruptDelays[10] = {0, 0, 0, 0, 0, 0, 0, 0, 3, 2}; int r; const char* cmd[4]; #ifdef _WIN32 @@ -515,9 +694,10 @@ int main(int argc, const char* argv[]) fprintf(stderr, "Output on stderr before test %d.\n", n); fflush(stdout); fflush(stderr); - r = runChild(cmd, states[n-1], exceptions[n-1], values[n-1], 0, + r = runChild(cmd, states[n-1], exceptions[n-1], values[n-1], shares[n-1], outputs[n-1], delays[n-1], timeouts[n-1], - polls[n-1], repeat[n-1], 0); + polls[n-1], repeat[n-1], 0, createNewGroups[n-1], + interruptDelays[n-1]); fprintf(stdout, "Output on stdout after test %d.\n", n); fprintf(stderr, "Output on stderr after test %d.\n", n); fflush(stdout); @@ -536,7 +716,8 @@ int main(int argc, const char* argv[]) int exception = kwsysProcess_Exception_None; int value = 0; double timeout = 0; - int r = runChild(cmd, state, exception, value, 0, 1, 0, timeout, 0, 1, 0); + int r = runChild(cmd, state, exception, value, 0, 1, 0, timeout, + 0, 1, 0, 0, 0); return r; } else -- cgit v0.12 From 129640f279259e51fbb0e81a5bec2ec2dfac543e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 23 Jul 2015 09:22:25 -0400 Subject: CTestCustom: Ignore kwsys.testProcess-10 for MemCheck as KWSys does The test covers exceptional behavior that leaks memory, so ignore it for dynamic analysis runs. --- CTestCustom.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 7f20d10..f29ac70 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -109,3 +109,7 @@ set(CTEST_CUSTOM_COVERAGE_EXCLUDE # Exclude Qt source files from coverage results: "[A-Za-z]./[Qq]t/qt-.+-opensource-src" ) + +list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE + kwsys.testProcess-10 # See Source/kwsys/CTestCustom.cmake.in + ) -- cgit v0.12 From da98b89612d59906bd938d58a9072b3ce68864de Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 23 Jul 2015 09:47:03 -0400 Subject: Tests: In CTestTest2 skip the kwsys.testProcess-10 test that leaks This test intentionally leaks memory so KWSys excludes it from MemCheck. However, when CTestTest2 runs under our own MemCheck then valgrind may recursively check tests run by ctest_test() calls in our test.cmake script. Teach these calls to exluce testProcess-10 too. Also read the KWSys CTestCustom.cmake file so ctest_memcheck() will ignore the test too. --- Tests/CTestTest2/test.cmake.in | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in index 852bb6b..825b957 100644 --- a/Tests/CTestTest2/test.cmake.in +++ b/Tests/CTestTest2/test.cmake.in @@ -39,14 +39,19 @@ CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ CTEST_TEST_KWSYS:BOOL=ON ") +set(test_exclude + kwsys.testProcess-10 + ) + CTEST_START(Experimental) #CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_READ_CUSTOM_FILES(${CTEST_BINARY_DIRECTORY}) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 1 END 5 STRIDE 2) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 7 STRIDE 2 SUBMIT_INDEX 1) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 2 END 4 STRIDE 2 SUBMIT_INDEX 2) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 6 STRIDE 2 SUBMIT_INDEX 3) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res EXCLUDE ${test_exclude} START 1 END 5 STRIDE 2) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res EXCLUDE ${test_exclude} START 7 STRIDE 2 SUBMIT_INDEX 1) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res EXCLUDE ${test_exclude} START 2 END 4 STRIDE 2 SUBMIT_INDEX 2) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res EXCLUDE ${test_exclude} START 6 STRIDE 2 SUBMIT_INDEX 3) CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res STRIDE 1.5) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -- cgit v0.12 From 1c46b6aed0db88c97189713f291164f98df780a9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 31 Jul 2015 09:42:25 -0400 Subject: FindMPI: Drop unnecessary and incorrect use of GetPrerequisites Since commit v2.8.5~121^2~2 (FindMPI: Handle multiple languages, 2010-12-29) we called the GetPrerequisites is_file_executable function but passed the name of a CMake variable instead of its value. Therefore the function has always failed and caused the search for the compiler name to run even with an absolute path. Switch to using if(IS_ABSOLUTE) instead and drop use of GetPrerequisites. --- Modules/FindMPI.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 06ecfaa..48adf3c 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -102,7 +102,6 @@ # include this to handle the QUIETLY and REQUIRED arguments include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/GetPrerequisites.cmake) # # This part detects MPI compilers, attempting to wade through the mess of compiler names in @@ -578,14 +577,13 @@ foreach (lang C CXX Fortran) if (CMAKE_${lang}_COMPILER_WORKS) # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. if (MPI_${lang}_COMPILER) - is_file_executable(MPI_${lang}_COMPILER MPI_COMPILER_IS_EXECUTABLE) - if (NOT MPI_COMPILER_IS_EXECUTABLE) + if (NOT IS_ABSOLUTE "${MPI_${lang}_COMPILER}") # Get rid of our default list of names and just search for the name the user wants. set(_MPI_${lang}_COMPILER_NAMES ${MPI_${lang}_COMPILER}) set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - # If the user specifies a compiler, we don't want to try to search libraries either. - set(try_libs FALSE) endif() + # If the user specifies a compiler, we don't want to try to search libraries either. + set(try_libs FALSE) else() set(try_libs TRUE) endif() -- cgit v0.12 From afb674ab46a7d6ff3d1801315f3d852bdba79d0c Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 29 Jul 2015 17:05:51 +0100 Subject: GetPrerequisites: Add error checks for execute_process() calls Add return status checks to external command invocations so that they do not fail silently producing incomplete install packages. --- Modules/GetPrerequisites.cmake | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 23d486e..a359d2c 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -229,9 +229,14 @@ function(is_file_executable file result_var) if(file_cmd) execute_process(COMMAND "${file_cmd}" "${file_full}" + RESULT_VARIABLE file_rv OUTPUT_VARIABLE file_ov + ERROR_VARIABLE file_ev OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT file_rv STREQUAL "0") + message(FATAL_ERROR "${file_cmd} failed: ${file_rv}\n${file_ev}") + endif() # Replace the name of the file in the output with a placeholder token # (the string " _file_full_ ") so that just in case the path name of @@ -543,11 +548,21 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(CYGPATH_EXECUTABLE) execute_process(COMMAND ${CYGPATH_EXECUTABLE} -W + RESULT_VARIABLE env_rv OUTPUT_VARIABLE env_windir + ERROR_VARIABLE env_ev OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT env_rv STREQUAL "0") + message(FATAL_ERROR "${CYGPATH_EXECUTABLE} -W failed: ${env_rv}\n${env_ev}") + endif() execute_process(COMMAND ${CYGPATH_EXECUTABLE} -S + RESULT_VARIABLE env_rv OUTPUT_VARIABLE env_sysdir + ERROR_VARIABLE env_ev OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT env_rv STREQUAL "0") + message(FATAL_ERROR "${CYGPATH_EXECUTABLE} -S failed: ${env_rv}\n${env_ev}") + endif() string(TOLOWER "${env_windir}" windir) string(TOLOWER "${env_sysdir}" sysroot) @@ -765,8 +780,18 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # execute_process( COMMAND ${gp_cmd} ${gp_cmd_args} ${target} + RESULT_VARIABLE gp_rv OUTPUT_VARIABLE gp_cmd_ov + ERROR_VARIABLE gp_ev ) + if(NOT gp_rv STREQUAL "0") + if(gp_tool STREQUAL "dumpbin") + # dumpbin error messages seem to go to stdout + message(FATAL_ERROR "${gp_cmd} failed: ${gp_rv}\n${gp_ev}\n${gp_cmd_ov}") + else() + message(FATAL_ERROR "${gp_cmd} failed: ${gp_rv}\n${gp_ev}") + endif() + endif() if(gp_tool STREQUAL "ldd") set(ENV{LD_LIBRARY_PATH} "${old_ld_env}") @@ -791,8 +816,13 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if(gp_tool STREQUAL "otool") execute_process( COMMAND otool -D ${target} + RESULT_VARIABLE otool_rv OUTPUT_VARIABLE gp_install_id_ov + ERROR_VARIABLE otool_ev ) + if(NOT otool_rv STREQUAL "0") + message(FATAL_ERROR "otool -D failed: ${otool_rv}\n${otool_ev}") + endif() # second line is install name string(REGEX REPLACE ".*:\n" "" gp_install_id "${gp_install_id_ov}") if(gp_install_id) -- cgit v0.12 From 5d0a8b1abc3f8a6d8d23772251b4ef2758d2def6 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 29 Jul 2015 17:36:38 +0100 Subject: GetPrerequisites: Optionally filter "objdump" output for speed As dumpbin.exe is no longer reliable for gcc libraries on MinGW because it crashes on many common libraries like libgcc_s and libgfortran it is now necessary too resort to using objdump for DLL dependency walking. Using objdump has a secondary problem in that it generates a lot of output for large libraries and causes fixup_bundle() to take many minutes to process what took fractions of a second with "dumpbin.exe /dependents". Add a 'grep' pre-filter in the execute_process() command pipeline to reduce this output to a minimum for a several orders of magnitude speed up. If grep is not available just use the full output. As there does not seem to be a reliable way of detecting MinGW, callers of fixup_bundle() may have to set the variable gp_tool to "objdump" if dumpbin.exe is installed on the build machine to stop it using the broken MS dumpbin.exe for library dependency walking. --- Modules/GetPrerequisites.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index a359d2c..e4018b6 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -700,6 +700,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa return() endif() + set(gp_cmd_maybe_filter) # optional command to pre-filter gp_tool results + if(gp_tool STREQUAL "ldd") set(gp_cmd_args "") set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$") @@ -724,6 +726,11 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa set(gp_regex_error "") set(gp_regex_fallback "") set(gp_regex_cmp_count 1) + # objdump generaates copious output so we create a grep filter to pre-filter results + find_program(gp_grep_cmd grep) + if(gp_grep_cmd) + set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "^[[:blank:]]*DLL Name: ") + endif() else() message(STATUS "warning: gp_tool='${gp_tool}' is an unknown tool...") message(STATUS "CMake function get_prerequisites needs more code to handle '${gp_tool}'") @@ -780,6 +787,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # execute_process( COMMAND ${gp_cmd} ${gp_cmd_args} ${target} + ${gp_cmd_maybe_filter} RESULT_VARIABLE gp_rv OUTPUT_VARIABLE gp_cmd_ov ERROR_VARIABLE gp_ev -- cgit v0.12 From 9432b14e916421a727265f9a05dc1fbe6c6ec381 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 1 Aug 2015 00:01:06 -0400 Subject: 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 34779a5..5d53072 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150731) +set(CMake_VERSION_PATCH 20150801) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f0005bb484bc2b85a169ef7816e33d8e2f16e109 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Aug 2015 07:16:40 +0200 Subject: Tests: Verify generate-time policy scope behavior. If some day there are no policies checked through the makefile at generate time, this can be fixed. --- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/PolicyScope/CMakeLists.txt | 3 +++ Tests/RunCMake/PolicyScope/RunCMakeTest.cmake | 4 ++++ Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt | 1 + Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt | 5 +++++ Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake | 2 ++ Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake | 6 ++++++ Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt | 5 +++++ Tests/RunCMake/PolicyScope/dir1/foo.cpp | 5 +++++ Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt | 1 + Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake | 7 +++++++ 11 files changed, 40 insertions(+) create mode 100644 Tests/RunCMake/PolicyScope/CMakeLists.txt create mode 100644 Tests/RunCMake/PolicyScope/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake create mode 100644 Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt create mode 100644 Tests/RunCMake/PolicyScope/dir1/foo.cpp create mode 100644 Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt create mode 100644 Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 607e799..c4579d7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -145,6 +145,7 @@ add_RunCMake_test(TargetSources) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) +add_RunCMake_test(PolicyScope) add_RunCMake_test(WriteCompilerDetectionHeader) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) diff --git a/Tests/RunCMake/PolicyScope/CMakeLists.txt b/Tests/RunCMake/PolicyScope/CMakeLists.txt new file mode 100644 index 0000000..667561e --- /dev/null +++ b/Tests/RunCMake/PolicyScope/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake b/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake new file mode 100644 index 0000000..d6c021f --- /dev/null +++ b/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(parent-dir-generate-time) +run_cmake(dir-in-macro-generate-time) diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt new file mode 100644 index 0000000..d223f42 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) at dir1/CMakeLists.txt:5 \(target_compile_definitions\): + Policy CMP0044 is not set: Case sensitive _COMPILER_ID generator + expressions. Run "cmake --help-policy CMP0044" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake new file mode 100644 index 0000000..04a7c2c --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake @@ -0,0 +1,2 @@ + +include(dir-in-macro-include.cmake) diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake b/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake new file mode 100644 index 0000000..fd326f1 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake @@ -0,0 +1,6 @@ + +enable_language(CXX) + +# This does not affect dir1 despite being set before the add_subdirectory. +cmake_policy(SET CMP0044 NEW) +add_subdirectory(dir1) diff --git a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt new file mode 100644 index 0000000..16bcb36 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt @@ -0,0 +1,5 @@ + + +add_library(foo STATIC foo.cpp) +string(TOLOWER ${CMAKE_CXX_COMPILER_ID} compiler_id) +target_compile_definitions(foo PRIVATE Foo=$) diff --git a/Tests/RunCMake/PolicyScope/dir1/foo.cpp b/Tests/RunCMake/PolicyScope/dir1/foo.cpp new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/dir1/foo.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt b/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake b/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake new file mode 100644 index 0000000..a0842f7 --- /dev/null +++ b/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake @@ -0,0 +1,7 @@ + +enable_language(CXX) + +add_subdirectory(dir1) + +# This affects dir1 despite being set after the add_subdirectory. +cmake_policy(SET CMP0044 NEW) -- cgit v0.12 From 0a01e6c6e7bd428ca0ec99a00924b5b498c6e637 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Jul 2015 12:54:16 +0200 Subject: cmState: Add Snapshot Type accessor. --- Source/cmState.cxx | 5 +++++ Source/cmState.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d8f8306..a466471 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -847,6 +847,11 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position) } +cmState::SnapshotType cmState::Snapshot::GetType() const +{ + return this->Position->SnapshotType; +} + const char* cmState::Directory::GetCurrentSource() const { return this->DirectoryState->Location.c_str(); diff --git a/Source/cmState.h b/Source/cmState.h index 0d5300f..23fbc79 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -56,6 +56,7 @@ public: bool IsValid() const; Snapshot GetBuildsystemDirectoryParent() const; Snapshot GetCallStackParent() const; + SnapshotType GetType() const; void InitializeFromParent(); -- cgit v0.12 From a5fc17b5098ee27fd7ae457ca6c5743bacc384a7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Jul 2015 16:16:43 +0200 Subject: cmMakefile: Re-order policy entries and barriers. Make the barriers surround the entries. --- Source/cmMakefile.cxx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bdc9d5..16404cd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -189,12 +189,12 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); - // Enter a policy level for this directory. - this->PushPolicy(); - // Protect the directory-level policies. this->PushPolicyBarrier(); + // Enter a policy level for this directory. + this->PushPolicy(); + // push empty loop block this->PushLoopBlockBarrier(); @@ -468,6 +468,7 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, Makefile(mf), NoPolicyScope(noPolicyScope), CheckCMP0011(false), ReportError(true) { + this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -497,8 +498,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, } } - // The included file cannot pop our policy scope. - this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); this->Makefile->StateSnapshot = @@ -518,7 +517,6 @@ cmMakefile::IncludeScope::~IncludeScope() this->Makefile->PopFunctionBlockerBarrier(this->ReportError); // Enforce matching policy scopes inside the included file. - this->Makefile->PopPolicyBarrier(this->ReportError); if(!this->NoPolicyScope) { @@ -541,6 +539,7 @@ cmMakefile::IncludeScope::~IncludeScope() this->EnforceCMP0011(); } } + this->Makefile->PopPolicyBarrier(this->ReportError); } //---------------------------------------------------------------------------- @@ -1640,14 +1639,14 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); - this->PushPolicy(true, pm); this->PushPolicyBarrier(); + this->PushPolicy(true, pm); } void cmMakefile::PopFunctionScope(bool reportError) { - this->PopPolicyBarrier(reportError); this->PopPolicy(); + this->PopPolicyBarrier(reportError); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -1677,14 +1676,14 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); - this->PushPolicy(true, pm); this->PushPolicyBarrier(); + this->PushPolicy(true, pm); } void cmMakefile::PopMacroScope(bool reportError) { - this->PopPolicyBarrier(reportError); this->PopPolicy(); + this->PopPolicyBarrier(reportError); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -4843,15 +4842,15 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, cmPolicies::PolicyMap const& pm): Makefile(m), ReportError(true) { - this->Makefile->PushPolicy(weak, pm); this->Makefile->PushPolicyBarrier(); + this->Makefile->PushPolicy(weak, pm); } //---------------------------------------------------------------------------- cmMakefile::PolicyPushPop::~PolicyPushPop() { - this->Makefile->PopPolicyBarrier(this->ReportError); this->Makefile->PopPolicy(); + this->Makefile->PopPolicyBarrier(this->ReportError); } //---------------------------------------------------------------------------- -- cgit v0.12 From 6ae8b30bf4127011284a66541ed2116fcb45f007 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Jul 2015 08:09:49 +0200 Subject: cmMakefile: Move policy barriers inside cmState scopes. --- Source/cmMakefile.cxx | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 16404cd..2c854dd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -468,6 +468,14 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, Makefile(mf), NoPolicyScope(noPolicyScope), CheckCMP0011(false), ReportError(true) { + this->Makefile->PushFunctionBlockerBarrier(); + + this->Makefile->StateSnapshot = + this->Makefile->GetState()->CreateCallStackSnapshot( + this->Makefile->StateSnapshot, + this->Makefile->ContextStack.back()->Name, + this->Makefile->ContextStack.back()->Line, + filenametoread); this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { @@ -497,27 +505,11 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, break; } } - - this->Makefile->PushFunctionBlockerBarrier(); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->CreateCallStackSnapshot( - this->Makefile->StateSnapshot, - this->Makefile->ContextStack.back()->Name, - this->Makefile->ContextStack.back()->Line, - filenametoread); } //---------------------------------------------------------------------------- cmMakefile::IncludeScope::~IncludeScope() { - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); - // Enforce matching policy scopes inside the included file. - if(!this->NoPolicyScope) { // If we need to enforce policy CMP0011 then the top entry is the @@ -540,6 +532,11 @@ cmMakefile::IncludeScope::~IncludeScope() } } this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = + this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); + assert(this->Makefile->StateSnapshot.IsValid()); + + this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } //---------------------------------------------------------------------------- @@ -634,8 +631,6 @@ public: ListFileScope(cmMakefile* mf, std::string const& filenametoread) : Makefile(mf), ReportError(true) { - this->Makefile->PushPolicyBarrier(); - long line = 0; std::string name; if (!this->Makefile->ContextStack.empty()) @@ -647,17 +642,21 @@ public: this->Makefile->GetState()->CreateInlineListFileSnapshot( this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); + + this->Makefile->PushPolicyBarrier(); + this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { + this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PopFunctionBlockerBarrier(this->ReportError); - this->Makefile->PopPolicyBarrier(this->ReportError); } void Quiet() { this->ReportError = false; } @@ -1628,6 +1627,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); + this->PushPolicyBarrier(); this->Internal->PushDefinitions(); @@ -1639,15 +1639,14 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); - this->PushPolicyBarrier(); this->PushPolicy(true, pm); } void cmMakefile::PopFunctionScope(bool reportError) { this->PopPolicy(); - this->PopPolicyBarrier(reportError); + this->PopPolicyBarrier(reportError); this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); assert(this->StateSnapshot.IsValid()); @@ -1673,10 +1672,10 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); + this->PushPolicyBarrier(); this->PushFunctionBlockerBarrier(); - this->PushPolicyBarrier(); this->PushPolicy(true, pm); } -- cgit v0.12 From af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Aug 2015 07:29:36 +0200 Subject: cmState: Remove call stack parent tracking. This was added at a time when I thought the cmState would report errors, but that is not the direction it is going. The ordering of the stack of scopes is canonical and clients are required to maintain it. --- Source/cmState.cxx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a466471..a7df040 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,7 +20,6 @@ struct cmState::SnapshotDataType { - cmState::PositionType CallStackParent; cmState::PositionType DirectoryParent; cmState::SnapshotType SnapshotType; cmLinkedTree::iterator ExecutionListFile; @@ -732,7 +731,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Extend(originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; @@ -754,7 +752,6 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; @@ -772,7 +769,6 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = MacroCallType; @@ -789,7 +785,6 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = CallStackType; @@ -806,7 +801,6 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = InlineListFileType; @@ -827,11 +821,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); - if (prevPos == this->SnapshotData.Root()) - { - return Snapshot(this, prevPos); - } - return Snapshot(this, originSnapshot.Position->CallStackParent); + return Snapshot(this, prevPos); } cmState::Snapshot::Snapshot(cmState* state) -- cgit v0.12 From 6c0e9ee276e9e35a970990baec09c0c2c85b3804 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Aug 2015 12:05:13 +0200 Subject: cmMakefile: Store EvaluationFiles. Relieve the cmGlobalGenerator of this responsibility. Evaluate the generator expressions in the context of the cmLocalGenerator. --- Source/cmFileCommand.cxx | 7 ++--- Source/cmGlobalGenerator.cxx | 56 +++++---------------------------------- Source/cmGlobalGenerator.h | 8 ------ Source/cmGlobalNinjaGenerator.cxx | 26 +++++++++--------- Source/cmLocalGenerator.cxx | 48 +++++++++++++++++++++++++++++++++ Source/cmLocalGenerator.h | 2 ++ Source/cmMakefile.cxx | 21 +++++++++++++++ Source/cmMakefile.h | 9 +++++++ 8 files changed, 100 insertions(+), 77 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 0daed66..87faf84 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3573,11 +3573,8 @@ void cmFileCommand::AddEvaluationFile(const std::string &inputName, cmsys::auto_ptr conditionCge = conditionGe.Parse(condition); - this->Makefile->GetGlobalGenerator()->AddEvaluationFile(inputName, - outputCge, - this->Makefile, - conditionCge, - inputIsContent); + this->Makefile->AddEvaluationFile(inputName, outputCge, + conditionCge, inputIsContent); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1d6608b..d6d36d4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -30,7 +30,6 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" -#include "cmGeneratorExpressionEvaluationFile.h" #include "cmExportBuildFileGenerator.h" #include "cmCPackPropertiesGenerator.h" #include "cmAlgorithms.h" @@ -1561,9 +1560,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); - cmDeleteAll(this->EvaluationFiles); - this->EvaluationFiles.clear(); - cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); @@ -3032,61 +3028,21 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const { void cmGlobalGenerator::CreateEvaluationSourceFiles( std::string const& config) const { - for(std::vector::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) { - (*li)->CreateOutputFile(config); + this->LocalGenerators[i]->CreateEvaluationFileOutputs(config); } } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile, - cmsys::auto_ptr outputExpr, - cmMakefile *makefile, - cmsys::auto_ptr condition, - bool inputIsContent) -{ - this->EvaluationFiles.push_back( - new cmGeneratorExpressionEvaluationFile(inputFile, outputExpr, - makefile, condition, - inputIsContent)); -} - -//---------------------------------------------------------------------------- void cmGlobalGenerator::ProcessEvaluationFiles() { std::vector generatedFiles; - for(std::vector::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) { - (*li)->Generate(); - if (cmSystemTools::GetFatalErrorOccured()) - { - return; - } - std::vector files = (*li)->GetFiles(); - std::sort(files.begin(), files.end()); - - std::vector intersection; - std::set_intersection(files.begin(), files.end(), - generatedFiles.begin(), generatedFiles.end(), - std::back_inserter(intersection)); - if (!intersection.empty()) - { - cmSystemTools::Error("Files to be generated by multiple different " - "commands: ", cmWrap('"', intersection, '"', " ").c_str()); - return; - } - - generatedFiles.insert(generatedFiles.end(), - files.begin(), files.end()); - std::vector::iterator newIt = - generatedFiles.end() - files.size(); - std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + this->LocalGenerators[i]->ProcessEvaluationFiles(generatedFiles); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3402fbc 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -34,7 +34,6 @@ class cmake; class cmGeneratorTarget; -class cmGeneratorExpressionEvaluationFile; class cmMakefile; class cmLocalGenerator; class cmExternalMakefileProjectGenerator; @@ -334,12 +333,6 @@ public: static std::string EscapeJSON(const std::string& s); - void AddEvaluationFile(const std::string &inputFile, - cmsys::auto_ptr outputName, - cmMakefile *makefile, - cmsys::auto_ptr condition, - bool inputIsContent); - void ProcessEvaluationFiles(); std::map& GetBuildExportSets() @@ -436,7 +429,6 @@ protected: TargetMap TotalTargets; TargetMap AliasTargets; TargetMap ImportedTargets; - std::vector EvaluationFiles; const char* GetPredefinedTargetsFolder(); virtual bool UseFolderProperty(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d24cce8..cc7f78b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1055,23 +1055,21 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) { knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); } - } - knownDependencies.insert( "CMakeCache.txt" ); - - for(std::vector::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) - { - //get all the files created by generator expressions and convert them - //to ninja paths - std::vector files = (*li)->GetFiles(); - typedef std::vector::const_iterator vect_it; - for(vect_it j = files.begin(); j != files.end(); ++j) + std::vector const& ef = + (*i)->GetMakefile()->GetEvaluationFiles(); + for(std::vector::const_iterator + li = ef.begin(); li != ef.end(); ++li) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + //get all the files created by generator expressions and convert them + //to ninja paths + std::vector evaluationFiles = (*li)->GetFiles(); + for(vect_it j = evaluationFiles.begin(); j != evaluationFiles.end(); ++j) + { + knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + } } } + knownDependencies.insert( "CMakeCache.txt" ); for(TargetAliasMap::const_iterator i= this->TargetAliases.begin(); i != this->TargetAliases.end(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..7cc256a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalGenerator.h" #include "cmInstallGenerator.h" #include "cmInstallFilesGenerator.h" +#include "cmGeneratorExpressionEvaluationFile.h" #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmMakefile.h" @@ -212,6 +213,53 @@ void cmLocalGenerator::GenerateTestFiles() } } +void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) +{ + std::vector ef = + this->Makefile->GetEvaluationFiles(); + for(std::vector::const_iterator + li = ef.begin(); li != ef.end(); ++li) + { + (*li)->CreateOutputFile(config); + } +} + +void cmLocalGenerator::ProcessEvaluationFiles( + std::vector& generatedFiles) +{ + std::vector ef = + this->Makefile->GetEvaluationFiles(); + for(std::vector::const_iterator + li = ef.begin(); + li != ef.end(); + ++li) + { + (*li)->Generate(); + if (cmSystemTools::GetFatalErrorOccured()) + { + return; + } + std::vector files = (*li)->GetFiles(); + std::sort(files.begin(), files.end()); + + std::vector intersection; + std::set_intersection(files.begin(), files.end(), + generatedFiles.begin(), generatedFiles.end(), + std::back_inserter(intersection)); + if (!intersection.empty()) + { + cmSystemTools::Error("Files to be generated by multiple different " + "commands: ", cmWrap('"', intersection, '"', " ").c_str()); + return; + } + + generatedFiles.insert(generatedFiles.end(), files.begin(), files.end()); + std::vector::iterator newIt = + generatedFiles.end() - files.size(); + std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + } +} + //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateInstallRules() { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2971574..1c18788 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -305,6 +305,8 @@ public: void IssueMessage(cmake::MessageType t, std::string const& text) const; + void CreateEvaluationFileOutputs(const std::string& config); + void ProcessEvaluationFiles(std::vector& generatedFiles); void ComputeObjectMaxPath(); protected: diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bdc9d5..1407888 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -21,6 +21,7 @@ #include "cmState.h" #include "cmOutputConverter.h" #include "cmFunctionBlocker.h" +#include "cmGeneratorExpressionEvaluationFile.h" #include "cmListFileCache.h" #include "cmCommandArgumentParserHelper.h" #include "cmGeneratorExpression.h" @@ -235,6 +236,9 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->ImportedTargetsOwned); cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); + cmDeleteAll(this->EvaluationFiles); + this->EvaluationFiles.clear(); + this->FunctionBlockers.clear(); if (this->PolicyStack.size() != 1) { @@ -777,6 +781,23 @@ void cmMakefile::EnforceDirectoryLevelRules() const } } +void cmMakefile::AddEvaluationFile(const std::string& inputFile, + cmsys::auto_ptr outputName, + cmsys::auto_ptr condition, + bool inputIsContent) +{ + this->EvaluationFiles.push_back( + new cmGeneratorExpressionEvaluationFile(inputFile, outputName, + this, condition, + inputIsContent)); +} + +std::vector +cmMakefile::GetEvaluationFiles() const +{ + return this->EvaluationFiles; +} + namespace { struct file_not_persistent diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..c16ab3d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -52,6 +52,7 @@ class cmVariableWatch; class cmake; class cmMakefileCall; class cmCMakePolicyCommand; +class cmGeneratorExpressionEvaluationFile; /** \class cmMakefile * \brief Process the input CMakeLists.txt file. @@ -799,6 +800,12 @@ public: void EnforceDirectoryLevelRules() const; + void AddEvaluationFile(const std::string &inputFile, + cmsys::auto_ptr outputName, + cmsys::auto_ptr condition, + bool inputIsContent); + std::vector GetEvaluationFiles() const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -895,6 +902,8 @@ private: std::vector UnConfiguredDirectories; + std::vector EvaluationFiles; + cmPropertyMap Properties; std::vector ContextStack; -- cgit v0.12 From 12c3f24827d2459154fcc9773b279f96c303e591 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Aug 2015 12:19:32 +0200 Subject: cmGeneratorExpressionEvaluationFile: Require generator context. Avoid storing a cmMakefile as a member, and evaluate in the context of a cmLocalGenerator instead. --- Source/cmGeneratorExpressionEvaluationFile.cxx | 40 ++++++++++++++------------ Source/cmGeneratorExpressionEvaluationFile.h | 15 +++++----- Source/cmLocalGenerator.cxx | 4 +-- Source/cmMakefile.cxx | 2 +- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 92ff314..e4d9f10 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -25,19 +25,18 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( const std::string &input, cmsys::auto_ptr outputFileExpr, - cmMakefile *makefile, cmsys::auto_ptr condition, bool inputIsContent) : Input(input), OutputFileExpr(outputFileExpr), - Makefile(makefile), Condition(condition), InputIsContent(inputIsContent) { } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, + const std::string& config, const std::string& lang, cmCompiledGeneratorExpression* inputExpression, std::map &outputFiles, mode_t perm) @@ -45,7 +44,8 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) { - std::string condResult = this->Condition->Evaluate(this->Makefile, config, + std::string condResult = this->Condition->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, lang); if (condResult == "0") { @@ -56,16 +56,17 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, std::ostringstream e; e << "Evaluation file condition \"" << rawCondition << "\" did " "not evaluate to valid content. Got \"" << condResult << "\"."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } } const std::string outputFileName - = this->OutputFileExpr->Evaluate(this->Makefile, config, + = this->OutputFileExpr->Evaluate(lg->GetMakefile(), config, false, 0, 0, 0, lang); const std::string outputContent - = inputExpression->Evaluate(this->Makefile, config, + = inputExpression->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, lang); std::map::iterator it @@ -81,11 +82,11 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, e << "Evaluation file to be written multiple times for different " "configurations or languages with different content:\n " << outputFileName; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Makefile->AddCMakeOutputFile(outputFileName.c_str()); + lg->GetMakefile()->AddCMakeOutputFile(outputFileName.c_str()); this->Files.push_back(outputFileName); outputFiles[outputFileName] = outputContent; @@ -100,18 +101,19 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorExpressionEvaluationFile::CreateOutputFile( - std::string const& config) + cmLocalGenerator *lg, std::string const& config) { std::vector enabledLanguages; - cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator *gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); for(std::vector::const_iterator le = enabledLanguages.begin(); le != enabledLanguages.end(); ++le) { - std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config, + std::string name = this->OutputFileExpr->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, *le); - cmSourceFile* sf = this->Makefile->GetOrCreateSource(name); + cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name); sf->SetProperty("GENERATED", "1"); gg->SetFilenameTargetDepends(sf, @@ -120,7 +122,7 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate() +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg) { mode_t perm = 0; std::string inputContent; @@ -130,14 +132,14 @@ void cmGeneratorExpressionEvaluationFile::Generate() } else { - this->Makefile->AddCMakeDependFile(this->Input.c_str()); + lg->GetMakefile()->AddCMakeDependFile(this->Input.c_str()); cmSystemTools::GetPermissions(this->Input.c_str(), perm); cmsys::ifstream fin(this->Input.c_str()); if(!fin) { std::ostringstream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -159,7 +161,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() std::map outputFiles; std::vector allConfigs; - this->Makefile->GetConfigurations(allConfigs); + lg->GetMakefile()->GetConfigurations(allConfigs); if (allConfigs.empty()) { @@ -167,7 +169,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() } std::vector enabledLanguages; - cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator *gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); for(std::vector::const_iterator le = enabledLanguages.begin(); @@ -176,7 +178,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() for(std::vector::const_iterator li = allConfigs.begin(); li != allConfigs.end(); ++li) { - this->Generate(*li, *le, inputExpression.get(), outputFiles, perm); + this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm); if(cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 5d8b54c..ad41274 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -18,31 +18,32 @@ #include "cmGeneratorExpression.h" +class cmLocalGenerator; + //---------------------------------------------------------------------------- class cmGeneratorExpressionEvaluationFile { public: cmGeneratorExpressionEvaluationFile(const std::string &input, cmsys::auto_ptr outputFileExpr, - cmMakefile *makefile, cmsys::auto_ptr condition, bool inputIsContent); - void Generate(); + void Generate(cmLocalGenerator* lg); std::vector GetFiles() const { return this->Files; } - void CreateOutputFile(std::string const& config); + void CreateOutputFile(cmLocalGenerator* lg, std::string const& config); private: - void Generate(const std::string& config, const std::string& lang, - cmCompiledGeneratorExpression* inputExpression, - std::map &outputFiles, mode_t perm); + void Generate(cmLocalGenerator* lg, const std::string& config, + const std::string& lang, + cmCompiledGeneratorExpression* inputExpression, + std::map &outputFiles, mode_t perm); private: const std::string Input; const cmsys::auto_ptr OutputFileExpr; - cmMakefile *Makefile; const cmsys::auto_ptr Condition; std::vector Files; const bool InputIsContent; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7cc256a..ea0f658 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -220,7 +220,7 @@ void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) for(std::vector::const_iterator li = ef.begin(); li != ef.end(); ++li) { - (*li)->CreateOutputFile(config); + (*li)->CreateOutputFile(this, config); } } @@ -234,7 +234,7 @@ void cmLocalGenerator::ProcessEvaluationFiles( li != ef.end(); ++li) { - (*li)->Generate(); + (*li)->Generate(this); if (cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1407888..3e8abbc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -788,7 +788,7 @@ void cmMakefile::AddEvaluationFile(const std::string& inputFile, { this->EvaluationFiles.push_back( new cmGeneratorExpressionEvaluationFile(inputFile, outputName, - this, condition, + condition, inputIsContent)); } -- cgit v0.12 From 614786cc5c8cf6f504112a722aabf8dddc154d2c Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 2 Aug 2015 00:01:07 -0400 Subject: 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 5d53072..8c496cd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150801) +set(CMake_VERSION_PATCH 20150802) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 348354333a82ce98d733dc2ee939186c53c506f9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Jul 2015 12:56:10 +0200 Subject: cmState: Add Type for policy scope. --- Source/cmMakefile.cxx | 11 +++++++++++ Source/cmState.cxx | 22 ++++++++++++++++++++-- Source/cmState.h | 4 +++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2c854dd..9fb3d06 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -189,6 +189,9 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); + this->StateSnapshot = this->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->StateSnapshot); + // Protect the directory-level policies. this->PushPolicyBarrier(); @@ -1705,6 +1708,8 @@ public: this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource(); currentStart += "/CMakeLists.txt"; this->Makefile->StateSnapshot.SetListFile(currentStart); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); @@ -1722,6 +1727,8 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4841,6 +4848,8 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, cmPolicies::PolicyMap const& pm): Makefile(m), ReportError(true) { + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4850,6 +4859,8 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a7df040..09446bb 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -809,6 +809,15 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, return cmState::Snapshot(this, pos); } +cmState::Snapshot +cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->SnapshotType = PolicyScopeType; + return cmState::Snapshot(this, pos); +} + cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) { PositionType pos = originSnapshot.Position; @@ -959,13 +968,22 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const assert(this->Position != this->State->SnapshotData.Root()); Snapshot snapshot; - if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType) + PositionType parentPos = this->Position; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) { return snapshot; } - PositionType parentPos = this->Position; ++parentPos; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos == this->State->SnapshotData.Root()) { return snapshot; diff --git a/Source/cmState.h b/Source/cmState.h index 23fbc79..63b60ef 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -37,7 +37,8 @@ public: FunctionCallType, MacroCallType, CallStackType, - InlineListFileType + InlineListFileType, + PolicyScopeType }; class Directory; @@ -148,6 +149,7 @@ public: const std::string& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot); Snapshot Pop(Snapshot originSnapshot); enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, -- cgit v0.12 From 65a5e0c671fc7d42525a6279aebf9a74de2c97a7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 14 Jun 2015 01:38:57 +0200 Subject: cmLinkedTree: Add Clear API. --- Source/cmLinkedTree.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index df00b30..3bcb940 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -155,6 +155,12 @@ public: return iterator(this, 1); } + void Clear() + { + this->UpPositions.clear(); + this->Data.clear(); + } + private: T& GetReference(PositionType pos) { -- cgit v0.12 From 52dbe654dea7562564be9d880540e6bc706998ba Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Aug 2015 07:20:26 +0200 Subject: cmState: Record the end position of each directory. At generate time, variables and policies are determined from the end state of the cmMakefile. --- Source/cmState.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 09446bb..1d24ec6 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -34,6 +34,8 @@ struct cmState::SnapshotDataType struct cmState::BuildsystemDirectoryStateType { + cmState::PositionType DirectoryEnd; + std::string Location; std::string OutputLocation; @@ -239,6 +241,9 @@ cmState::Snapshot cmState::Reset() this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); + PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); + { cmLinkedTree::iterator it = this->BuildsystemDirectory.Truncate(); @@ -248,9 +253,8 @@ cmState::Snapshot cmState::Reset() it->CompileDefinitionsBacktraces.clear(); it->CompileOptions.clear(); it->CompileOptionsBacktraces.clear(); + it->DirectoryEnd = pos; } - PositionType pos = this->SnapshotData.Truncate(); - this->ExecutionListFiles.Truncate(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -721,6 +725,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->IncludeDirectoryPosition = 0; pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -741,6 +746,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -757,6 +763,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = FunctionCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -774,6 +781,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -790,6 +798,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -806,6 +815,7 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->SnapshotType = InlineListFileType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -815,6 +825,7 @@ cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; + pos->BuildSystemDirectory->DirectoryEnd = pos; return cmState::Snapshot(this, pos); } @@ -829,6 +840,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->BuildSystemDirectory->CompileDefinitions.size(); prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); + prevPos->BuildSystemDirectory->DirectoryEnd = prevPos; return Snapshot(this, prevPos); } -- cgit v0.12 From 757a1f54085af4645ee1946329e24538162ac054 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Jul 2015 13:04:09 +0200 Subject: cmState: Move PolicyState from cmMakefile. Implement lexical scope checking in terms of the state stack instead of barriers. --- Source/cmMakefile.cxx | 93 ++++------------------------------------ Source/cmMakefile.h | 13 ------ Source/cmState.cxx | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmState.h | 10 +++++ 4 files changed, 135 insertions(+), 97 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9fb3d06..a0a36ec 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -192,9 +192,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->StateSnapshot = this->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->StateSnapshot); - // Protect the directory-level policies. - this->PushPolicyBarrier(); - // Enter a policy level for this directory. this->PushPolicy(); @@ -239,11 +236,6 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- @@ -479,7 +471,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, this->Makefile->ContextStack.back()->Name, this->Makefile->ContextStack.back()->Line, filenametoread); - this->Makefile->PushPolicyBarrier(); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -519,7 +510,8 @@ cmMakefile::IncludeScope::~IncludeScope() // one we pushed above. If the entry is empty, then the included // script did not set any policies that might affect the includer so // we do not need to enforce the policy. - if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty()) + if(this->CheckCMP0011 + && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) { this->CheckCMP0011 = false; } @@ -535,9 +527,6 @@ cmMakefile::IncludeScope::~IncludeScope() } } this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -646,19 +635,12 @@ public: this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PushPolicyBarrier(); - this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { this->Makefile->PopPolicyBarrier(this->ReportError); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } @@ -1630,7 +1612,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->Internal->PushDefinitions(); @@ -1650,8 +1631,6 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); this->PopFunctionBlockerBarrier(reportError); @@ -1675,7 +1654,6 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->ContextStack.back()->Name, this->ContextStack.back()->Line, fileName); assert(this->StateSnapshot.IsValid()); - this->PushPolicyBarrier(); this->PushFunctionBlockerBarrier(); @@ -1687,9 +1665,6 @@ void cmMakefile::PopMacroScope(bool reportError) this->PopPolicy(); this->PopPolicyBarrier(reportError); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); - this->PopFunctionBlockerBarrier(reportError); } @@ -1710,7 +1685,6 @@ public: this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); this->GG = mf->GetGlobalGenerator(); @@ -1727,8 +1701,6 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); #if defined(CMAKE_BUILD_WITH_CMAKE) this->GG->GetFileLockPool().PopFileScope(); #endif @@ -4759,30 +4731,7 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - - if(status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) - { - return status; - } - - cmLocalGenerator* lg = this->LocalGenerator; - while(lg) - { - cmMakefile const* mf = lg->GetMakefile(); - for(PolicyStackType::const_reverse_iterator psi = - mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) - { - if(psi->IsDefined(id)) - { - status = psi->Get(id); - return status; - } - } - lg = lg->GetParent(); - } - return status; + return this->StateSnapshot.GetPolicy(id); } //---------------------------------------------------------------------------- @@ -4831,15 +4780,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, return false; } - // Update the policy stack from the top to the top-most strong entry. - bool previous_was_weak = true; - for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); - previous_was_weak && psi != this->PolicyStack.rend(); ++psi) - { - psi->Set(id, status); - previous_was_weak = psi->Weak; - } - + this->StateSnapshot.SetPolicy(id, status); return true; } @@ -4850,7 +4791,6 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, { this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); - this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicy(weak, pm); } @@ -4859,25 +4799,18 @@ cmMakefile::PolicyPushPop::~PolicyPushPop() { this->Makefile->PopPolicy(); this->Makefile->PopPolicyBarrier(this->ReportError); - this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() - ->Pop(this->Makefile->StateSnapshot); } //---------------------------------------------------------------------------- void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm) { - // Allocate a new stack entry. - this->PolicyStack.push_back(PolicyStackEntry(pm, weak)); + this->StateSnapshot.PushPolicy(pm, weak); } //---------------------------------------------------------------------------- void cmMakefile::PopPolicy() { - if(this->PolicyStack.size() > this->PolicyBarriers.back()) - { - this->PolicyStack.pop_back(); - } - else + if (!this->StateSnapshot.PopPolicy()) { this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy POP without matching PUSH"); @@ -4885,17 +4818,9 @@ void cmMakefile::PopPolicy() } //---------------------------------------------------------------------------- -void cmMakefile::PushPolicyBarrier() -{ - this->PolicyBarriers.push_back(this->PolicyStack.size()); -} - -//---------------------------------------------------------------------------- void cmMakefile::PopPolicyBarrier(bool reportError) { - // Remove any extra entries pushed on the barrier. - PolicyStackType::size_type barrier = this->PolicyBarriers.back(); - while(this->PolicyStack.size() > barrier) + while (!this->StateSnapshot.CanPopPolicyScope()) { if(reportError) { @@ -4906,8 +4831,8 @@ void cmMakefile::PopPolicyBarrier(bool reportError) this->PopPolicy(); } - // Remove the barrier. - this->PolicyBarriers.pop_back(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..173914e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -909,7 +909,6 @@ private: void PushPolicy(bool weak = false, cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap()); void PopPolicy(); - void PushPolicyBarrier(); void PopPolicyBarrier(bool reportError = true); friend class cmCMakePolicyCommand; class IncludeScope; @@ -919,18 +918,6 @@ private: class BuildsystemFileScope; friend class BuildsystemFileScope; - // stack of policy settings - struct PolicyStackEntry: public cmPolicies::PolicyMap - { - typedef cmPolicies::PolicyMap derived; - PolicyStackEntry(bool w = false): derived(), Weak(w) {} - PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {} - PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} - bool Weak; - }; - typedef std::vector PolicyStackType; - PolicyStackType PolicyStack; - std::vector PolicyBarriers; // CMP0053 == old cmake::MessageType ExpandVariablesInStringOld( diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 1d24ec6..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -21,6 +21,9 @@ struct cmState::SnapshotDataType { cmState::PositionType DirectoryParent; + cmLinkedTree::iterator Policies; + cmLinkedTree::iterator PolicyRoot; + cmLinkedTree::iterator PolicyScope; cmState::SnapshotType SnapshotType; cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator @@ -32,6 +35,15 @@ struct cmState::SnapshotDataType std::vector::size_type CompileOptionsPosition; }; +struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false): derived(), Weak(w) {} + PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} + bool Weak; +}; + struct cmState::BuildsystemDirectoryStateType { cmState::PositionType DirectoryEnd; @@ -256,6 +268,13 @@ cmState::Snapshot cmState::Reset() it->DirectoryEnd = pos; } + this->PolicyStack.Clear(); + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); + this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "", true); @@ -726,6 +745,11 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -747,6 +771,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = originSnapshot.Position->Policies; + pos->PolicyRoot = originSnapshot.Position->Policies; + pos->PolicyScope = originSnapshot.Position->Policies; + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -764,6 +793,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -782,6 +812,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -799,6 +830,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -816,6 +848,7 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -826,6 +859,7 @@ cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) *originSnapshot.Position); pos->SnapshotType = PolicyScopeType; pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -1005,6 +1039,88 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const return snapshot; } +void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + PositionType pos = this->Position; + pos->Policies = + this->State->PolicyStack.Extend(pos->Policies, + PolicyStackEntry(entry, weak)); +} + +bool cmState::Snapshot::PopPolicy() +{ + PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) + { + return false; + } + ++pos->Policies; + return true; +} + +bool cmState::Snapshot::CanPopPolicyScope() +{ + return this->Position->Policies == this->Position->PolicyScope; +} + +void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for(cmLinkedTree::iterator psi = this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) + { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus +cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + + cmLinkedTree::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) + { + assert(dir.IsValid()); + cmLinkedTree::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree::iterator root = + dir->DirectoryEnd->PolicyRoot; + for( ; leaf != root; ++leaf) + { + if(leaf->IsDefined(id)) + { + status = leaf->Get(id); + return status; + } + } + cmState::PositionType e = dir->DirectoryEnd; + cmState::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) + { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmState::Snapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + static const std::string cmPropertySentinal = std::string(); template diff --git a/Source/cmState.h b/Source/cmState.h index 63b60ef..07aa2a5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -17,6 +17,7 @@ #include "cmPropertyMap.h" #include "cmLinkedTree.h" #include "cmAlgorithms.h" +#include "cmPolicies.h" class cmake; class cmCommand; @@ -24,6 +25,7 @@ class cmCommand; class cmState { struct SnapshotDataType; + struct PolicyStackEntry; struct BuildsystemDirectoryStateType; typedef cmLinkedTree::iterator PositionType; friend class Snapshot; @@ -61,6 +63,13 @@ public: void InitializeFromParent(); + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + bool HasDefinedPolicyCMP0011(); + void PushPolicy(cmPolicies::PolicyMap entry, bool weak); + bool PopPolicy(); + bool CanPopPolicyScope(); + cmState* GetState() const; Directory GetDirectory() const; @@ -257,6 +266,7 @@ private: cmLinkedTree ExecutionListFiles; + cmLinkedTree PolicyStack; cmLinkedTree SnapshotData; std::vector SourceDirectoryComponents; -- cgit v0.12 From ebacce3f0b0cef6116e91d408d591ff67285c420 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 3 Aug 2015 00:01:05 -0400 Subject: 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 8c496cd..368ff0c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150802) +set(CMake_VERSION_PATCH 20150803) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 623dcc85a447b9ce0f09cffa8cd296cd8a51ad9d Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 29 Jul 2015 14:46:40 -0400 Subject: ExternalProject: Avoid if() auto-dereference of a "TEST" variable Exposed by CMP0054 warnings. --- Modules/ExternalProject.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index f6844be..fdb146a 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1211,7 +1211,7 @@ function(_ep_get_build_command name step cmd_var) if(step STREQUAL "INSTALL") set(args install) endif() - if(step STREQUAL "TEST") + if("x${step}x" STREQUAL "xTESTx") set(args test) endif() else() @@ -1230,7 +1230,7 @@ function(_ep_get_build_command name step cmd_var) list(APPEND args --target install) endif() # But for "TEST" drive the project with corresponding "ctest". - if(step STREQUAL "TEST") + if("x${step}x" STREQUAL "xTESTx") string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") set(args "") endif() @@ -1246,7 +1246,7 @@ function(_ep_get_build_command name step cmd_var) if(step STREQUAL "INSTALL") set(args install) endif() - if(step STREQUAL "TEST") + if("x${step}x" STREQUAL "xTESTx") set(args test) endif() endif() -- cgit v0.12 From 14e49ed15615e7f2bcb58aa4540683250006f5c7 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 29 Dec 2014 20:47:48 -0500 Subject: if: Add "TEST " condition if(TEST TestNameThatExists) will return true if a test with the name TestNameThatExists has been added with add_test. The syntax is similar to if(TARGET TargetName). Since use of "TEST" as an argument to if() could previously be interpreted as a non-keyword argument, add policy CMP0064 to treat it as a keyword as NEW behavior. --- Help/command/if.rst | 4 ++++ Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0064.rst | 17 ++++++++++++++ Help/release/dev/if-TEST.rst | 5 +++++ Source/cmConditionEvaluator.cxx | 26 +++++++++++++++++++++- Source/cmConditionEvaluator.h | 1 + Source/cmPolicies.h | 3 +++ Tests/RunCMake/CMP0064/CMP0064-NEW.cmake | 5 +++++ Tests/RunCMake/CMP0064/CMP0064-OLD.cmake | 7 ++++++ Tests/RunCMake/CMP0064/CMP0064-WARN.cmake | 7 ++++++ Tests/RunCMake/CMP0064/CMakeLists.txt | 3 +++ Tests/RunCMake/CMP0064/RunCMakeTest.cmake | 5 +++++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/if/RunCMakeTest.cmake | 3 +++ .../if/TestNameThatDoesNotExist-stdout.txt | 1 + Tests/RunCMake/if/TestNameThatDoesNotExist.cmake | 6 +++++ Tests/RunCMake/if/TestNameThatExists-stdout.txt | 1 + Tests/RunCMake/if/TestNameThatExists.cmake | 7 ++++++ 18 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Help/policy/CMP0064.rst create mode 100644 Help/release/dev/if-TEST.rst create mode 100644 Tests/RunCMake/CMP0064/CMP0064-NEW.cmake create mode 100644 Tests/RunCMake/CMP0064/CMP0064-OLD.cmake create mode 100644 Tests/RunCMake/CMP0064/CMP0064-WARN.cmake create mode 100644 Tests/RunCMake/CMP0064/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0064/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt create mode 100644 Tests/RunCMake/if/TestNameThatDoesNotExist.cmake create mode 100644 Tests/RunCMake/if/TestNameThatExists-stdout.txt create mode 100644 Tests/RunCMake/if/TestNameThatExists.cmake diff --git a/Help/command/if.rst b/Help/command/if.rst index 396becf..2465bde 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -71,6 +71,10 @@ Possible expressions are: created by the :command:`add_executable`, :command:`add_library`, or :command:`add_custom_target` commands. +``if(TEST test-name)`` + True if the given name is an existing test name created by the + :command:`add_test` command. + ``if(EXISTS path-to-file-or-directory)`` True if the named file or directory exists. Behavior is well-defined only for full paths. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 0a313cd..590f10d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -121,3 +121,4 @@ All Policies /policy/CMP0061 /policy/CMP0062 /policy/CMP0063 + /policy/CMP0064 diff --git a/Help/policy/CMP0064.rst b/Help/policy/CMP0064.rst new file mode 100644 index 0000000..e9a061b --- /dev/null +++ b/Help/policy/CMP0064.rst @@ -0,0 +1,17 @@ +CMP0064 +------- + +Recognize ``TEST`` as a operator for the :command:`if` command. + +The ``TEST`` operator was added to the :command:`if` command to determine if a +given test name was created by the :command:`add_test` command. + +The ``OLD`` behavior for this policy is to ignore the ``TEST`` operator. +The ``NEW`` behavior is to interpret the ``TEST`` operator. + +This policy was introduced in CMake version 3.4. CMake version +|release| warns when the policy is not set and uses ``OLD`` behavior. Use +the :command:`cmake_policy()` command to set it to ``OLD`` or ``NEW`` +explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/if-TEST.rst b/Help/release/dev/if-TEST.rst new file mode 100644 index 0000000..05bf71c --- /dev/null +++ b/Help/release/dev/if-TEST.rst @@ -0,0 +1,5 @@ +if-TEST +------- + +* Add a new TEST operator to if() that evaluates to true + if a given test name has been defined. diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 420bfdf..7874803 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -16,7 +16,8 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): Makefile(makefile), Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)), Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)), - Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) + Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)), + Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064)) { } @@ -493,6 +494,29 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs, this->Makefile.FindTargetToUse(argP1->GetValue())?true:false, reducible, arg, newArgs, argP1, argP2); } + // does a test exist + if(this->Policy64Status != cmPolicies::OLD && + this->Policy64Status != cmPolicies::WARN) + { + if (this->IsKeyword("TEST", *arg) && argP1 != newArgs.end()) + { + const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str()); + this->HandlePredicate( + haveTest?true:false, + reducible, arg, newArgs, argP1, argP2); + } + } + else if(this->Policy64Status == cmPolicies::WARN && + this->IsKeyword("TEST", *arg)) + { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0064) << "\n"; + e << "TEST will be interpreted as an operator " + "when the policy is set to NEW. " + "Since the policy is not set the OLD behavior will be used."; + + this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + } // is a variable defined if (this->IsKeyword("DEFINED", *arg) && argP1 != newArgs.end()) { diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index c923d76..c4e2d11 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -94,6 +94,7 @@ private: cmPolicies::PolicyStatus Policy12Status; cmPolicies::PolicyStatus Policy54Status; cmPolicies::PolicyStatus Policy57Status; + cmPolicies::PolicyStatus Policy64Status; }; #endif diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index b783701..a791b89 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -217,6 +217,9 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0063, \ "Honor visibility properties for all target types.", \ + 3, 3, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0064, \ + "Support new TEST if() operator.", \ 3, 3, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) diff --git a/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake b/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake new file mode 100644 index 0000000..cdf50e9 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMP0064-NEW.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0064 NEW) + +if(NOT TEST TestThatDoesNotExist) + message(STATUS "if NOT TestThatDoesNotExist is true") +endif() diff --git a/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake b/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake new file mode 100644 index 0000000..bffd3f3 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMP0064-OLD.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 OLD) + +if(TEST) + message(FATAL_ERROR "TEST was not recognized to be undefined") +else() + message(STATUS "TEST was treated as a variable") +endif() diff --git a/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake b/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake new file mode 100644 index 0000000..bffd3f3 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMP0064-WARN.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 OLD) + +if(TEST) + message(FATAL_ERROR "TEST was not recognized to be undefined") +else() + message(STATUS "TEST was treated as a variable") +endif() diff --git a/Tests/RunCMake/CMP0064/CMakeLists.txt b/Tests/RunCMake/CMP0064/CMakeLists.txt new file mode 100644 index 0000000..74b3ff8 --- /dev/null +++ b/Tests/RunCMake/CMP0064/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0064/RunCMakeTest.cmake b/Tests/RunCMake/CMP0064/RunCMakeTest.cmake new file mode 100644 index 0000000..26e0a91 --- /dev/null +++ b/Tests/RunCMake/CMP0064/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0064-OLD) +run_cmake(CMP0064-WARN) +run_cmake(CMP0064-NEW) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 607e799..20d47b2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -103,6 +103,7 @@ add_RunCMake_test(CMP0055) add_RunCMake_test(CMP0057) add_RunCMake_test(CMP0059) add_RunCMake_test(CMP0060) +add_RunCMake_test(CMP0064) if(CMAKE_GENERATOR MATCHES "Make") add_RunCMake_test(Make) endif() diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake index 2c0c4d7..3f4d2a2 100644 --- a/Tests/RunCMake/if/RunCMakeTest.cmake +++ b/Tests/RunCMake/if/RunCMakeTest.cmake @@ -4,3 +4,6 @@ run_cmake(InvalidArgument1) run_cmake(IsDirectory) run_cmake(IsDirectoryLong) run_cmake(elseif-message) + +run_cmake(TestNameThatExists) +run_cmake(TestNameThatDoesNotExist) diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt b/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt new file mode 100644 index 0000000..8874ca8 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist-stdout.txt @@ -0,0 +1 @@ +TestThatDoesNotExist is false diff --git a/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake new file mode 100644 index 0000000..74bc8b0 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatDoesNotExist.cmake @@ -0,0 +1,6 @@ +cmake_policy(SET CMP0064 NEW) +if(TEST TestThatDoesNotExist) + message(FATAL_ERROR "if TestThatDoesNotExist is true") +else() + message(STATUS "if TestThatDoesNotExist is false") +endif() diff --git a/Tests/RunCMake/if/TestNameThatExists-stdout.txt b/Tests/RunCMake/if/TestNameThatExists-stdout.txt new file mode 100644 index 0000000..54911bc --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatExists-stdout.txt @@ -0,0 +1 @@ +TestThatExists is true diff --git a/Tests/RunCMake/if/TestNameThatExists.cmake b/Tests/RunCMake/if/TestNameThatExists.cmake new file mode 100644 index 0000000..65c2b46 --- /dev/null +++ b/Tests/RunCMake/if/TestNameThatExists.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0064 NEW) +add_test(NAME TestThatExists COMMAND ${CMAKE_COMMAND} -E echo "A CMake Test") +if(TEST TestThatExists) + message(STATUS "if TestThatExists is true") +else() + message(FATAL_ERROR "if TestThatExists is false") +endif() -- cgit v0.12 From d951f5429a116e6174f9cdb983945cb01cf37553 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Aug 2015 10:19:49 -0400 Subject: Help: Refine RULE_LAUNCH_{COMPILE,CUSTOM,LINK} global property docs Link to the generators that implement these properties. Explain in more detail why other generators ignore them. --- Help/prop_gbl/RULE_LAUNCH_COMPILE.rst | 10 ++++++---- Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst | 10 ++++++---- Help/prop_gbl/RULE_LAUNCH_LINK.rst | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst b/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst index 980843b..e0df878 100644 --- a/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst +++ b/Help/prop_gbl/RULE_LAUNCH_COMPILE.rst @@ -3,7 +3,9 @@ RULE_LAUNCH_COMPILE Specify a launcher for compile rules. -Makefile generators prefix compiler commands with the given launcher -command line. This is intended to allow launchers to intercept build -problems with high granularity. Non-Makefile generators currently -ignore this property. +:ref:`Makefile Generators` and the :generator:`Ninja` generator prefix +compiler commands with the given launcher command line. +This is intended to allow launchers to intercept build problems +with high granularity. Other generators ignore this property +because their underlying build systems provide no hook to wrap +individual commands with a launcher. diff --git a/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst b/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst index 9d4a25c..b20c59b 100644 --- a/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst +++ b/Help/prop_gbl/RULE_LAUNCH_CUSTOM.rst @@ -3,7 +3,9 @@ RULE_LAUNCH_CUSTOM Specify a launcher for custom rules. -Makefile generators prefix custom commands with the given launcher -command line. This is intended to allow launchers to intercept build -problems with high granularity. Non-Makefile generators currently -ignore this property. +:ref:`Makefile Generators` and the :generator:`Ninja` generator prefix +custom commands with the given launcher command line. +This is intended to allow launchers to intercept build problems +with high granularity. Other generators ignore this property +because their underlying build systems provide no hook to wrap +individual commands with a launcher. diff --git a/Help/prop_gbl/RULE_LAUNCH_LINK.rst b/Help/prop_gbl/RULE_LAUNCH_LINK.rst index 191f1d5..567bb68 100644 --- a/Help/prop_gbl/RULE_LAUNCH_LINK.rst +++ b/Help/prop_gbl/RULE_LAUNCH_LINK.rst @@ -3,7 +3,9 @@ RULE_LAUNCH_LINK Specify a launcher for link rules. -Makefile generators prefix link and archive commands with the given -launcher command line. This is intended to allow launchers to -intercept build problems with high granularity. Non-Makefile -generators currently ignore this property. +:ref:`Makefile Generators` and the :generator:`Ninja` generator prefix +link and archive commands with the given launcher command line. +This is intended to allow launchers to intercept build problems +with high granularity. Other generators ignore this property +because their underlying build systems provide no hook to wrap +individual commands with a launcher. -- cgit v0.12 From 9a59ae5c198f7c413bcaf29f1ab107a265677b95 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 3 Aug 2015 13:14:14 -0400 Subject: KWSys 2015-08-03 (dad68c33) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ dad68c33 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' f63febb7..dad68c33 James Johnston (1): dad68c33 Encoding: Fix undefined behavior if out of memory. Jean-Christophe Fillion-Robin (2): e5c23738 SystemTools: Fix DetectFileType failure on missing file 6d83c113 SystemTools: Fix DetectFileType failure on directory Sebastian Schuberth (1): 4db8e69f SystemTools: Implement FileIsSymlink on Windows --- EncodingC.c | 14 ++++++++++---- SystemTools.cxx | 18 ++++++++++++++++-- testSystemTools.cxx | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/EncodingC.c b/EncodingC.c index ba2cec2..32b9bff 100644 --- a/EncodingC.c +++ b/EncodingC.c @@ -45,8 +45,11 @@ wchar_t* kwsysEncoding_DupToWide(const char* str) if(length > 0) { ret = (wchar_t*)malloc((length)*sizeof(wchar_t)); - ret[0] = 0; - kwsysEncoding_mbstowcs(ret, str, length); + if(ret) + { + ret[0] = 0; + kwsysEncoding_mbstowcs(ret, str, length); + } } return ret; } @@ -72,8 +75,11 @@ char* kwsysEncoding_DupToNarrow(const wchar_t* str) if(length > 0) { ret = (char*)malloc(length); - ret[0] = 0; - kwsysEncoding_wcstombs(ret, str, length); + if(ret) + { + ret[0] = 0; + kwsysEncoding_wcstombs(ret, str, length); + } } return ret; } diff --git a/SystemTools.cxx b/SystemTools.cxx index 3452259..0714344 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3198,8 +3198,16 @@ bool SystemTools::FileIsDirectory(const kwsys_stl::string& inName) bool SystemTools::FileIsSymlink(const kwsys_stl::string& name) { #if defined( _WIN32 ) - (void)name; - return false; + DWORD attr = GetFileAttributesW( + SystemTools::ConvertToWindowsExtendedPath(name).c_str()); + if (attr != INVALID_FILE_ATTRIBUTES) + { + return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + } + else + { + return false; + } #else struct stat fs; if(lstat(name.c_str(), &fs) == 0) @@ -4230,6 +4238,11 @@ SystemTools::DetectFileType(const char *filename, return SystemTools::FileTypeUnknown; } + if (SystemTools::FileIsDirectory(filename)) + { + return SystemTools::FileTypeUnknown; + } + FILE *fp = Fopen(filename, "rb"); if (!fp) { @@ -4243,6 +4256,7 @@ SystemTools::DetectFileType(const char *filename, fclose(fp); if (read_length == 0) { + delete [] buffer; return SystemTools::FileTypeUnknown; } diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 15d8eab..7b5c025 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -98,6 +98,10 @@ static bool CheckEscapeChars(kwsys_stl::string input, static bool CheckFileOperations() { bool res = true; + const kwsys_stl::string testNonExistingFile(TEST_SYSTEMTOOLS_SOURCE_DIR + "/testSystemToolsNonExistingFile"); + const kwsys_stl::string testDotFile(TEST_SYSTEMTOOLS_SOURCE_DIR + "/."); const kwsys_stl::string testBinFile(TEST_SYSTEMTOOLS_SOURCE_DIR "/testSystemTools.bin"); const kwsys_stl::string testTxtFile(TEST_SYSTEMTOOLS_SOURCE_DIR @@ -106,6 +110,24 @@ static bool CheckFileOperations() "/testSystemToolsNewDir"); const kwsys_stl::string testNewFile(testNewDir + "/testNewFile.txt"); + if (kwsys::SystemTools::DetectFileType(testNonExistingFile.c_str()) != + kwsys::SystemTools::FileTypeUnknown) + { + kwsys_ios::cerr + << "Problem with DetectFileType - failed to detect type of: " + << testNonExistingFile << kwsys_ios::endl; + res = false; + } + + if (kwsys::SystemTools::DetectFileType(testDotFile.c_str()) != + kwsys::SystemTools::FileTypeUnknown) + { + kwsys_ios::cerr + << "Problem with DetectFileType - failed to detect type of: " + << testDotFile << kwsys_ios::endl; + res = false; + } + if (kwsys::SystemTools::DetectFileType(testBinFile.c_str()) != kwsys::SystemTools::FileTypeBinary) { -- cgit v0.12 From 331e791a3e18d8335960c0161d30dbe04e3a6fe5 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 4 Aug 2015 00:01:07 -0400 Subject: 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 368ff0c..9a7ae8b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150803) +set(CMake_VERSION_PATCH 20150804) #set(CMake_VERSION_RC 1) -- cgit v0.12 From e72806fb30dd9162aa1b05cb478ae51d1ecd27fa Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 31 Jul 2015 10:00:43 +0200 Subject: FindJava: Add support for idlj and jarsigner tools --- Help/release/dev/java-updates.rst | 5 +++ Modules/FindJava.cmake | 94 +++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 23 deletions(-) create mode 100644 Help/release/dev/java-updates.rst diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst new file mode 100644 index 0000000..94998eb --- /dev/null +++ b/Help/release/dev/java-updates.rst @@ -0,0 +1,5 @@ +java-updates +------------ + +* The :module:`FindJava` module learned to optionally find + the ``idlj`` and ``jarsigner`` tools. diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 9e43174..9f87997 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -8,21 +8,34 @@ # include files and libraries are. The caller may set variable JAVA_HOME # to specify a Java installation prefix explicitly. # +# +# Specify one or more of the following components as you call this find module. See example below. +# +# :: +# +# Runtime = User just want to execute some Java byte-compiled +# Development = Development tools (java, javac, javah and javadoc), includes Runtime component +# IdlJ = idl compiler for Java +# JarSigner = signer tool for jar +# +# # This module sets the following result variables: # # :: # -# Java_JAVA_EXECUTABLE = the full path to the Java runtime -# Java_JAVAC_EXECUTABLE = the full path to the Java compiler -# Java_JAVAH_EXECUTABLE = the full path to the Java header generator -# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator -# Java_JAR_EXECUTABLE = the full path to the Java archiver -# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 -# Java_VERSION_MAJOR = The major version of the package found. -# Java_VERSION_MINOR = The minor version of the package found. -# Java_VERSION_PATCH = The patch version of the package found. -# Java_VERSION_TWEAK = The tweak version of the package found (after '_') -# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) +# Java_JAVA_EXECUTABLE = the full path to the Java runtime +# Java_JAVAC_EXECUTABLE = the full path to the Java compiler +# Java_JAVAH_EXECUTABLE = the full path to the Java header generator +# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator +# Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler +# Java_JAR_EXECUTABLE = the full path to the Java archiver +# Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer +# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 +# Java_VERSION_MAJOR = The major version of the package found. +# Java_VERSION_MINOR = The minor version of the package found. +# Java_VERSION_PATCH = The patch version of the package found. +# Java_VERSION_TWEAK = The tweak version of the package found (after '_') +# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # # # @@ -184,28 +197,61 @@ find_program(Java_JAVADOC_EXECUTABLE PATHS ${_JAVA_PATHS} ) +find_program(Java_IDLJ_EXECUTABLE + NAMES idlj + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + +find_program(Java_JARSIGNER_EXECUTABLE + NAMES jarsigner + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(Java_FIND_COMPONENTS) + set(_JAVA_REQUIRED_VARS) foreach(component ${Java_FIND_COMPONENTS}) # User just want to execute some Java byte-compiled - if(component STREQUAL "Runtime") - find_package_handle_standard_args(Java - REQUIRED_VARS Java_JAVA_EXECUTABLE - VERSION_VAR Java_VERSION - ) + If(component STREQUAL "Runtime") + list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE) + if(Java_JAVA_EXECUTABLE) + set(Java_Runtime_FOUND TRUE) + endif() elseif(component STREQUAL "Development") - find_package_handle_standard_args(Java - REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE - Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE - VERSION_VAR Java_VERSION - ) + list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE + Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) + if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE + AND Java_JAVAH_EXECUTABLE AND Java_JAVADOC_EXECUTABLE) + set(Java_Development_FOUND TRUE) + endif() + elseif(component STREQUAL "IdlJ") + list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE) + if(Java_IdlJ_EXECUTABLE) + set(Java_Extra_FOUND TRUE) + endif() + elseif(component STREQUAL "JarSigner") + list(APPEND _JAVA_REQUIRED_VARS Java_JARSIGNER_EXECUTABLE) + if(Java_IDLJ_EXECUTABLE) + set(Java_JarSigner_FOUND TRUE) + endif() else() message(FATAL_ERROR "Comp: ${component} is not handled") endif() - set(Java_${component}_FOUND TRUE) endforeach() + list (REMOVE_DUPLICATES _JAVA_REQUIRED_VARS) + find_package_handle_standard_args(Java + REQUIRED_VARS ${_JAVA_REQUIRED_VARS} HANDLE_COMPONENTS + VERSION_VAR Java_VERSION + ) + if(Java_FOUND) + foreach(component ${Java_FIND_COMPONENTS}) + set(Java_${component}_FOUND TRUE) + endforeach() + endif() else() - # Check for everything + # Check for Development find_package_handle_standard_args(Java REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE @@ -220,6 +266,8 @@ mark_as_advanced( Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE + Java_IDLJ_EXECUTABLE + Java_JARSIGNER_EXECUTABLE ) # LEGACY -- cgit v0.12 From 3d287de4ea99718ffe2ac6b855c2786d67946be2 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Thu, 30 Jul 2015 11:17:04 +0200 Subject: UseJava: Teach add_jar to support file syntax for sources --- Help/release/dev/java-updates.rst | 4 ++++ Modules/UseJava.cmake | 34 +++++++++++++++++++++++++--------- Tests/CMakeLists.txt | 21 +++++++++++++++++---- Tests/Java/CMakeLists.txt | 4 ++++ 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index 94998eb..2e5e184 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -3,3 +3,7 @@ java-updates * The :module:`FindJava` module learned to optionally find the ``idlj`` and ``jarsigner`` tools. + +* The :module:`UseJava` module ``add_jar`` function learned + to support response files (e.g. ``@srcs.txt``) for source + specification. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 5eb0ca8..0add8d2 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -21,7 +21,8 @@ # # This command creates a .jar. It compiles the given # source files (source) and adds the given resource files (resource) to -# the jar file. If only resource files are given then just a jar file +# the jar file. Source files can be java files or listing files +# (prefixed by '@'). If only resource files are given then just a jar file # is created. The list of include jars are added to the classpath when # compiling the java sources and also to the dependencies of the target. # INCLUDE_JARS also accepts other target names created by add_jar. For @@ -423,6 +424,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_CLASS_FILES) set(_JAVA_COMPILE_FILES) + set(_JAVA_COMPILE_FILELISTS) set(_JAVA_DEPENDS) set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) @@ -433,7 +435,11 @@ function(add_jar _TARGET_NAME) get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH) get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE) - if (_JAVA_EXT MATCHES ".java") + if (_JAVA_SOURCE_FILE MATCHES "^@(.+)$") + get_filename_component(_JAVA_FULL ${CMAKE_MATCH_1} ABSOLUTE) + list(APPEND _JAVA_COMPILE_FILELISTS ${_JAVA_FULL}) + + elseif (_JAVA_EXT MATCHES ".java") file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL}) file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) @@ -492,11 +498,21 @@ function(add_jar _TARGET_NAME) file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") endif() - if (_JAVA_COMPILE_FILES) - # Create the list of files to compile. - set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) - string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") - file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + if (_JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS) + set (_JAVA_SOURCES_FILELISTS) + + if (_JAVA_COMPILE_FILES) + # Create the list of files to compile. + set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) + string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") + file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_SOURCES_FILE}") + endif() + if (_JAVA_COMPILE_FILELISTS) + foreach (_JAVA_FILELIST IN LISTS _JAVA_COMPILE_FILELISTS) + list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_FILELIST}") + endforeach() + endif() # Compile the java files and create a list of class files add_custom_command( @@ -506,9 +522,9 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} - @${_JAVA_SOURCES_FILE} + ${_JAVA_SOURCES_FILELISTS} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} - DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS} + DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building Java objects for ${_TARGET_NAME}.jar" ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d95a5f4..5781a9e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3008,17 +3008,30 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink file(READ "${JNI_H}" JNI_FILE) if("${JNI_FILE}" MATCHES "JDK1_2") - add_test(Java ${CMAKE_CTEST_COMMAND} + add_test(Java.Jar ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJar" ${build_generator_args} --build-project hello + --build-target hello --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/" --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar") + add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJarSourceList" + ${build_generator_args} + --build-project hello + --build-target hello2 + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") endif() endif() endif() diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index 6a69a24..e1bcf3c 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -7,3 +7,7 @@ find_package(Java COMPONENTS Development) include (UseJava) add_jar(hello A.java HelloWorld.java) + +# use listing file to specify sources +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/java_fileslist "A.java\nHelloWorld.java\n") +add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist) -- cgit v0.12 From cc23f0e9d38fe3f880ada549af4e552fc13fc655 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Thu, 30 Jul 2015 11:19:24 +0200 Subject: UseJava: Teach install_jar new DESTINATION and COMPONENT options --- Help/release/dev/java-updates.rst | 4 +++ Modules/UseJava.cmake | 54 ++++++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index 2e5e184..b777807 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -7,3 +7,7 @@ java-updates * The :module:`UseJava` module ``add_jar`` function learned to support response files (e.g. ``@srcs.txt``) for source specification. + +* The :module:`UseJava` module ``install_jar`` function learned + new ``DESTINATION`` and ``COMPONENT`` options to specify + the corresponding :command:`install` command options. diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 0add8d2..c61591d 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -211,14 +211,16 @@ # # :: # -# install_jar(TARGET_NAME DESTINATION) +# install_jar(target_name destination) +# install_jar(target_name DESTINATION destination [COMPONENT component]) # # This command installs the TARGET_NAME files to the given DESTINATION. # It should be called in the same scope as add_jar() or it will fail. # # :: # -# install_jni_symlink(TARGET_NAME DESTINATION) +# install_jni_symlink(target_name destination) +# install_jni_symlink(target_name DESTINATION destination [COMPONENT component]) # # This command installs the TARGET_NAME JNI symlinks to the given # DESTINATION. It should be called in the same scope as add_jar() or it @@ -629,7 +631,26 @@ function(add_jar _TARGET_NAME) endfunction() -function(INSTALL_JAR _TARGET_NAME _DESTINATION) +function(INSTALL_JAR _TARGET_NAME) + if (ARGC EQUAL 2) + set (_DESTINATION ${ARGV1}) + else() + cmake_parse_arguments(_install_jar + "" + "DESTINATION;COMPONENT" + "" + ${ARGN}) + if (_install_jar_DESTINATION) + set (_DESTINATION ${_install_jar_DESTINATION}) + else() + message(SEND_ERROR "install_jar: ${_TARGET_NAME}: DESTINATION must be specified.") + endif() + + if (_install_jar_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jar_COMPONENT}) + endif() + endif() + get_property(__FILES TARGET ${_TARGET_NAME} @@ -643,13 +664,33 @@ function(INSTALL_JAR _TARGET_NAME _DESTINATION) ${__FILES} DESTINATION ${_DESTINATION} + ${_COMPONENT} ) else () - message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + message(SEND_ERROR "install_jar: The target ${_TARGET_NAME} is not known in this scope.") endif () endfunction() -function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) +function(INSTALL_JNI_SYMLINK _TARGET_NAME) + if (ARGC EQUAL 2) + set (_DESTINATION ${ARGV1}) + else() + cmake_parse_arguments(_install_jni_symlink + "" + "DESTINATION;COMPONENT" + "" + ${ARGN}) + if (_install_jni_symlink_DESTINATION) + set (_DESTINATION ${_install_jni_symlink_DESTINATION}) + else() + message(SEND_ERROR "install_jni_symlink: ${_TARGET_NAME}: DESTINATION must be specified.") + endif() + + if (_install_jni_symlink_COMPONENT) + set (_COMPONENT COMPONENT ${_install_jni_symlink_COMPONENT}) + endif() + endif() + get_property(__SYMLINK TARGET ${_TARGET_NAME} @@ -663,9 +704,10 @@ function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) ${__SYMLINK} DESTINATION ${_DESTINATION} + ${_COMPONENT} ) else () - message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + message(SEND_ERROR "install_jni_symlink: The target ${_TARGET_NAME} is not known in this scope.") endif () endfunction() -- cgit v0.12 From 1ab59f688f647abe1bc0b5e7a187ec0bac988e0f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:40 +0200 Subject: cmGlobalNinjaGenerator: Simplify usage of API. --- Source/cmGlobalNinjaGenerator.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d24cce8..5bdd35f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -911,9 +911,7 @@ cmGlobalNinjaGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::MODULE_LIBRARY: { - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); outputs.push_back(ng->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; -- cgit v0.12 From 1aa13f2b58e477095f76d28a8d9bb1b83a9dd1f5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:41 +0200 Subject: cmExportInstallFileGenerator: Simplify local generator access. --- Source/cmExportInstallFileGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 1d75f43..c88b7b2 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -358,7 +358,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = te->Target->GetMakefile() ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); -- cgit v0.12 From c4d2f64f3c9dea3a5fcd8af5bb389db00ccd64df Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Aug 2015 16:39:31 -0400 Subject: add_subdirectory: Fix error message on missing CMakeLists.txt (#15680) Refactoring in commit v3.3.0-rc1~76^2 (cmMakefile: Handle CMP0014 before configuring the generator, 2015-05-14) accidentally left the file name "/CMakeLists.txt" in the error message. Remove it and add a test case. --- Source/cmMakefile.cxx | 4 ++-- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/add_subdirectory/CMakeLists.txt | 3 +++ Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt | 1 + Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt | 5 +++++ Tests/RunCMake/add_subdirectory/DoesNotExist.cmake | 1 + Tests/RunCMake/add_subdirectory/Missing-result.txt | 1 + Tests/RunCMake/add_subdirectory/Missing-stderr.txt | 8 ++++++++ Tests/RunCMake/add_subdirectory/Missing.cmake | 1 + Tests/RunCMake/add_subdirectory/Missing/Missing.txt | 0 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 4 ++++ 11 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/add_subdirectory/CMakeLists.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/DoesNotExist.cmake create mode 100644 Tests/RunCMake/add_subdirectory/Missing-result.txt create mode 100644 Tests/RunCMake/add_subdirectory/Missing-stderr.txt create mode 100644 Tests/RunCMake/add_subdirectory/Missing.cmake create mode 100644 Tests/RunCMake/add_subdirectory/Missing/Missing.txt create mode 100644 Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ee6c1da..bdc55f2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1564,8 +1564,8 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) cmSystemTools::Message(msg.c_str()); } - currentStart += "/CMakeLists.txt"; - if(!cmSystemTools::FileExists(currentStart.c_str(), true)) + std::string const currentStartFile = currentStart + "/CMakeLists.txt"; + if (!cmSystemTools::FileExists(currentStartFile, true)) { // The file is missing. Check policy CMP0014. std::ostringstream e; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 81029cd..4e7c7b3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -118,6 +118,7 @@ add_RunCMake_test(Syntax) add_RunCMake_test(add_custom_command) add_RunCMake_test(add_custom_target) add_RunCMake_test(add_dependencies) +add_RunCMake_test(add_subdirectory) add_RunCMake_test(build_command) add_RunCMake_test(execute_process) add_RunCMake_test(export) diff --git a/Tests/RunCMake/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMakeLists.txt new file mode 100644 index 0000000..18dfd26 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt b/Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt new file mode 100644 index 0000000..369a956 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at DoesNotExist.cmake:1 \(add_subdirectory\): + add_subdirectory given source "DoesNotExist" which is not an existing + directory. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist.cmake b/Tests/RunCMake/add_subdirectory/DoesNotExist.cmake new file mode 100644 index 0000000..fe2945c --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/DoesNotExist.cmake @@ -0,0 +1 @@ +add_subdirectory(DoesNotExist) diff --git a/Tests/RunCMake/add_subdirectory/Missing-result.txt b/Tests/RunCMake/add_subdirectory/Missing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_subdirectory/Missing-stderr.txt b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt new file mode 100644 index 0000000..aba0675 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error at Missing.cmake:1 \(add_subdirectory\): + The source directory + + .*/Tests/RunCMake/add_subdirectory/Missing + + does not contain a CMakeLists.txt file. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/add_subdirectory/Missing.cmake b/Tests/RunCMake/add_subdirectory/Missing.cmake new file mode 100644 index 0000000..0e68927 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Missing.cmake @@ -0,0 +1 @@ +add_subdirectory(Missing) diff --git a/Tests/RunCMake/add_subdirectory/Missing/Missing.txt b/Tests/RunCMake/add_subdirectory/Missing/Missing.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake new file mode 100644 index 0000000..a3ddec8 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(DoesNotExist) +run_cmake(Missing) -- cgit v0.12 From 64aacb24b65e5496b4148437ed96363ae06e8200 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Thu, 16 Jul 2015 22:48:27 +0200 Subject: CPack/RPM: undocumented variables Some CPack/RPM variables were undocumented even though they are implemented in code for quite a while now. --- Modules/CPackRPM.cmake | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index cb77fb8..f442731 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -95,6 +95,7 @@ # * Default : CPACK_PACKAGE_VENDOR if set or "unknown" # # .. variable:: CPACK_RPM_PACKAGE_URL +# CPACK_RPM__PACKAGE_URL # # The projects URL. # @@ -123,7 +124,55 @@ # compression whereas older cannot use such RPM. Using this one can enforce # compression type to be used. Possible value are: lzma, xz, bzip2 and gzip. # +# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ +# CPACK_RPM__PACKAGE_AUTOREQ +# +# RPM spec autoreq field. +# +# * Mandatory : NO +# * Default : - +# +# May be used to enable (1, yes) or disable (0, no) automatic shared libraries +# dependency detection. Dependencies are added to requires list. +# +# .. note:: +# +# By defalut automatic dependency detection is enabled by rpm generator. +# +# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV +# CPACK_RPM__PACKAGE_AUTOPROV +# +# RPM spec autoprov field. +# +# * Mandatory : NO +# * Default : - +# +# May be used to enable (1, yes) or disable (0, no) automatic listing of shared +# libraries that are provided by the package. Shared libraries are added to +# provides list. +# +# .. note:: +# +# By defalut automatic provides detection is enabled by rpm generator. +# +# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV +# CPACK_RPM__PACKAGE_AUTOREQPROV +# +# RPM spec autoreqprov field. +# +# * Mandatory : NO +# * Default : - +# +# Variable enables/disables autoreq and autoprov at the same time. +# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV` +# for more details. +# +# .. note:: +# +# By defalut automatic detection feature is enabled by rpm. +# # .. variable:: CPACK_RPM_PACKAGE_REQUIRES +# CPACK_RPM__PACKAGE_REQUIRES # # RPM spec requires field. # @@ -140,6 +189,7 @@ # rpm -qp --requires file.rpm # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE +# CPACK_RPM__PACKAGE_REQUIRES_PRE # # RPM spec requires(pre) field. # @@ -152,6 +202,7 @@ # set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts") # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST +# CPACK_RPM__PACKAGE_REQUIRES_POST # # RPM spec requires(post) field. # @@ -165,6 +216,7 @@ # # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN +# CPACK_RPM__PACKAGE_REQUIRES_POSTUN # # RPM spec requires(postun) field. # @@ -178,6 +230,7 @@ # # # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN +# CPACK_RPM__PACKAGE_REQUIRES_PREUN # # RPM spec requires(preun) field. # @@ -190,6 +243,7 @@ # set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts") # # .. variable:: CPACK_RPM_PACKAGE_SUGGESTS +# CPACK_RPM__PACKAGE_SUGGESTS # # RPM spec suggest field. # @@ -200,6 +254,7 @@ # enclose the complete requires string between quotes. # # .. variable:: CPACK_RPM_PACKAGE_PROVIDES +# CPACK_RPM__PACKAGE_PROVIDES # # RPM spec provides field. # @@ -212,6 +267,7 @@ # rpm -qp --provides file.rpm # # .. variable:: CPACK_RPM_PACKAGE_OBSOLETES +# CPACK_RPM__PACKAGE_OBSOLETES # # RPM spec obsoletes field. # -- cgit v0.12 From e26f53a88b2fd16fc54513adfbb8eaab26dd102f Mon Sep 17 00:00:00 2001 From: Frank-Christian Otto Date: Fri, 17 Jul 2015 17:11:37 +0200 Subject: CPack/RPM: missing PACKAGE_CONFLICTS documentation --- Modules/CPackRPM.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index f442731..7c1db14 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -188,6 +188,23 @@ # # rpm -qp --requires file.rpm # +# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS +# CPACK_RPM__PACKAGE_CONFLICTS +# +# RPM spec conflicts field. +# +# * Mandatory : NO +# * Default : - +# +# May be used to set negative RPM dependencies (conflicts). Note that you must enclose +# the complete requires string between quotes, for example:: +# +# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2") +# +# The conflicting package list of an RPM file could be printed with:: +# +# rpm -qp --conflicts file.rpm +# # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE # CPACK_RPM__PACKAGE_REQUIRES_PRE # -- cgit v0.12 From a15b69cbc75f475601f41c516330c679915676e4 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 5 Aug 2015 00:01:06 -0400 Subject: 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 9a7ae8b..a9dfae0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150804) +set(CMake_VERSION_PATCH 20150805) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f0609182cc2bbce7f6af557d6352e0c434e7acc2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Aug 2015 10:39:03 -0400 Subject: Fortran: Store detected compiler version persistently (#15684) The Fortran compiler version detection infrastructure added by commit v3.3.0-rc1~436^2~9 (Fortran: Add infrastructure to detect compiler version, 2015-02-17) forgot to update CMakeFortranCompiler.cmake.in to save the compiler version persistently as we do already in "CMake{C,CXX}Compiler.cmake.in". Add the missing line now. --- Modules/CMakeFortranCompiler.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index e4c7618..14fdd60 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -1,6 +1,7 @@ set(CMAKE_Fortran_COMPILER "@CMAKE_Fortran_COMPILER@") set(CMAKE_Fortran_COMPILER_ARG1 "@CMAKE_Fortran_COMPILER_ARG1@") set(CMAKE_Fortran_COMPILER_ID "@CMAKE_Fortran_COMPILER_ID@") +set(CMAKE_Fortran_COMPILER_VERSION "@CMAKE_Fortran_COMPILER_VERSION@") set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@") set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") -- cgit v0.12 From 41abdc17df99662a8e99ba895050dbc8c0e34b8e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:41 +0200 Subject: cmGeneratorTarget: Move GetSOName from cmTarget.. --- Source/cmComputeLinkInformation.cxx | 16 ++++++---- Source/cmExportFileGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 43 +++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 3 ++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmTarget.cxx | 57 ------------------------------------ Source/cmTarget.h | 18 +++++++++--- 8 files changed, 73 insertions(+), 70 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..72db6f8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = 0; + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); + lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -790,9 +791,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, } if(order) { - if(tgt) + if(gtgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; -- cgit v0.12 From 12bc571c13eda8d504eac788d6b3e5e8d83e3ad3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:41 +0200 Subject: cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. --- Source/cmGeneratorTarget.cxx | 26 ++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 4 +++- Source/cmQtAutoGenerators.cxx | 5 ++++- Source/cmTarget.cxx | 25 ------------------------- Source/cmTarget.h | 2 -- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..a72b176 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; -- cgit v0.12 From 244c5b5dcdc5af1f91a79a81f7f7ec4047759fe8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:42 +0200 Subject: cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. --- Source/cmGeneratorExpressionNode.cxx | 27 ++++++----- Source/cmGeneratorTarget.cxx | 81 +++++++++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 26 +++++++++++ Source/cmTarget.cxx | 88 ------------------------------------ Source/cmTarget.h | 19 -------- 5 files changed, 122 insertions(+), 119 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; -- cgit v0.12 From c971338416d7376d8b710b5c18957f6a800b3de0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:42 +0200 Subject: Export: Port more API to cmGeneratorTarget. --- Source/cmExportBuildFileGenerator.cxx | 6 ++++-- Source/cmExportFileGenerator.cxx | 13 +++++++------ Source/cmExportFileGenerator.h | 2 +- Source/cmExportInstallFileGenerator.cxx | 6 +++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c88b7b2..b0bc686 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } -- cgit v0.12 From 803a7982b4403c690d7b7fa8c49d00a5abae3471 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:42 +0200 Subject: cmGeneratorTarget: Move GetLinkInformation from cmTarget --- Source/cmCommonTargetGenerator.cxx | 5 +-- Source/cmExportFileGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 38 +++++++++++++++++++++ Source/cmGeneratorTarget.h | 9 +++++ Source/cmGlobalXCodeGenerator.cxx | 7 ++-- Source/cmInstallTargetGenerator.cxx | 10 +++--- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 4 ++- Source/cmLocalVisualStudio7Generator.cxx | 7 ++-- Source/cmMakefileTargetGenerator.cxx | 3 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 53 ------------------------------ Source/cmTarget.h | 13 -------- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 14 files changed, 72 insertions(+), 85 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - 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); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error -- cgit v0.12 From 90bad039c44195b742740613a34b90697254fdd2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. --- Source/cmGeneratorTarget.cxx | 236 ++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 3 + Source/cmTarget.cxx | 285 ++++--------------------------------------- Source/cmTarget.h | 11 +- 4 files changed, 268 insertions(+), 267 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream 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, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream 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, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; -- cgit v0.12 From 38d4ba3564b9a37f8042888ffd63bf736852b6b8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Port internal API to cmGeneratorTarget. --- Source/cmGeneratorTarget.cxx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *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()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); -- cgit v0.12 From 5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. --- Source/cmGeneratorExpressionNode.cxx | 12 +- Source/cmGeneratorTarget.cxx | 413 ++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 11 + Source/cmLocalGenerator.cxx | 4 +- Source/cmQtAutoGenerators.cxx | 11 +- Source/cmTarget.cxx | 399 --------------------------------- Source/cmTarget.h | 9 - 7 files changed, 433 insertions(+), 426 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; -- cgit v0.12 From 4b86f5edc91ba649908f5b6ab0fb7f1154e38066 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Make CompatibleType enum private again. --- Source/cmGeneratorTarget.cxx | 80 ++++++++++++++++++++++++-------------------- Source/cmTarget.h | 8 ----- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; -- cgit v0.12 From 97f10e488a5153e45d6a27a730cc1ecbaae7d559 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:44 +0200 Subject: cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. --- Source/cmGeneratorTarget.cxx | 60 ++++++++++++++++++++++++++++++++++++-------- Source/cmGeneratorTarget.h | 7 ++++++ Source/cmTarget.cxx | 40 ----------------------------- Source/cmTarget.h | 6 ----- 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; -- cgit v0.12 From 7da4c9d4edbdd6df6aa2a9467d6f32a98fc8cac4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:44 +0200 Subject: cmGeneratorTarget: Move GetLinkImplementationClosure --- Source/cmGeneratorTarget.cxx | 54 +++++++++++++++++++++++++++++++++++++++++--- Source/cmGeneratorTarget.h | 12 ++++++++++ Source/cmTarget.cxx | 54 -------------------------------------------- Source/cmTarget.h | 3 --- 4 files changed, 63 insertions(+), 60 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries -- cgit v0.12 From 47803e6f8e98984e740acf2f7c0a217de58717cd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:44 +0200 Subject: cmGeneratorTarget: Move GetExecutableNames from cmTarget. --- Source/cmGeneratorTarget.cxx | 68 ++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 6 +++ Source/cmInstallTargetGenerator.cxx | 7 ++- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileExecutableTargetGenerator.cxx | 4 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 62 ----------------------- Source/cmTarget.h | 8 --- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 9 files changed, 81 insertions(+), 80 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 37e08dd..daac331 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1244,7 +1244,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } -- cgit v0.12 From 766839c56da82e12b6986fb5cf7c8d86442615bc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: cmGeneratorTarget: Move GetLibraryNames from cmTarget. --- Source/cmGeneratorTarget.cxx | 98 +++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 7 +++ Source/cmInstallTargetGenerator.cxx | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 89 -------------------------- Source/cmTarget.h | 7 --- Source/cmVisualStudio10TargetGenerator.cxx | 3 +- 9 files changed, 107 insertions(+), 109 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index daac331..dd4cd33 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } -- cgit v0.12 From f0aa660772565545cbcda9ed8ae946b8d5097416 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: cmGeneratorTarget: Move HasSOName from cmTarget. --- Source/cmExportFileGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 14 +++++++++++++- Source/cmGeneratorTarget.h | 3 +++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 11 ----------- Source/cmTarget.h | 3 --- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b9..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; -- cgit v0.12 From a45fed81e5fd5d9b280c8dd70d50c9606a982a0b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. --- Source/cmGeneratorTarget.cxx | 45 ++++++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 6 ++++ Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 3 +- Source/cmTarget.cxx | 43 ---------------------------- Source/cmTarget.h | 6 ---- Source/cmVisualStudio10TargetGenerator.cxx | 3 +- 8 files changed, 57 insertions(+), 53 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33..799bac6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); -- cgit v0.12 From 3df705681be123d93146156fec3166b41b19465a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:46 +0200 Subject: cmGeneratorTarget: Move GetPDBName from cmTarget. --- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 36 ++++++++++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 3 +++ Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 31 ------------------------------- Source/cmTarget.h | 3 --- 7 files changed, 40 insertions(+), 39 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; -- cgit v0.12 From 8d2de00244f8338664c16bd8d8ebb03c6f0cb83f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:46 +0200 Subject: cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. --- Source/cmGeneratorTarget.cxx | 67 ++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 5 ++ Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +-- Source/cmInstallTargetGenerator.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 3 +- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +- Source/cmTarget.cxx | 64 ------------------------ Source/cmTarget.h | 5 -- 9 files changed, 80 insertions(+), 78 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; -- cgit v0.12 From e27d737e27fbfc8cfde020ec02d6b2c74afb6885 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:46 +0200 Subject: cmGeneratorTarget: Move IsChrPathUsed from cmTarget. --- Source/cmComputeLinkInformation.cxx | 6 +++- Source/cmGeneratorTarget.cxx | 69 ++++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 3 ++ Source/cmInstallTargetGenerator.cxx | 5 ++- Source/cmTarget.cxx | 67 ----------------------------------- Source/cmTarget.h | 3 -- 6 files changed, 78 insertions(+), 75 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 72db6f8..b7555a6 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ -- cgit v0.12 From 62720e44be3e9f28e4c1e7d38206b2c51d34745e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:47 +0200 Subject: cmGeneratorTarget: Move GetFullNameComponents from cmTarget. --- Source/cmGeneratorTarget.cxx | 10 ++++++++++ Source/cmGeneratorTarget.h | 5 +++++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 9 --------- Source/cmTarget.h | 4 ---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; -- cgit v0.12 From 89e2a080e977b9632fa13c627b6a5370250d6ed5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:47 +0200 Subject: cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 45 +++++++++++++++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 9 +++++++++ Source/cmOSXBundleGenerator.cxx | 2 +- Source/cmTarget.cxx | 39 ----------------------------------- Source/cmTarget.h | 8 -------- 5 files changed, 53 insertions(+), 50 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; -- cgit v0.12 From d560bfd2739f2594119c49d82485b99bb4fbbe1f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:47 +0200 Subject: cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. --- Source/cmExportBuildFileGenerator.cxx | 4 +- Source/cmExportBuildFileGenerator.h | 3 +- Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportFileGenerator.h | 2 +- Source/cmExportInstallFileGenerator.cxx | 4 +- Source/cmExportInstallFileGenerator.h | 3 +- Source/cmExportTryCompileFileGenerator.cxx | 4 +- Source/cmExportTryCompileFileGenerator.h | 2 +- Source/cmGeneratorTarget.cxx | 67 +++++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 9 ++++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 11 +++-- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 3 +- Source/cmTarget.cxx | 67 ----------------------------- Source/cmTarget.h | 9 ---- 16 files changed, 100 insertions(+), 94 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } -- cgit v0.12 From 7a460852fa1bc9df22d4c54bac3d57f909488608 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:48 +0200 Subject: cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 15 ++++++++++++++- Source/cmGeneratorTarget.h | 4 ++++ Source/cmOSXBundleGenerator.cxx | 4 ++-- Source/cmTarget.cxx | 11 ----------- Source/cmTarget.h | 4 ---- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; -- cgit v0.12 From d6bb319b09d056428468d8894f7d7dd2cb0d963e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:48 +0200 Subject: cmGeneratorTarget: Move GetFullName from cmTarget. Bring GetFullNameInternal with it. --- Source/cmGeneratorTarget.cxx | 180 +++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 11 ++ Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmLocalVisualStudio6Generator.cxx | 28 ++--- Source/cmLocalVisualStudio7Generator.cxx | 4 +- Source/cmTarget.cxx | 156 ------------------------- Source/cmTarget.h | 10 -- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 8 files changed, 201 insertions(+), 195 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ @@ -279,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..014d3be 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } @@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 799bac6..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { @@ -3626,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -575,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); -- cgit v0.12 From 6da99de3236fbaeebf6a4fc66f7d68f43a59902f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:48 +0200 Subject: cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 48 ++++++++++++++++++++++++++++++++++++++--- Source/cmGeneratorTarget.h | 8 +++++++ Source/cmOSXBundleGenerator.cxx | 8 +++---- Source/cmTarget.cxx | 41 ----------------------------------- Source/cmTarget.h | 8 ------- 5 files changed, 57 insertions(+), 56 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; -- cgit v0.12 From 7c809fa2a675b7e669e76683f73397e38dd22999 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. --- Source/cmComputeLinkInformation.cxx | 7 +++---- Source/cmGeneratorExpressionNode.cxx | 10 +++++----- Source/cmGeneratorTarget.cxx | 16 +++++++++++----- Source/cmGeneratorTarget.h | 3 +++ Source/cmGhsMultiTargetGenerator.cxx | 3 ++- Source/cmGlobalXCodeGenerator.cxx | 7 ++++--- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 8 ++++---- Source/cmLocalVisualStudio7Generator.cxx | 10 ++++++---- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 10 +++++----- Source/cmMakefileTargetGenerator.cxx | 8 +++++--- Source/cmNinjaNormalTargetGenerator.cxx | 3 +-- Source/cmTarget.cxx | 6 ------ Source/cmTarget.h | 3 --- Source/cmVisualStudio10TargetGenerator.cxx | 6 +++--- 16 files changed, 54 insertions(+), 50 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b7555a6..c46cab8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 014d3be..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error -- cgit v0.12 From f8076644ce21c5c20cb0d368d25c191a05364481 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmGeneratorTarget: Move GetLinkClosure from cmTarget. --- Source/cmComputeLinkInformation.cxx | 15 ++- Source/cmComputeLinkInformation.h | 1 + Source/cmGeneratorTarget.cxx | 226 +++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 17 +++ Source/cmTarget.cxx | 221 ----------------------------------- Source/cmTarget.h | 13 --- 6 files changed, 255 insertions(+), 238 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c46cab8..269aa69 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, -- cgit v0.12 From c8a5f5ae60c911298fc3c0f168ac3652223722a4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmMakefileTargetGenerator: Add accessor for GeneratorTarget. --- Source/cmMakefileTargetGenerator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: -- cgit v0.12 From ee26add4f4062d8b53f22e161027a573dc03399c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmGeneratorTarget: Move IsBundleOnApple from cmTarget. --- Source/cmGeneratorTarget.cxx | 8 ++++++++ Source/cmGeneratorTarget.h | 4 ++++ Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 7 ------- Source/cmTarget.h | 4 ---- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; -- cgit v0.12 From c93230ac3838231f2f44986e224da1bdaf9a7dfe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:50 +0200 Subject: cmComputeLinkInformation: Port to cmGeneratorTarget. --- Source/cmComputeLinkInformation.cxx | 84 ++++++++++++++++++------------------- Source/cmComputeLinkInformation.h | 5 ++- Source/cmGeneratorTarget.cxx | 2 +- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 269aa69..f00a8cf 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; -- cgit v0.12 From 4329a71c128f8a8fca48a8827226d09f61fcbe85 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:50 +0200 Subject: cmComputeLinkDepends: Port to cmGeneratorTarget. --- Source/cmComputeLinkDepends.cxx | 17 +++++++++-------- Source/cmComputeLinkDepends.h | 6 ++++-- Source/cmComputeLinkInformation.cxx | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f00a8cf..7a516e2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); -- cgit v0.12 From 34c437411dad89c671261269f2067129584a4259 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:50 +0200 Subject: cmGeneratorTarget: Move GetOutputName from cmTarget. --- Source/cmGeneratorTarget.cxx | 56 ++++++++++++++++++++++++++++++++++++++++---- Source/cmGeneratorTarget.h | 3 +++ Source/cmTarget.cxx | 48 ------------------------------------- Source/cmTarget.h | 3 --- 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; -- cgit v0.12 From b3f0e35308993de825f00ec18fc6559e6609c9b0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:51 +0200 Subject: cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 12 +++++++++++- Source/cmGeneratorTarget.h | 6 ++++++ Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 16 ---------------- Source/cmTarget.h | 12 +++++------- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* -- cgit v0.12 From f83e84028ac28ce098ea76bd857ae1663c295494 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:51 +0200 Subject: cmGeneratorTarget: Move CompileInfoMap from cmTarget. --- Source/cmGeneratorTarget.cxx | 42 +++++++++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 10 ++++++++++ Source/cmTarget.cxx | 42 ------------------------------------------ Source/cmTarget.h | 7 ------- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, -- cgit v0.12 From a309409ead0bde721a17e8b3c4e89fe6a2181423 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:51 +0200 Subject: cmOrderDirectories: Port to cmGeneratorTarget. --- Source/cmComputeLinkInformation.cxx | 6 +++--- Source/cmOrderDirectories.cxx | 8 +++++--- Source/cmOrderDirectories.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 7a516e2..c3f36af 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; -- cgit v0.12 From 26f5445bb461910efd42bc80a99a63dd53b49643 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Aug 2015 13:28:35 -0400 Subject: Do not install 3rd-party dependencies by default Disable the CMake_INSTALL_DEPENDENCIES option by default and turn it on explicitly in our packaging scripts. This simplifies packaging in distributions that provide the dependencies for us without having to install them. We only need 3rd-party runtime dependencies to be installed for packaging with redistributable binaries. --- CMakeLists.txt | 2 +- Utilities/Release/dash2win64_cygwin.cmake | 1 + Utilities/Release/dash2win64_release.cmake | 1 + Utilities/Release/dashmacmini2_release.cmake | 1 + Utilities/Release/dashmacmini5_release.cmake | 1 + Utilities/Release/linux64_release.cmake | 1 + Utilities/Release/magrathea_release.cmake | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a47c2ad..36244dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ endmacro() # option to disable installing 3rd-party dependencies option(CMake_INSTALL_DEPENDENCIES - "Whether to install 3rd-party runtime dependencies" ON) + "Whether to install 3rd-party runtime dependencies" OFF) mark_as_advanced(CMake_INSTALL_DEPENDENCIES) #----------------------------------------------------------------------- diff --git a/Utilities/Release/dash2win64_cygwin.cmake b/Utilities/Release/dash2win64_cygwin.cmake index ac3c527..d15915a 100644 --- a/Utilities/Release/dash2win64_cygwin.cmake +++ b/Utilities/Release/dash2win64_cygwin.cmake @@ -12,6 +12,7 @@ CTEST_TEST_TIMEOUT:STRING=7200 DART_TESTING_TIMEOUT:STRING=7200 SPHINX_HTML:BOOL=ON SPHINX_MAN:BOOL=ON +CMake_INSTALL_DEPENDENCIES:BOOL=ON ") set(CXX g++) set(CC gcc) diff --git a/Utilities/Release/dash2win64_release.cmake b/Utilities/Release/dash2win64_release.cmake index 2511db4..3ea895a 100644 --- a/Utilities/Release/dash2win64_release.cmake +++ b/Utilities/Release/dash2win64_release.cmake @@ -14,6 +14,7 @@ CMAKE_Fortran_COMPILER:FILEPATH=FALSE CMAKE_GENERATOR:INTERNAL=Unix Makefiles BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=c:/Dashboards/Support/qt-build/Qt/bin/qmake.exe ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index ba82aab..01f5b8b 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -18,6 +18,7 @@ CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal BUILD_QtDialog:BOOL=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.0/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake index b407554..be1dfa9 100644 --- a/Utilities/Release/dashmacmini5_release.cmake +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -20,6 +20,7 @@ CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-x86_64 BUILD_QtDialog:BOOL=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.6/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake index 2cd5dfc..25da00a 100644 --- a/Utilities/Release/linux64_release.cmake +++ b/Utilities/Release/linux64_release.cmake @@ -17,6 +17,7 @@ OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libssl.a CPACK_SYSTEM_NAME:STRING=Linux-x86_64 BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.8.6/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake index b0e0a3a..b031eb8 100644 --- a/Utilities/Release/magrathea_release.cmake +++ b/Utilities/Release/magrathea_release.cmake @@ -17,6 +17,7 @@ OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libssl.a CPACK_SYSTEM_NAME:STRING=Linux-i386 BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +CMake_INSTALL_DEPENDENCIES:BOOL=ON QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.43-install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -- cgit v0.12 From 2eee2943cce2a7aea7a11b93f2459f5f333eb84c Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 2 Aug 2015 00:06:49 +0200 Subject: Xcode: Invert quoting logic to whitelist of characters Our explicit list of characters that require quoting does not account for non-ascii characters (e.g. UTF-8) that also need quoting. Invert the logic to quote a string unless it contains exclusively a set of characters we whitelist. --- Source/cmXCodeObject.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index ba6e395..c59c360 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,11 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},~") != String.npos); + String.find_first_not_of( + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "$_./") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. -- cgit v0.12 From 43c94281401cfa89bcbe7110727845ed5df984ec Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Aug 2015 14:02:55 -0400 Subject: Ninja: Honor the LINK_DEPENDS target property (#14796) --- Source/cmNinjaTargetGenerator.cxx | 9 +++++++++ Tests/BuildDepends/CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..08b2e66 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -209,6 +209,15 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const result.push_back(this->ConvertToNinjaPath(this->ModuleDefinitionFile)); } + // Add user-specified dependencies. + if (const char* linkDepends = this->Target->GetProperty("LINK_DEPENDS")) + { + std::vector linkDeps; + cmSystemTools::ExpandListArgument(linkDepends, linkDeps); + std::transform(linkDeps.begin(), linkDeps.end(), + std::back_inserter(result), MapToNinjaPath()); + } + return result; } diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 7b7353c..36987de 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -34,7 +34,7 @@ if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") set(_cmake_options "-DCMAKE_EXE_LINKER_FLAGS=") endif() -if("${CMAKE_GENERATOR}" MATCHES "Make") +if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") set(TEST_LINK_DEPENDS ${BuildDepends_BINARY_DIR}/Project/linkdep.txt) file(WRITE ${TEST_LINK_DEPENDS} "1") endif() -- cgit v0.12 From 42526efec45993466cbc605eb2cee70194eed4a6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 6 Aug 2015 00:01:07 -0400 Subject: 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 a9dfae0..c9fec35 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150805) +set(CMake_VERSION_PATCH 20150806) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 145735b748ab04505ab7a885a54fbd175ccecee2 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Wed, 29 Jul 2015 23:32:13 +0200 Subject: Tests/RunCMake/CPack: Enable CXX language in tests Enable CXX language for CPack tests so that they may compile binaries if needed. --- Tests/RunCMake/CPack/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index 7905706..46f1367 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -project(${RunCMake_TEST} NONE) +project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) # include test generator specifics -- cgit v0.12 From d882d4770fec6d65d82d818b4979cb5763d253c1 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Wed, 29 Jul 2015 23:34:17 +0200 Subject: Tests/RunCMake/CPack/DEB: Add getPackageInfo helper function getPackageInfo helper function returns package info for provided deb package file --- Tests/RunCMake/CPack/DEB/Helpers.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index 45c85c3..a204a3c 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -26,3 +26,13 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES) endif() endforeach() endfunction() + +function(getPackageInfo FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -I ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE package_info_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_info_}" PARENT_SCOPE) +endfunction() -- cgit v0.12 From 105011e08fafe23cb4cfd4fcb1468187f9d81f21 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Wed, 29 Jul 2015 23:36:11 +0200 Subject: Tests/RunCMake/CPack: Bump verify result cmake version Bumped version to current cmake version so that we always use latest policies. --- Tests/RunCMake/CPack/VerifyResult.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index e059d9c..96efa9e 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR) include("${config_file}") include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake") -- cgit v0.12 From 94226751cb9beb7aa1939e9395d4999e30b30600 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Wed, 29 Jul 2015 23:39:11 +0200 Subject: Tests/RunCMake/CPack: Add dependencies tests Add tests for RPM and DEB package test for currently supported dependency features (requires, provides, conflicts, ...). --- .../CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake | 14 +++++++ .../CPack/DEB/DEPENDENCIES-VerifyResult.cmake | 15 ++++++++ .../CPack/DEB/DEPENDENCIES-specifics.cmake | 15 ++++++++ Tests/RunCMake/CPack/DEPENDENCIES.cmake | 18 +++++++++ .../CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake | 13 +++++++ .../CPack/RPM/DEPENDENCIES-VerifyResult.cmake | 45 ++++++++++++++++++++++ .../CPack/RPM/DEPENDENCIES-specifics.cmake | 22 +++++++++++ Tests/RunCMake/CPack/RunCMakeTest.cmake | 1 + 8 files changed, 143 insertions(+) create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake create mode 100644 Tests/RunCMake/CPack/DEPENDENCIES.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake new file mode 100644 index 0000000..c56c670 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -0,0 +1,14 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1 "dependencies*-applications.deb") +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") +set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb") +set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") +set(EXPECTED_FILE_3 "dependencies*-headers.deb") +set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") +set(EXPECTED_FILE_4 "dependencies*-libs.deb") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") +set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb") +set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake new file mode 100644 index 0000000..44c862d --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake @@ -0,0 +1,15 @@ +function(checkDepends_ FILE REGEX) + set(whitespaces_ "[\t\n\r ]*") + + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") + endif() +endfunction() + +checkDepends_("${FOUND_FILE_1}" ".*Depends${whitespaces_}:${whitespaces_}depend-application, depend-application-b.*") +# use wildcard as we are using dependency auto detection +checkDepends_("${FOUND_FILE_2}" ".*Depends${whitespaces_}:${whitespaces_}.*depend-application, depend-application-b.*") +checkDepends_("${FOUND_FILE_3}" ".*Depends${whitespaces_}:${whitespaces_}depend-headers.*") +checkDepends_("${FOUND_FILE_4}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") +checkDepends_("${FOUND_FILE_5}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake new file mode 100644 index 0000000..9e09428 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake @@ -0,0 +1,15 @@ +set(CPACK_PACKAGE_CONTACT "someone") +set(CPACK_DEB_COMPONENT_INSTALL "ON") + +# false by default +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) +# FIXME can not be tested as libraries first have to be part of a package in order +# to determine their dependencies and we can not be certain if there will be any +set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) + +set(CPACK_DEBIAN_PACKAGE_DEPENDS "depend-default, depend-default-b") +set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DEPENDS "depend-application, depend-application-b") +set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_DEPENDS "depend-application, depend-application-b") +set(CPACK_DEBIAN_HEADERS_PACKAGE_DEPENDS "depend-headers") + +# TODO add other dependency tests once CPackDeb supports them diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake new file mode 100644 index 0000000..0aef925 --- /dev/null +++ b/Tests/RunCMake/CPack/DEPENDENCIES.cmake @@ -0,0 +1,18 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) +install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(TARGETS test_lib DESTINATION bas COMPONENT libs) +install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) + +set(CPACK_PACKAGE_NAME "dependencies") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake new file mode 100644 index 0000000..cf85dab --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake @@ -0,0 +1,13 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1 "dependencies*-applications.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") +set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm") +set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$") +set(EXPECTED_FILE_3 "dependencies*-headers.rpm") +set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") +set(EXPECTED_FILE_4 "dependencies*-libs.rpm") +set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") +set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm") +set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake new file mode 100644 index 0000000..fec8889 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake @@ -0,0 +1,45 @@ +function(checkDependencies_ FILE TYPE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_DEPENDENCIES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() +endfunction() + +# TODO add tests for what should not be present in lists +checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") +checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") +checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") +checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") +checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") + +checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") +checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") +checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") +checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") +checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") + +checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") +checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") +checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake new file mode 100644 index 0000000..2cdfece --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake @@ -0,0 +1,22 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") + +# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild +# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 +set(CPACK_RPM_PACKAGE_AUTOREQ "no") +set(CPACK_RPM_PACKAGE_AUTOPROV "no") +set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes") +set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes") + +set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") +set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers") + +set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") +set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers") + +set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") +set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib") +set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 97ef238..3e5714d 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -7,3 +7,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") run_cpack_test(MINIMAL "RPM;DEB" false) run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) run_cpack_test(DEB_EXTRA "DEB" false) +run_cpack_test(DEPENDENCIES "RPM;DEB" true) -- cgit v0.12 From 35aab9df9f299d62edaa6ce611aa30614deb9e9d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Aug 2015 15:28:41 -0400 Subject: Reject TARGET_PDB_FILE for imported targets instead of crashing Reported-by: Justin Borodinsky --- Source/cmGeneratorExpressionNode.cxx | 7 +++++++ Source/cmGeneratorTarget.cxx | 1 + .../GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt | 1 + .../GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt | 8 ++++++++ .../GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake | 2 ++ Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake | 1 + 6 files changed, 20 insertions(+) create mode 100644 Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt create mode 100644 Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a86c2bc..44a9adb 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1600,6 +1600,13 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { + if (target->IsImported()) + { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_PDB_FILE not allowed for IMPORTED targets."); + return std::string(); + } + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..e490368 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,6 +1248,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, UNORDERED_SET languages; cmTarget::LinkImplementation const* impl = this->Target->GetLinkImplementation(config); + assert(impl); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt new file mode 100644 index 0000000..d915ecb --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ImportedTarget-TARGET_PDB_FILE.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$ + + TARGET_PDB_FILE not allowed for IMPORTED targets. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake new file mode 100644 index 0000000..c55c5d5 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE.cmake @@ -0,0 +1,2 @@ +add_library(empty UNKNOWN IMPORTED) +add_custom_target(custom COMMAND echo $) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 1c8fab5..cba3941 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -26,6 +26,7 @@ run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) run_cmake(NonValidTarget-TARGET_PDB_FILE) run_cmake(ValidTarget-TARGET_PDB_FILE) -- cgit v0.12 From afeb4eb243e01df5c7396dc346f2629b21115e2c Mon Sep 17 00:00:00 2001 From: James Johnston Date: Wed, 5 Aug 2015 21:23:07 +0000 Subject: nmake/jom: Only warn about bad VS environment if compiler not found. nmake and jom generators no longer warn about missing INCLUDE/LIB environment variables unless the C/CXX compiler cannot be found. This is useful if the user does not want to use these generators with the Visual C++ compiler, or they do not want to enable any language. --- Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalJOMMakefileGenerator.cxx | 28 +++++++++-------- Source/cmGlobalJOMMakefileGenerator.h | 3 ++ Source/cmGlobalNMakeMakefileGenerator.cxx | 28 +++++++++-------- Source/cmGlobalNMakeMakefileGenerator.h | 3 ++ .../CompilerNotFound/BadCompilerC-stderr-JOM.txt | 17 +++++++++++ .../CompilerNotFound/BadCompilerC-stderr-NMake.txt | 17 +++++++++++ .../CompilerNotFound/BadCompilerCXX-stderr-JOM.txt | 17 +++++++++++ .../BadCompilerCXX-stderr-NMake.txt | 17 +++++++++++ .../BadCompilerCandCXX-stderr-JOM.txt | 35 ++++++++++++++++++++++ .../BadCompilerCandCXX-stderr-NMake.txt | 35 ++++++++++++++++++++++ Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake | 14 +++++++++ 12 files changed, 192 insertions(+), 26 deletions(-) create mode 100644 Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt create mode 100644 Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt create mode 100644 Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt create mode 100644 Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt create mode 100644 Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt create mode 100644 Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..ec916ae 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -374,6 +374,8 @@ protected: void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); + virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; virtual bool ComputeTargetDepends(); @@ -462,8 +464,6 @@ private: virtual void ForceLinkerLanguages(); - virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, - const char* envVar) const; void CheckCompilerIdCompatibility(cmMakefile* mf, std::string const& lang) const; diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 50e7053..3f33f91 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -36,18 +36,6 @@ void cmGlobalJOMMakefileGenerator // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - if(!(cmSystemTools::GetEnv("INCLUDE") && - cmSystemTools::GetEnv("LIB")) - ) - { - std::string message = "To use the JOM generator, cmake must be run " - "from a shell that can use the compiler cl from the command line. " - "This environment does not contain INCLUDE, LIB, or LIBPATH, and " - "these must be set for the cl compiler to work. "; - mf->IssueMessage(cmake::WARNING, - message); - } - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } @@ -58,3 +46,19 @@ void cmGlobalJOMMakefileGenerator entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Brief = "Generates JOM makefiles."; } + +//---------------------------------------------------------------------------- +void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os, + std::string const& lang, + const char* envVar) const +{ + if(lang == "CXX" || lang == "C") + { + os << + "To use the JOM generator with Visual C++, cmake must be run from a " + "shell that can use the compiler cl from the command line. This " + "environment is unable to invoke the cl compiler. To fix this problem, " + "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n"; + } + this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); +} diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 2185b23..1869fed 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -42,6 +42,9 @@ public: */ virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); +private: + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; }; #endif diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 4219c34..7c570a6 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -36,18 +36,6 @@ void cmGlobalNMakeMakefileGenerator // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - if(!(cmSystemTools::GetEnv("INCLUDE") && - cmSystemTools::GetEnv("LIB")) - ) - { - std::string message = "To use the NMake generator, cmake must be run " - "from a shell that can use the compiler cl from the command line. " - "This environment does not contain INCLUDE, LIB, or LIBPATH, and " - "these must be set for the cl compiler to work. "; - mf->IssueMessage(cmake::WARNING, - message); - } - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } @@ -58,3 +46,19 @@ void cmGlobalNMakeMakefileGenerator entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Brief = "Generates NMake makefiles."; } + +//---------------------------------------------------------------------------- +void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(std::ostream& os, + std::string const& lang, + const char* envVar) const +{ + if(lang == "CXX" || lang == "C") + { + os << + "To use the NMake generator with Visual C++, cmake must be run from a " + "shell that can use the compiler cl from the command line. This " + "environment is unable to invoke the cl compiler. To fix this problem, " + "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n"; + } + this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); +} diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index dd72c49..3c8375a 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -40,6 +40,9 @@ public: */ virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); +private: + void PrintCompilerAdvice(std::ostream& os, std::string const& lang, + const char* envVar) const; }; #endif diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt new file mode 100644 index 0000000..b7db7eb --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-JOM.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt new file mode 100644 index 0000000..03c5933 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerC-stderr-NMake.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerC.cmake:2 \(enable_language\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt new file mode 100644 index 0000000..4b42ea6 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-JOM.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt new file mode 100644 index 0000000..1bfcdcc --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCXX-stderr-NMake.txt @@ -0,0 +1,17 @@ +CMake Error at BadCompilerCXX.cmake:2 \(enable_language\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt new file mode 100644 index 0000000..f25a267 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-JOM.txt @@ -0,0 +1,35 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the JOM generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt new file mode 100644 index 0000000..ffcdce8 --- /dev/null +++ b/Tests/RunCMake/CompilerNotFound/BadCompilerCandCXX-stderr-NMake.txt @@ -0,0 +1,35 @@ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_C_COMPILER: + + no-C-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to + the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadCompilerCandCXX.cmake:3 \(project\): + The CMAKE_CXX_COMPILER: + + no-CXX-compiler + + is not a full path and was not found in the PATH. + + To use the NMake generator with Visual C\+\+, cmake must be run from a shell + that can use the compiler cl from the command line. This environment is + unable to invoke the cl compiler. To fix this problem, run cmake from the + Visual Studio Command Prompt \(vcvarsall.bat\). + + Tell CMake where to find the compiler by setting either the environment + variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path + to the compiler, or to the compiler name if it is in the PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake index 8b84f39..19d149c 100644 --- a/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerNotFound/RunCMakeTest.cmake @@ -4,6 +4,20 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") run_cmake(NoCompilerC-IDE) run_cmake(NoCompilerCXX-IDE) run_cmake(NoCompilerCandCXX-IDE) +elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles") + set(RunCMake-stderr-file BadCompilerC-stderr-NMake.txt) + run_cmake(BadCompilerC) + set(RunCMake-stderr-file BadCompilerCXX-stderr-NMake.txt) + run_cmake(BadCompilerCXX) + set(RunCMake-stderr-file BadCompilerCandCXX-stderr-NMake.txt) + run_cmake(BadCompilerCandCXX) +elseif(RunCMake_GENERATOR STREQUAL "NMake Makefiles JOM") + set(RunCMake-stderr-file BadCompilerC-stderr-JOM.txt) + run_cmake(BadCompilerC) + set(RunCMake-stderr-file BadCompilerCXX-stderr-JOM.txt) + run_cmake(BadCompilerCXX) + set(RunCMake-stderr-file BadCompilerCandCXX-stderr-JOM.txt) + run_cmake(BadCompilerCandCXX) else() run_cmake(BadCompilerC) run_cmake(BadCompilerCXX) -- cgit v0.12 From 772ca69f803a8f294d6e04f9e258becc35179233 Mon Sep 17 00:00:00 2001 From: James Johnston Date: Tue, 4 Aug 2015 23:47:38 -0400 Subject: get_filename_component: Tests now check for proper CACHE usage. The RunCMake.get_filename_component test was improved to assert that each test variable outputted by get_filename_component is or is not a cache variable, as per the particular test. Signed-off-by: James Johnston --- .../RunCMake/get_filename_component/CMakeLists.txt | 2 +- .../get_filename_component/KnownComponents.cmake | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/get_filename_component/CMakeLists.txt b/Tests/RunCMake/get_filename_component/CMakeLists.txt index 12cd3c7..74b3ff8 100644 --- a/Tests/RunCMake/get_filename_component/CMakeLists.txt +++ b/Tests/RunCMake/get_filename_component/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 9d7cf90..3f20e1a 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -1,9 +1,11 @@ +# Assertion macro macro(check desc actual expect) if(NOT "x${actual}" STREQUAL "x${expect}") message(SEND_ERROR "${desc}: got \"${actual}\", not \"${expect}\"") endif() endmacro() +# General test of all component types given an absolute path. set(filename "/path/to/filename.ext.in") set(expect_DIRECTORY "/path/to") set(expect_NAME "filename.ext.in") @@ -13,14 +15,19 @@ set(expect_PATH "/path/to") foreach(c DIRECTORY NAME EXT NAME_WE PATH) get_filename_component(actual_${c} "${filename}" ${c}) check("${c}" "${actual_${c}}" "${expect_${c}}") + list(APPEND non_cache_vars actual_${c}) endforeach() +# Test Windows paths with DIRECTORY component and an absolute Windows path. get_filename_component(test_slashes "c:\\path\\to\\filename.ext.in" DIRECTORY) check("DIRECTORY from backslashes" "${test_slashes}" "c:/path/to") +list(APPEND non_cache_vars test_slashes) get_filename_component(test_winroot "c:\\filename.ext.in" DIRECTORY) check("DIRECTORY in windows root" "${test_winroot}" "c:/") +list(APPEND non_cache_vars test_winroot) +# Test finding absolute paths. get_filename_component(test_absolute "/path/to/a/../filename.ext.in" ABSOLUTE) check("ABSOLUTE" "${test_absolute}" "/path/to/filename.ext.in") @@ -29,10 +36,36 @@ check("ABSOLUTE .. in root" "${test_absolute}" "/path/to/filename.ext.in") get_filename_component(test_absolute "c:/../path/to/filename.ext.in" ABSOLUTE) check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.in") +list(APPEND non_cache_vars test_absolute) + +# Test CACHE parameter for most component types. get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE) check("CACHE 1" "${test_cache}" "/path/to") +# Make sure that the existing CACHE entry from previous is honored: get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE) check("CACHE 2" "${test_cache}" "/path/to") unset(test_cache CACHE) get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE) check("CACHE 3" "${test_cache}" "/path/to/other") + +list(APPEND cache_vars test_cache) + +# Test that ONLY the expected cache variables were created. +get_cmake_property(current_cache_vars CACHE_VARIABLES) +get_cmake_property(current_vars VARIABLES) + +foreach(thisVar ${cache_vars}) + if(NOT thisVar IN_LIST current_cache_vars) + message(SEND_ERROR "${thisVar} expected in cache but was not found.") + endif() +endforeach() + +foreach(thisVar ${non_cache_vars}) + if(thisVar IN_LIST current_cache_vars) + message(SEND_ERROR "${thisVar} unexpectedly found in cache.") + endif() + if(NOT thisVar IN_LIST current_vars) + # Catch likely typo when appending to non_cache_vars: + message(SEND_ERROR "${thisVar} not found in regular variable list.") + endif() +endforeach() -- cgit v0.12 From 38ed5866ed212effe0217f193f728ee54ea7378b Mon Sep 17 00:00:00 2001 From: James Johnston Date: Wed, 5 Aug 2015 00:30:58 -0400 Subject: get_filename_component: Added initial tests for PROGRAM component. The RunCMake.get_filename_component test now tests basic functionality of the PROGRAM component argument of get_filename_component. Signed-off-by: James Johnston --- Tests/RunCMake/get_filename_component/KnownComponents.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 3f20e1a..1532792 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -38,6 +38,18 @@ check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext. list(APPEND non_cache_vars test_absolute) +# Test the PROGRAM component type. +get_filename_component(test_program_name "/ arg1 arg2" PROGRAM) +check("PROGRAM with no args output" "${test_program_name}" "/") + +get_filename_component(test_program_name "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_program_args) +check("PROGRAM with args output: name" "${test_program_name}" "/") +check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2") + +list(APPEND non_cache_vars test_program_name) +list(APPEND non_cache_vars test_program_args) + # Test CACHE parameter for most component types. get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE) check("CACHE 1" "${test_cache}" "/path/to") -- cgit v0.12 From d035e9687a2d28e2f64ec3a316f8abea57e49d63 Mon Sep 17 00:00:00 2001 From: James Johnston Date: Wed, 5 Aug 2015 00:33:59 -0400 Subject: get_filename_component: Fix bug where CACHE was ignored. If PROGRAM_ARGS is provided to get_filename_component, fix bug where the command failed to honor the CACHE argument. Added test cases to RunCMake.get_filename_component that fail when the bug is not fixed to prevent regressions. Signed-off-by: James Johnston --- Source/cmGetFilenameComponentCommand.cxx | 4 +-- .../get_filename_component/KnownComponents.cmake | 32 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 67f9f2d..13a9afb 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -24,7 +24,7 @@ bool cmGetFilenameComponentCommand // Check and see if the value has been stored in the cache // already, if so use that value - if(args.size() == 4 && args[3] == "CACHE") + if(args.size() >= 4 && args[args.size() - 1] == "CACHE") { const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) @@ -111,7 +111,7 @@ bool cmGetFilenameComponentCommand return false; } - if(args.size() == 4 && args[3] == "CACHE") + if(args.size() >= 4 && args[args.size() - 1] == "CACHE") { if(!programArgs.empty() && !storeArgs.empty()) { diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index 1532792..386109f 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -62,6 +62,38 @@ check("CACHE 3" "${test_cache}" "/path/to/other") list(APPEND cache_vars test_cache) +# Test the PROGRAM component type with CACHE specified. + +# 1. Make sure it makes a cache variable in the first place for basic usage: +get_filename_component(test_cache_program_name_1 "/ arg1 arg2" PROGRAM CACHE) +check("PROGRAM CACHE 1 with no args output" "${test_cache_program_name_1}" "/") +list(APPEND cache_vars test_cache_program_name_1) + +# 2. Set some existing cache variables & make sure the function returns them: +set(test_cache_program_name_2 DummyProgramName CACHE FILEPATH "") +get_filename_component(test_cache_program_name_2 "/ arg1 arg2" PROGRAM CACHE) +check("PROGRAM CACHE 2 with no args output" "${test_cache_program_name_2}" + "DummyProgramName") +list(APPEND cache_vars test_cache_program_name_2) + +# 3. Now test basic usage when PROGRAM_ARGS is used: +get_filename_component(test_cache_program_name_3 "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_cache_program_args_3 CACHE) +check("PROGRAM CACHE 3 name" "${test_cache_program_name_3}" "/") +check("PROGRAM CACHE 3 args" "${test_cache_program_args_3}" " arg1 arg2") +list(APPEND cache_vars test_cache_program_name_3) +list(APPEND cache_vars test_cache_program_args_3) + +# 4. Test that existing cache variables are returned when PROGRAM_ARGS is used: +set(test_cache_program_name_4 DummyPgm CACHE FILEPATH "") +set(test_cache_program_args_4 DummyArgs CACHE STRING "") +get_filename_component(test_cache_program_name_4 "/ arg1 arg2" PROGRAM + PROGRAM_ARGS test_cache_program_args_4 CACHE) +check("PROGRAM CACHE 4 name" "${test_cache_program_name_4}" "DummyPgm") +check("PROGRAM CACHE 4 args" "${test_cache_program_args_4}" "DummyArgs") +list(APPEND cache_vars test_cache_program_name_4) +list(APPEND cache_vars test_cache_program_name_4) + # Test that ONLY the expected cache variables were created. get_cmake_property(current_cache_vars CACHE_VARIABLES) get_cmake_property(current_vars VARIABLES) -- cgit v0.12 From dd11f72ced8a5a42ae0a1d7ca8a51b94e670a66f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 14:09:35 +0200 Subject: cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. --- Source/cmGlobalGenerator.cxx | 13 +++++++------ Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 10 ++++++---- Source/cmLocalNinjaGenerator.cxx | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..bc3c255 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2054,10 +2054,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget const& target) const + cmGeneratorTarget* target) const { - if(target.GetType() == cmTarget::INTERFACE_LIBRARY - || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target->GetType() == cmTarget::INTERFACE_LIBRARY + || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2066,7 +2066,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { // This target is included in its directory. Check whether the // directory is excluded. - return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator()); + return this->IsExcluded(root, target->GetLocalGenerator()); } } @@ -2127,15 +2127,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmTarget const& target = t->second; + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); clg = clg->GetParent()) { // This local generator includes the target. std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..608b59c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -391,7 +391,7 @@ protected: void FillProjectMap(); void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..47822b4 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -289,7 +289,7 @@ public: const std::vector& GetLocalGenerators() const { return LocalGenerators; } - bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 69747a4..76d059ee 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -821,7 +821,7 @@ cmGlobalUnixMakefileGenerator3 localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); @@ -889,7 +889,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..cf1be5c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -111,17 +111,19 @@ bool cmGlobalVisualStudioGenerator::Compute() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmTargets& targets = (*i)->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); + cmGeneratorTargetsType targets = + (*i)->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second.GetType() == cmTarget::GLOBAL_TARGET) + if (t->second->GetType() == cmTarget::GLOBAL_TARGET + || t->first->IsImported()) { continue; } if(!this->IsExcluded(gen[0], t->second)) { - allBuild->AddUtility(t->second.GetName()); + allBuild->AddUtility(t->second->GetName()); } } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..1822c97 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -90,7 +90,7 @@ void cmLocalNinjaGenerator::Generate() // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - *t->second->Target)) + t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } -- cgit v0.12 From 1689c91d8d7667426fdca694d801b6189f68d37e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 14:27:52 +0200 Subject: cmMakefile: Remove unused method. --- Source/cmMakefile.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 27e5bce..1c4da00 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -114,10 +114,6 @@ public: bool GetIsSourceFileTryCompile() const; - ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() const - { return this->LocalGenerator;} - /** * Help enforce global target name uniqueness. */ -- cgit v0.12 From 27252b2414f5034b16a447273e1f249fdf317b72 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 19:35:48 +0200 Subject: cmComputeLinkInformation: Simplify generator object access. --- Source/cmComputeLinkInformation.cxx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c3f36af..c16472e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -14,6 +14,7 @@ #include "cmComputeLinkDepends.h" #include "cmOrderDirectories.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -248,7 +249,8 @@ cmComputeLinkInformation // Store context information. this->Target = target; this->Makefile = this->Target->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = + this->Target->GetLocalGenerator()->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // Check whether to recognize OpenBSD-style library versioned names. @@ -540,9 +542,7 @@ bool cmComputeLinkInformation::Compute() i != wrongItems.end(); ++i) { cmTarget const* tgt = *i; - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -646,9 +646,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, if(tgt && tgt->IsLinkable()) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) { @@ -762,7 +760,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being @@ -1812,9 +1810,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target); std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); -- cgit v0.12 From d9da6ee29fe0267ed347860f24f21be647ac81e8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:49:49 +0200 Subject: cmLinkItem: Split to separate file. --- Source/CMakeLists.txt | 1 + Source/cmLinkItem.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ Source/cmTarget.h | 27 +-------------------------- 3 files changed, 49 insertions(+), 26 deletions(-) create mode 100644 Source/cmLinkItem.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 92fee8a..428b364 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -288,6 +288,7 @@ set(SRCS cmInstallDirectoryGenerator.h cmInstallDirectoryGenerator.cxx cmLinkedTree.h + cmLinkItem.h cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h new file mode 100644 index 0000000..da91ed1 --- /dev/null +++ b/Source/cmLinkItem.h @@ -0,0 +1,47 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2015 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. +============================================================================*/ + +#ifndef cmLinkItem_h +#define cmLinkItem_h + +#include "cmListFileCache.h" + +class cmTarget; + +// Basic information about each link item. +class cmLinkItem: public std::string +{ + typedef std::string std_string; +public: + cmLinkItem(): std_string(), Target(0) {} + cmLinkItem(const std_string& n, + cmTarget const* t): std_string(n), Target(t) {} + cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} + cmTarget const* Target; +}; + +class cmLinkImplItem: public cmLinkItem +{ +public: + cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} + cmLinkImplItem(std::string const& n, + cmTarget const* t, + cmListFileBacktrace const& bt, + bool fromGenex): + cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} + cmLinkImplItem(cmLinkImplItem const& r): + cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {} + cmListFileBacktrace Backtrace; + bool FromGenex; +}; + +#endif diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3fbdfd..c4f3817 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -16,6 +16,7 @@ #include "cmPropertyMap.h" #include "cmPolicies.h" #include "cmListFileCache.h" +#include "cmLinkItem.h" #include #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -52,32 +53,6 @@ class cmTarget; class cmGeneratorTarget; class cmTargetTraceDependencies; -// Basic information about each link item. -class cmLinkItem: public std::string -{ - typedef std::string std_string; -public: - cmLinkItem(): std_string(), Target(0) {} - cmLinkItem(const std_string& n, - cmTarget const* t): std_string(n), Target(t) {} - cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} - cmTarget const* Target; -}; -class cmLinkImplItem: public cmLinkItem -{ -public: - cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} - cmLinkImplItem(std::string const& n, - cmTarget const* t, - cmListFileBacktrace const& bt, - bool fromGenex): - cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} - cmLinkImplItem(cmLinkImplItem const& r): - cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {} - cmListFileBacktrace Backtrace; - bool FromGenex; -}; - class cmTargetInternals; class cmTargetInternalPointer { -- cgit v0.12 From 10040601a2e13cbb0653a20c55c1c696b5cacf29 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:55:46 +0200 Subject: cmLinkImplementationLibraries: Move to namespace scope. --- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmLinkItem.h | 12 ++++++++++++ Source/cmTarget.cxx | 12 ++++++------ Source/cmTarget.h | 17 +++-------------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a86c2bc..49f2515 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1120,7 +1120,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } else if(!interfacePropertyName.empty()) { - if(cmTarget::LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = target->GetLinkImplementationLibraries(context->Config)) { linkedTargetsContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..aed2c07 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1506,7 +1506,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( tgts.Done = true; std::set emitted; - cmTarget::LinkImplementationLibraries const* impl + cmLinkImplementationLibraries const* impl = this->Target->GetLinkImplementationLibraries(config); for(std::vector::const_iterator diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index da91ed1..a5427de 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -44,4 +44,16 @@ public: bool FromGenex; }; +/** The link implementation specifies the direct library + dependencies needed by the object files of the target. */ +struct cmLinkImplementationLibraries +{ + // Libraries linked directly in this configuration. + std::vector Libraries; + + // Libraries linked directly in other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1f8f07a..1d4313e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3381,7 +3381,7 @@ bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const { return false; } - if(LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config)) { return !impl->Libraries.empty(); @@ -4331,7 +4331,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // to the link implementation. { // The link implementation is the default link interface. - cmTarget::LinkImplementationLibraries const* impl = + cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); @@ -4431,7 +4431,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. - cmTarget::LinkImplementationLibraries const* + cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; @@ -4482,7 +4482,7 @@ void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) { - if(cmTarget::LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibraries(config)) { for (std::vector::const_iterator @@ -4532,14 +4532,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::LinkImplementationLibraries const* +cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const { return this->GetLinkImplementationLibrariesInternal(config, this); } //---------------------------------------------------------------------------- -cmTarget::LinkImplementationLibraries const* +cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c4f3817..c5918ba 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -268,18 +268,7 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - /** The link implementation specifies the direct library - dependencies needed by the object files of the target. */ - struct LinkImplementationLibraries - { - // Libraries linked directly in this configuration. - std::vector Libraries; - - // Libraries linked directly in other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - }; - struct LinkImplementation: public LinkImplementationLibraries + struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. std::vector Languages; @@ -287,7 +276,7 @@ public: LinkImplementation const* GetLinkImplementation(const std::string& config) const; - LinkImplementationLibraries const* + cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; cmTarget const* FindTargetToLink(std::string const& name) const; @@ -606,7 +595,7 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; - LinkImplementationLibraries const* + cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; -- cgit v0.12 From 32f131b0ca68bc88bbb32dbf03e76dfba24defe5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 19:42:31 +0200 Subject: cmGeneratorTarget: Prefer the local generator to access the global. --- Source/cmGeneratorTarget.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704..b19856d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -234,7 +234,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); } cmGeneratorTarget::~cmGeneratorTarget() @@ -1556,7 +1556,7 @@ cmTargetTraceDependencies { // Convenience. this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = target->GetLocalGenerator()->GetGlobalGenerator(); this->CurrentEntry = 0; // Queue all the source files already specified for the target. @@ -1944,8 +1944,7 @@ void cmGeneratorTarget::GenerateTargetManifest( { return; } - cmMakefile* mf = this->Target->GetMakefile(); - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); + cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); // Get the names. std::string name; -- cgit v0.12 From 193699376af09bd77875d4ddfd10c3feb13ecdd2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 19:44:31 +0200 Subject: cmGeneratorTarget: Port internal type to cmGeneratorTarget. --- Source/cmGeneratorTarget.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b19856d..e914cf6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -36,7 +36,7 @@ //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, - cmTarget *target, cmake *cm) + cmGeneratorTarget const* target, cmake *cm) { if(!badObjLib.empty()) { @@ -50,7 +50,7 @@ void reportBadObjLib(std::vector const& badObjLib, e << "but may contain only sources that compile, header files, and " "other files that would not affect linking of a normal library."; cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - target->GetBacktrace()); + target->Target->GetBacktrace()); } } @@ -133,14 +133,14 @@ struct TagVisitor { DataType& Data; std::vector BadObjLibFiles; - cmTarget *Target; + cmGeneratorTarget const* Target; cmGlobalGenerator *GlobalGenerator; cmsys::RegularExpression Header; bool IsObjLib; - TagVisitor(cmTarget *target, DataType& data) + TagVisitor(cmGeneratorTarget const* target, DataType& data) : Data(data), Target(target), - GlobalGenerator(target->GetMakefile()->GetGlobalGenerator()), + GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()), Header(CM_HEADER_REGEX), IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY) { @@ -362,7 +362,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, { \ std::vector sourceFiles; \ this->Target->GetSourceFiles(sourceFiles, config); \ - TagVisitor visitor(this->Target, data); \ + TagVisitor visitor(this, data); \ for(std::vector::const_iterator si = sourceFiles.begin(); \ si != sourceFiles.end(); ++si) \ { \ -- cgit v0.12 From 73e4df99cb4d63f5ea8babb40656a74305d77e12 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 20:21:22 +0200 Subject: cmGlobalGenerator: Store a container of cmMakefiles. For use at configure-time. --- Source/cmGlobalGenerator.cxx | 9 +++++++++ Source/cmGlobalGenerator.h | 4 ++++ Source/cmMakefile.cxx | 1 + 3 files changed, 14 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..749ab6e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1129,6 +1129,7 @@ void cmGlobalGenerator::Configure() // start with this directory cmLocalGenerator *lg = this->MakeLocalGenerator(); + this->Makefiles.push_back(lg->GetMakefile()); this->LocalGenerators.push_back(lg); // set the Start directories @@ -1599,6 +1600,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); + this->Makefiles.clear(); + cmDeleteAll(this->LocalGenerators); this->LocalGenerators.clear(); @@ -1929,6 +1932,12 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( } //---------------------------------------------------------------------------- +void cmGlobalGenerator::AddMakefile(cmMakefile *mf) +{ + this->Makefiles.push_back(mf); +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) { this->LocalGenerators.push_back(lg); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3402fbc..616011f 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -173,6 +173,8 @@ public: cmake *GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); + const std::vector& GetMakefiles() const { + return this->Makefiles;} const std::vector& GetLocalGenerators() const { return this->LocalGenerators;} @@ -184,6 +186,7 @@ public: void SetCurrentMakefile(cmMakefile* mf) {this->CurrentMakefile = mf;} + void AddMakefile(cmMakefile *mf); void AddLocalGenerator(cmLocalGenerator *lg); ///! Set an generator for an "external makefile based project" @@ -402,6 +405,7 @@ protected: std::string FindMakeProgramFile; std::string ConfiguredFilesPath; cmake *CMakeInstance; + std::vector Makefiles; std::vector LocalGenerators; cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 60a11e1..85bc493 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1857,6 +1857,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() ->MakeLocalGenerator(newSnapshot, this->LocalGenerator); + this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); this->GetGlobalGenerator()->AddLocalGenerator(lg2); cmMakefile* subMf = lg2->GetMakefile(); -- cgit v0.12 From 3dd6f0a5bc0b6457c82df0b980a8f6ac87d1a6f9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 13:15:47 +0200 Subject: cmake: Port configure-time code to cmMakefile. --- Source/cmake.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8c455b2..d1e6265 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1592,7 +1592,7 @@ int cmake::ActualConfigure() } } - cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmMakefile* mf=this->GlobalGenerator->GetMakefiles()[0]; if (mf->IsOn("CTEST_USE_LAUNCHERS") && !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) { -- cgit v0.12 From 204aecdf82aa583b213464411069de4c8d7af64b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 20:26:32 +0200 Subject: cmGlobalGenerator: Port configure-time code to cmMakefile. --- Source/cmGlobalGenerator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 749ab6e..5266b23 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2821,9 +2821,9 @@ cmGlobalGenerator::AddRuleHash(const std::vector& outputs, } // Shorten the output name (in expected use case). - cmLocalGenerator* lg = this->GetLocalGenerators()[0]; - std::string fname = lg->Convert(outputs[0], - cmLocalGenerator::HOME_OUTPUT); + cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot()); + std::string fname = converter.Convert( + outputs[0], cmLocalGenerator::HOME_OUTPUT); // Associate the hash with this output. this->RuleHashes[fname] = hash; -- cgit v0.12 From bc1097e3d9a2d9545db849f9eef657477d83509a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 13:18:30 +0200 Subject: cmExportLibraryDependenciesCommand: Port to cmMakefile. --- Source/cmExportLibraryDependenciesCommand.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index cb150a7..fde8fb1 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmExportLibraryDependenciesCommand.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" #include "cmake.h" #include "cmVersion.h" @@ -82,15 +81,14 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const // the project. cmake* cm = this->Makefile->GetCMakeInstance(); cmGlobalGenerator* global = cm->GetGlobalGenerator(); - const std::vector& locals = global->GetLocalGenerators(); + const std::vector& locals = global->GetMakefiles(); std::map libDepsOld; std::map libDepsNew; std::map libTypes; - for(std::vector::const_iterator i = locals.begin(); + for(std::vector::const_iterator i = locals.begin(); i != locals.end(); ++i) { - const cmLocalGenerator* gen = *i; - const cmTargets &tgts = gen->GetMakefile()->GetTargets(); + const cmTargets &tgts = (*i)->GetTargets(); for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { -- cgit v0.12 From f8be9ba9c258698ed88a7510cf2ba3335491f3da Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 12:13:41 +0200 Subject: cmGlobalGenerator: Base progress on Makefiles, not LocalGenerators. --- Source/cmGlobalGenerator.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5266b23..5787a9d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1148,9 +1148,9 @@ void cmGlobalGenerator::Configure() // update the cache entry for the number of local generators, this is used // for progress char num[100]; - sprintf(num,"%d",static_cast(this->LocalGenerators.size())); + sprintf(num,"%d",static_cast(this->Makefiles.size())); this->GetCMakeInstance()->AddCacheEntry - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num, + ("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", cmState::INTERNAL); // check for link libraries and include directories containing "NOTFOUND" @@ -1742,9 +1742,9 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, // take the bulk of the time, so try and guess some progress // by getting closer and closer to 100 without actually getting there. if (!this->CMakeInstance->GetState()->GetInitializedCacheValue - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS")) + ("CMAKE_NUMBER_OF_MAKEFILES")) { - // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set + // If CMAKE_NUMBER_OF_MAKEFILES is not set // we are in the first time progress and we have no // idea how long it will be. So, just move 1/10th of the way // there each time, and don't go over 95% @@ -1935,22 +1935,16 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( void cmGlobalGenerator::AddMakefile(cmMakefile *mf) { this->Makefiles.push_back(mf); -} - -//---------------------------------------------------------------------------- -void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) -{ - this->LocalGenerators.push_back(lg); // update progress // estimate how many lg there will be const char *numGenC = this->CMakeInstance->GetState()->GetInitializedCacheValue - ("CMAKE_NUMBER_OF_LOCAL_GENERATORS"); + ("CMAKE_NUMBER_OF_MAKEFILES"); if (!numGenC) { - // If CMAKE_NUMBER_OF_LOCAL_GENERATORS is not set + // If CMAKE_NUMBER_OF_MAKEFILES is not set // we are in the first time progress and we have no // idea how long it will be. So, just move half way // there each time, and don't go over 95% @@ -1965,7 +1959,7 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) } int numGen = atoi(numGenC); - float prog = 0.9f*static_cast(this->LocalGenerators.size())/ + float prog = 0.9f*static_cast(this->Makefiles.size())/ static_cast(numGen); if (prog > 0.9f) { @@ -1974,6 +1968,12 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) this->CMakeInstance->UpdateProgress("Configuring", prog); } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) +{ + this->LocalGenerators.push_back(lg); +} + void cmGlobalGenerator::AddInstallComponent(const char* component) { if(component && *component) -- cgit v0.12 From 19b546ef766acedfcc9e19541c71b6a56d7fe630 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 12:17:31 +0200 Subject: cmGlobalGenerator: Base final target property computation on Makefiles. --- Source/cmGlobalGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5787a9d..83bfe57 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1482,9 +1482,9 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) void cmGlobalGenerator::FinalizeTargetCompileInfo() { // Construct per-target generator information. - for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + for(unsigned int i=0; i < this->Makefiles.size(); ++i) { - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); + cmMakefile *mf = this->Makefiles[i]; const cmStringRange noconfig_compile_definitions = mf->GetCompileDefinitionsEntries(); -- cgit v0.12 From 56f0540b5183036b46babbfc9b9ec0979e54992f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 12:45:17 +0200 Subject: cmGlobalGenerator: Port Configure-time check to cmMakefile. This uses no generate-time state. --- Source/cmGlobalGenerator.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 83bfe57..98961d8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1641,11 +1641,11 @@ void cmGlobalGenerator::CheckLocalGenerators() // std::set notFoundMap; // after it is all done do a ConfigureFinalPass cmState* state = this->GetCMakeInstance()->GetState(); - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + for (unsigned int i = 0; i < this->Makefiles.size(); ++i) { - this->LocalGenerators[i]->GetMakefile()->ConfigureFinalPass(); + this->Makefiles[i]->ConfigureFinalPass(); cmTargets &targets = - this->LocalGenerators[i]->GetMakefile()->GetTargets(); + this->Makefiles[i]->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { @@ -1700,15 +1700,14 @@ void cmGlobalGenerator::CheckLocalGenerators() } std::string text = notFoundMap[varName]; text += "\n used as include directory in directory "; - text += this->LocalGenerators[i] - ->GetMakefile()->GetCurrentSourceDirectory(); + text += this->Makefiles[i]->GetCurrentSourceDirectory(); notFoundMap[varName] = text; } } } this->CMakeInstance->UpdateProgress ("Configuring", 0.9f+0.1f*(static_cast(i)+1.0f)/ - static_cast(this->LocalGenerators.size())); + static_cast(this->Makefiles.size())); } if(!notFoundMap.empty()) -- cgit v0.12 From 8f75ea3b5e0b43118a6ecba4dc11a583d287705c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 12:48:08 +0200 Subject: cmGlobalGenerator: Port global target creation to cmMakefile. --- Source/cmGlobalGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 98961d8..f96cf21 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2247,7 +2247,7 @@ inline std::string removeQuotes(const std::string& s) void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); + cmMakefile* mf = this->Makefiles[0]; const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); // CPack -- cgit v0.12 From c5b8841fd96727a290e148e8b5132f893f8b4d4e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 12:57:06 +0200 Subject: cmGlobalGenerator: Create global targets from cmMakefiles. --- Source/cmGlobalGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f96cf21..8645317 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1193,9 +1193,9 @@ void cmGlobalGenerator::Configure() cmTargets globalTargets; this->CreateDefaultGlobalTargets(&globalTargets); - for (i = 0; i < this->LocalGenerators.size(); ++i) + for (i = 0; i < this->Makefiles.size(); ++i) { - cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); + cmMakefile* mf = this->Makefiles[i]; cmTargets* targets = &(mf->GetTargets()); cmTargets::iterator tit; for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) -- cgit v0.12 From 5f66900e71fdc33b40c46bf8a87b35d88d280769 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 12:39:51 +0200 Subject: cmGlobalGenerator: Port Find API to cmMakefile. --- Source/cmGetDirectoryPropertyCommand.cxx | 7 ++----- Source/cmGetPropertyCommand.cxx | 9 ++------- Source/cmGlobalGenerator.cxx | 14 ++++++++++++++ Source/cmGlobalGenerator.h | 1 + Source/cmSetPropertyCommand.cxx | 10 ++-------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index c056d95..2558876 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -51,10 +51,8 @@ bool cmGetDirectoryPropertyCommand sd = cmSystemTools::CollapseFullPath(sd); // lookup the makefile from the directory name - cmLocalGenerator *lg = - this->Makefile->GetGlobalGenerator()-> - FindLocalGenerator(sd); - if (!lg) + dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd); + if (!dir) { this->SetError ("DIRECTORY argument provided but requested directory not found. " @@ -62,7 +60,6 @@ bool cmGetDirectoryPropertyCommand "it is valid but has not been processed yet."); return false; } - dir = lg->GetMakefile(); ++i; } diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 33d638b..4c42f53 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -262,13 +262,8 @@ bool cmGetPropertyCommand::HandleDirectoryMode() dir = cmSystemTools::CollapseFullPath(dir); // Lookup the generator. - if(cmLocalGenerator* lg = - (this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir))) - { - // Use the makefile for the directory found. - mf = lg->GetMakefile(); - } - else + mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir); + if (!mf) { // Could not find the directory. this->SetError diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8645317..1e2d091 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2160,6 +2160,20 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() } } +cmMakefile* +cmGlobalGenerator::FindMakefile(const std::string& start_dir) const +{ + for(std::vector::const_iterator it = + this->Makefiles.begin(); it != this->Makefiles.end(); ++it) + { + std::string sd = (*it)->GetCurrentSourceDirectory(); + if (sd == start_dir) + { + return *it; + } + } + return 0; +} ///! Find a local generator by its startdirectory cmLocalGenerator* diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 616011f..778d946 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -256,6 +256,7 @@ public: that is a framework. */ bool NameResolvesToFramework(const std::string& libname) const; + cmMakefile* FindMakefile(const std::string& start_dir) const; ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 31e460f..17ad475 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -205,14 +205,8 @@ bool cmSetPropertyCommand::HandleDirectoryMode() // The local generators are associated with collapsed paths. dir = cmSystemTools::CollapseFullPath(dir); - // Lookup the generator. - if(cmLocalGenerator* lg = - this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir)) - { - // Use the makefile for the directory found. - mf = lg->GetMakefile(); - } - else + mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir); + if (!mf) { // Could not find the directory. this->SetError -- cgit v0.12 From 6d8a125e4988d5cb269b3d1e29a6114ecd0c47a4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 20:39:24 +0200 Subject: cmQtAutoGenerators: Prefer a generator to access global generator. --- Source/cmQtAutoGenerators.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..c619cdc 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -369,7 +369,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, #if defined(_WIN32) && !defined(__CYGWIN__) bool usePRE_BUILD = false; - cmGlobalGenerator* gg = makefile->GetGlobalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); if(gg->GetName().find("Visual Studio") != std::string::npos) { cmGlobalVisualStudioGenerator* vsgg = @@ -396,7 +396,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, std::vector rcc_output; bool const isNinja = - makefile->GetGlobalGenerator()->GetName() == "Ninja"; + lg->GetGlobalGenerator()->GetName() == "Ninja"; if(isNinja #if defined(_WIN32) && !defined(__CYGWIN__) || usePRE_BUILD -- cgit v0.12 From 3cefadbff07d68c5a6846835ea87cc35eae55a0b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 7 Aug 2015 00:01:07 -0400 Subject: 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 c9fec35..533a881 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150806) +set(CMake_VERSION_PATCH 20150807) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 7568199b4de18ed56ad8ef735c145c4a44327355 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:22:30 +0200 Subject: cmTarget: Request only the link libraries where needed. --- Source/cmTarget.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1d4313e..7b25819 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2099,7 +2099,8 @@ cmTarget::GetIncludeDirectories(const std::string& config, if(this->Makefile->IsOn("APPLE")) { - LinkImplementation const* impl = this->GetLinkImplementation(config); + cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config); for(std::vector::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) -- cgit v0.12 From 1f54bc1cf35707a5f1410ff4c6632d7cba351c40 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 20:25:02 +0200 Subject: cmTarget: Split storage of include directories from genexes. --- Source/cmGlobalGenerator.cxx | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 1 + Source/cmGlobalXCodeGenerator.cxx | 2 + Source/cmQtAutoGenerators.cxx | 2 + Source/cmTarget.cxx | 77 ++++++++++++++++++++----------- Source/cmTarget.h | 2 + 7 files changed, 60 insertions(+), 26 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff..50e2cd9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d5a5585..51dcab0 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a..b69fc65 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5006828..39933cb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f4..ce806ba 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7b25819..1eb8e6a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,7 +168,9 @@ public: const cmsys::auto_ptr ge; cmLinkImplItem const& LinkImplItem; }; - std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; @@ -366,13 +368,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentIncludesBts = this->Makefile->GetIncludeDirectoriesBacktraces(); - cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); - for (cmStringRange::const_iterator it - = parentIncludes.begin(); - it != parentIncludes.end(); ++it, ++btIt) - { - this->InsertInclude(*it, *btIt); - } + this->Internal->IncludeDirectoriesEntries.insert( + this->Internal->IncludeDirectoriesEntries.end(), + parentIncludes.begin(), parentIncludes.end()); + this->Internal->IncludeDirectoriesBacktraces.insert( + this->Internal->IncludeDirectoriesBacktraces.end(), + parentIncludesBts.begin(), parentIncludesBts.end()); + const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); @@ -384,7 +386,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - btIt = parentOptionsBts.begin(); + cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); for (cmStringRange::const_iterator it = parentOptions.begin(); it != parentOptions.end(); ++it, ++btIt) @@ -438,6 +440,29 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } +void CreatePropertyGeneratorExpressions( + std::vector const& entries, + std::vector const& backtraces, + std::vector& items) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1666,12 +1691,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.clear(); + this->Internal->IncludeDirectoriesBacktraces.clear(); + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->IncludeDirectoriesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1764,10 +1788,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1887,14 +1910,16 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->IncludeDirectoriesEntries.begin() + : this->Internal->IncludeDirectoriesEntries.end(); - std::vector::iterator position - = before ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->IncludeDirectoriesBacktraces.begin() + : this->Internal->IncludeDirectoriesBacktraces.end(); - this->Internal->IncludeDirectoriesEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->IncludeDirectoriesEntries.insert(position, entry); + this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2083,7 +2108,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, } processIncludeDirectories(this, - this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesItems, includes, uniqueIncludes, &dagChecker, @@ -2899,7 +2924,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); + output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_FEATURES) @@ -4805,7 +4830,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesEntries); + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c5918ba..490aaa3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,6 +132,8 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ -- cgit v0.12 From 772ecef4b8037d5ce59d24772c05829872aff406 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:19:00 +0200 Subject: cmTarget: Split storage of compile options from genexes. --- Source/cmTarget.cxx | 56 +++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1eb8e6a..09806e2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -171,7 +171,9 @@ public: std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector IncludeDirectoriesItems; - std::vector CompileOptionsEntries; + std::vector CompileOptionsEntries; + std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; std::vector SourceEntries; @@ -386,13 +388,12 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); - for (cmStringRange::const_iterator it - = parentOptions.begin(); - it != parentOptions.end(); ++it, ++btIt) - { - this->InsertCompileOption(*it, *btIt); - } + this->Internal->CompileOptionsEntries.insert( + this->Internal->CompileOptionsEntries.end(), + parentOptions.begin(), parentOptions.end()); + this->Internal->CompileOptionsBacktraces.insert( + this->Internal->CompileOptionsBacktraces.end(), + parentOptionsBts.begin(), parentOptionsBts.end()); } if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) @@ -461,6 +462,11 @@ void cmTarget::Compute() this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesBacktraces, this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); } //---------------------------------------------------------------------------- @@ -1699,12 +1705,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.clear(); + this->Internal->CompileOptionsBacktraces.clear(); + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileOptionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1794,10 +1799,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1927,14 +1931,16 @@ void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->CompileOptionsEntries.begin() + : this->Internal->CompileOptionsEntries.end(); - std::vector::iterator position - = before ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->CompileOptionsBacktraces.begin() + : this->Internal->CompileOptionsBacktraces.end(); - this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileOptionsEntries.insert(position, entry); + this->Internal->CompileOptionsBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2255,7 +2261,7 @@ void cmTarget::GetCompileOptions(std::vector &result, } processCompileOptions(this, - this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsItems, result, uniqueOptions, &dagChecker, @@ -2946,7 +2952,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileOptionsEntries); + output = cmJoin(this->Internal->CompileOptionsEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_DEFINITIONS) @@ -4831,7 +4837,7 @@ cmTargetInternalPointer cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); - cmDeleteAll(this->Pointer->CompileOptionsEntries); + cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); -- cgit v0.12 From 44e071aeff4d533f116a7721919f9036c5d5a1d1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:23:38 +0200 Subject: cmTarget: Split storage of compile features from genexes. --- Source/cmTarget.cxx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 09806e2..cc1df84 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -174,7 +174,9 @@ public: std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; - std::vector CompileFeaturesEntries; + std::vector CompileFeaturesEntries; + std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -467,6 +469,11 @@ void cmTarget::Compute() this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); } //---------------------------------------------------------------------------- @@ -1713,12 +1720,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.clear(); + this->Internal->CompileFeaturesBacktraces.clear(); + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileFeaturesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -1805,10 +1811,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -2433,7 +2438,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, } processCompileFeatures(this, - this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesItems, result, uniqueFeatures, &dagChecker, @@ -2941,7 +2946,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileFeaturesEntries); + output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_OPTIONS) @@ -4838,7 +4843,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); - cmDeleteAll(this->Pointer->CompileFeaturesEntries); + cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; -- cgit v0.12 From 197f4de110a59332757360110b1e90f6b07e1c97 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:30:17 +0200 Subject: cmTarget: Split storage of compile definitions from genexes. --- Source/cmTarget.cxx | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cc1df84..1277fc2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -177,7 +177,9 @@ public: std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; - std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -474,6 +476,11 @@ void cmTarget::Compute() this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); } //---------------------------------------------------------------------------- @@ -1728,12 +1735,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.clear(); + this->Internal->CompileDefinitionsBacktraces.clear(); + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileDefinitionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1817,10 +1823,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1952,10 +1957,8 @@ void cmTarget::InsertCompileOption(std::string const& entry, void cmTarget::InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt) { - cmGeneratorExpression ge(bt); - - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileDefinitionsEntries.push_back(entry); + this->Internal->CompileDefinitionsBacktraces.push_back(bt); } //---------------------------------------------------------------------------- @@ -2337,7 +2340,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } processCompileDefinitions(this, - this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsItems, list, uniqueOptions, &dagChecker, @@ -2745,22 +2748,6 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const } //---------------------------------------------------------------------------- -static void MakePropertyList(std::string& output, - std::vector const& values) -{ - output = ""; - std::string sep; - for (std::vector::const_iterator - it = values.begin(), end = values.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; - } -} - -//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, this->Makefile); @@ -2968,7 +2955,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileDefinitionsEntries); + output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); return output.c_str(); } else if (prop == propIMPORTED) @@ -4844,7 +4831,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); - cmDeleteAll(this->Pointer->CompileDefinitionsEntries); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } -- cgit v0.12 From 29886ce76482a8c857841015b58d1e91a9ee5c8e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 23:16:12 +0200 Subject: cmTarget: Use a simpler delete algorithm. This way, the methods can be moved without requiring a local algorithm. The containers use automatic storage. --- Source/cmTarget.cxx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1277fc2..d3170e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -191,14 +191,6 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; //---------------------------------------------------------------------------- -static void deleteAndClear( - std::vector &entries) -{ - cmDeleteAll(entries); - entries.clear(); -} - -//---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { } @@ -810,7 +802,7 @@ void cmTarget::GetSourceFiles(std::vector &files, this->LinkImplementationLanguageIsContextDependent = false; } - deleteAndClear(linkInterfaceSourcesEntries); + cmDeleteAll(linkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -2172,7 +2164,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, debugIncludes, language); - deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); return includes; } @@ -2293,7 +2285,7 @@ void cmTarget::GetCompileOptions(std::vector &result, debugOptions, language); - deleteAndClear(linkInterfaceCompileOptionsEntries); + cmDeleteAll(linkInterfaceCompileOptionsEntries); } //---------------------------------------------------------------------------- @@ -2395,7 +2387,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, debugDefines, language); - deleteAndClear(linkInterfaceCompileDefinitionsEntries); + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- @@ -2462,7 +2454,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, config, debugFeatures); - deleteAndClear(linkInterfaceCompileFeaturesEntries); + cmDeleteAll(linkInterfaceCompileFeaturesEntries); } //---------------------------------------------------------------------------- -- cgit v0.12 From 101ba25e6a2c177f9f3a81f3879a171256806756 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 8 Aug 2015 00:01:08 -0400 Subject: 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 533a881..e982b81 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150807) +set(CMake_VERSION_PATCH 20150808) #set(CMake_VERSION_RC 1) -- cgit v0.12 From b28b07db47b181718643399bd2aedc3e6d1b29c4 Mon Sep 17 00:00:00 2001 From: James Johnston Date: Sat, 8 Aug 2015 00:28:38 -0400 Subject: cmCTestCoverageHandle: Improve error handling. --- Source/CTest/cmCTestCoverageHandler.cxx | 33 +++++++++++++++++++++++++++------ Source/CTest/cmCTestCoverageHandler.h | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 6369e17..65599e0 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1474,7 +1474,12 @@ int cmCTestCoverageHandler::HandleLCovCoverage( << std::endl, this->Quiet); std::vector files; - this->FindLCovFiles(files); + if (!this->FindLCovFiles(files)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while finding LCov files.\n"); + return 0; + } std::vector::iterator it; if (files.empty()) @@ -1745,18 +1750,28 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector& files) } //---------------------------------------------------------------------------- -void cmCTestCoverageHandler::FindLCovFiles(std::vector& files) +bool cmCTestCoverageHandler::FindLCovFiles(std::vector& files) { cmsys::Glob gl; gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is // used while compiling. gl.RecurseThroughSymlinksOff(); std::string prevBinaryDir; - cmSystemTools::ChangeDirectory( - this->CTest->GetCTestConfiguration("BuildDirectory")); + std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory"); + if (cmSystemTools::ChangeDirectory(buildDir)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error changing directory to " << buildDir << std::endl); + return false; + } // Run profmerge to merge all *.dyn files into dpi files - cmSystemTools::RunSingleCommand("profmerge"); + if (!cmSystemTools::RunSingleCommand("profmerge")) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while running profmerge.\n"); + return false; + } prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str(); @@ -1766,10 +1781,16 @@ void cmCTestCoverageHandler::FindLCovFiles(std::vector& files) daGlob += "/*.dpi"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " looking for dpi files in: " << daGlob << std::endl, this->Quiet); - gl.FindFiles(daGlob); + if (!gl.FindFiles(daGlob)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while finding files matching " << daGlob << std::endl); + return false; + } files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Now searching in: " << daGlob << std::endl, this->Quiet); + return true; } //---------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 2ca123a..7102d1e 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -75,7 +75,7 @@ private: //! Handle coverage using Intel's LCov int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont); - void FindLCovFiles(std::vector& files); + bool FindLCovFiles(std::vector& files); //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); -- cgit v0.12 From 203b20df98512094cc74061fd1b76e87bd2d3afb Mon Sep 17 00:00:00 2001 From: James Johnston Date: Sat, 8 Aug 2015 01:06:27 -0400 Subject: cmcmd: Improve error handling when executing a process. --- Source/cmcmd.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 71f47f3..7bee0ea 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1468,18 +1468,24 @@ bool cmcmd::RunCommand(const char* comment, std::string output; int retCode =0; // use rc command to create .res file - cmSystemTools::RunSingleCommand(command, - &output, &output, - &retCode, 0, cmSystemTools::OUTPUT_NONE); + bool res = cmSystemTools::RunSingleCommand(command, + &output, &output, + &retCode, 0, + cmSystemTools::OUTPUT_NONE); // always print the output of the command, unless // it is the dumb rc command banner, but if the command // returned an error code then print the output anyway as // the banner may be mixed with some other important information. if(output.find("Resource Compiler Version") == output.npos - || retCode !=0) + || !res || retCode) { std::cout << output; } + if (!res) + { + std::cout << comment << " failed to run." << std::endl; + return false; + } // if retCodeOut is requested then always return true // and set the retCodeOut to retCode if(retCodeOut) @@ -1593,7 +1599,10 @@ int cmcmd::VisualStudioLinkIncremental(std::vector& args, mtCommand.push_back(tempManifest); // now run mt.exe to create the final manifest file int mtRet =0; - cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet); + if(!cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet)) + { + return -1; + } // if mt returns 0, then the manifest was not changed and // we do not need to do another link step if(mtRet == 0) -- cgit v0.12 From cf4bbf734ceee8cd67bf2ec1fbdb2d9bfedaf3e5 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 9 Aug 2015 00:01:05 -0400 Subject: 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 e982b81..ed7074b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150808) +set(CMake_VERSION_PATCH 20150809) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c5ac2b9df36a57d3b88e80a2d1c382d753faf2da Mon Sep 17 00:00:00 2001 From: James Johnston Date: Sat, 8 Aug 2015 20:04:08 +0000 Subject: Ninja: Centralized required Ninja version numbers and comparisons. --- Source/cmGlobalNinjaGenerator.cxx | 7 ++++--- Source/cmGlobalNinjaGenerator.h | 6 ++++-- Source/cmLocalNinjaGenerator.cxx | 12 +++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 088f0e1..b46d85c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1256,7 +1256,7 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const return "ninja"; } -std::string cmGlobalNinjaGenerator::ninjaVersion() const +std::string cmGlobalNinjaGenerator::CurrentNinjaVersion() const { std::string version; std::string command = ninjaCmd() + " --version"; @@ -1264,13 +1264,14 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const &version, 0, 0, 0, cmSystemTools::OUTPUT_NONE); - return version; + return cmSystemTools::TrimWhitespace(version); } bool cmGlobalNinjaGenerator::SupportsConsolePool() const { return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - ninjaVersion().c_str(), "1.5") == false; + CurrentNinjaVersion().c_str(), + RequiredNinjaVersionForConsolePool().c_str()) == false; } void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2a749c1..a1df1c2 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,8 +299,10 @@ public: virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; - std::string ninjaVersion() const; - + std::string CurrentNinjaVersion() const; + // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 + static std::string RequiredNinjaVersion() { return "1.3"; } + static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; } bool SupportsConsolePool() const; protected: diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9889bd4..aaad075 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -193,16 +193,14 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os) { // Default required version - // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 - std::string requiredVersion = "1.3"; + std::string requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersion(); // Ninja generator uses the 'console' pool if available (>= 1.5) - std::string usedVersion = this->GetGlobalNinjaGenerator()->ninjaVersion(); - if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - usedVersion.c_str(), - "1.5") == false) + if(this->GetGlobalNinjaGenerator()->SupportsConsolePool()) { - requiredVersion = "1.5"; + requiredVersion = + this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool(); } cmGlobalNinjaGenerator::WriteComment(os, -- cgit v0.12 From 874e70bc57f54e5fc898a169797a0b1e45df31f6 Mon Sep 17 00:00:00 2001 From: James Johnston Date: Sun, 9 Aug 2015 13:51:35 -0400 Subject: Ninja: Prevent generating if installed Ninja version is too old. --- Source/cmGlobalNinjaGenerator.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b46d85c..b92ad32 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -547,6 +547,18 @@ void cmGlobalNinjaGenerator // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { + // Check minimum Ninja version. + if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + CurrentNinjaVersion().c_str(), + RequiredNinjaVersion().c_str())) + { + std::ostringstream msg; + msg << "The detected version of Ninja (" << this->CurrentNinjaVersion(); + msg << ") is less than the version of Ninja required by CMake ("; + msg << this->RequiredNinjaVersion() << ")."; + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str()); + return; + } this->OpenBuildFileStream(); this->OpenRulesFileStream(); -- cgit v0.12 From 7979e25c8b9214a6a1097d5aa3937d6277556342 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 10 Aug 2015 00:01:09 -0400 Subject: 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 ed7074b..df17741 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150809) +set(CMake_VERSION_PATCH 20150810) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 4e3c7725d0d724d7a8a0e8305d15713e01b20503 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Aug 2015 13:26:52 -0400 Subject: bootstrap: Do not build Ninja generator The CMake bootstrap process uses Makefile generators so there is no need to build the Ninja generators during bootstrap. --- Source/cmake.cxx | 6 +++++- bootstrap | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8c455b2..0321f2c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -75,7 +75,9 @@ # include "cmGlobalWatcomWMakeGenerator.h" #endif #include "cmGlobalUnixMakefileGenerator3.h" -#include "cmGlobalNinjaGenerator.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +# include "cmGlobalNinjaGenerator.h" +#endif #include "cmExtraCodeLiteGenerator.h" #if !defined(CMAKE_BOOT_MINGW) @@ -1857,8 +1859,10 @@ void cmake::AddDefaultGenerators() #endif this->Generators.push_back( cmGlobalUnixMakefileGenerator3::NewFactory()); +#if defined(CMAKE_BUILD_WITH_CMAKE) this->Generators.push_back( cmGlobalNinjaGenerator::NewFactory()); +#endif #if defined(CMAKE_USE_WMAKE) this->Generators.push_back( cmGlobalWatcomWMakeGenerator::NewFactory()); diff --git a/bootstrap b/bootstrap index d778bbe..7b9a582 100755 --- a/bootstrap +++ b/bootstrap @@ -322,11 +322,6 @@ CMAKE_CXX_SOURCES="\ cmExprLexer \ cmExprParser \ cmExprParserHelper \ - cmGlobalNinjaGenerator \ - cmLocalNinjaGenerator \ - cmNinjaTargetGenerator \ - cmNinjaNormalTargetGenerator \ - cmNinjaUtilityTargetGenerator \ " if ${cmake_system_mingw}; then -- cgit v0.12 From 489ab9cb3aba79c9f3c1c08d3507b0e19e8ca9c0 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 11 Aug 2015 00:01:05 -0400 Subject: 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 df17741..40653ad 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150810) +set(CMake_VERSION_PATCH 20150811) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 5790aca4adfc21e9e042e93fa0dd290aab91be5c Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 9 Aug 2015 22:24:34 +0200 Subject: target_include_directories: Support relative SYSTEM include dirs (#15464) --- Source/cmTargetIncludeDirectoriesCommand.cxx | 20 ++++++++++++++++++-- .../SystemIncludeDirectories/CMakeLists.txt | 10 ++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 7824c89..7dfe9ca 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -75,7 +75,23 @@ bool cmTargetIncludeDirectoriesCommand tgt->InsertInclude(this->Join(content), lfbt, prepend); if (system) { - tgt->AddSystemIncludeDirectories(content); + std::string prefix = + this->Makefile->GetCurrentSourceDirectory() + std::string("/"); + std::set sdirs; + for (std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + if (cmSystemTools::FileIsFullPath(it->c_str()) + || cmGeneratorExpression::Find(*it) == 0) + { + sdirs.insert(*it); + } + else + { + sdirs.insert(prefix + *it); + } + } + tgt->AddSystemIncludeDirectories(sdirs); } return true; } @@ -91,7 +107,7 @@ void cmTargetIncludeDirectoriesCommand if (system) { - std::string joined = cmJoin(content, ";"); + std::string joined = this->Join(content); tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", joined.c_str()); } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index 0215e93..dcee85e 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -35,6 +35,16 @@ add_library(imported_consumer2 imported_consumer.cpp) target_link_libraries(imported_consumer2 imported_consumer) target_compile_options(imported_consumer2 PRIVATE -Werror=unused-variable) +# add a target which has a relative system include +add_library(somelib imported_consumer.cpp) +target_include_directories(somelib SYSTEM PUBLIC "systemlib_header_only") +target_compile_options(somelib PRIVATE -Werror=unused-variable) + +# add a target which consumes a relative system include +add_library(otherlib upstream.cpp) +target_link_libraries(otherlib PUBLIC somelib) +target_compile_options(somelib PRIVATE -Werror=unused-variable) + macro(do_try_compile error_option) set(TC_ARGS IFACE_TRY_COMPILE_${error_option} -- cgit v0.12 From 8c076a8bdba8c5bc77fc01b3fafafa100fb59657 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Mon, 10 Aug 2015 21:41:38 +0200 Subject: cmTarget: Remove unused AddSystemIncludeDirectories overload --- Source/cmTarget.cxx | 7 ------- Source/cmTarget.h | 1 - 2 files changed, 8 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..316d85c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1350,13 +1350,6 @@ cmTarget::AddSystemIncludeDirectories(const std::set &incs) this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); } -//---------------------------------------------------------------------------- -void -cmTarget::AddSystemIncludeDirectories(const std::vector &incs) -{ - this->SystemIncludeDirectories.insert(incs.begin(), incs.end()); -} - #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 490aaa3..2007b40 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -427,7 +427,6 @@ public: cmTarget::LinkLibraryType llt) const; void AddSystemIncludeDirectories(const std::set &incs); - void AddSystemIncludeDirectories(const std::vector &incs); std::set const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } -- cgit v0.12 From 8dc6cbcb248979a10ba96c9e7ce19fe18f009586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=2E=20Jo=C3=ABl=20Lamotte?= Date: Wed, 8 Jul 2015 02:18:38 +0200 Subject: FindProtobuf: Search x64 directories in VS-built protobuf source (#14833) Protobuf 2.6.x and lower do not use CMake (cmake is usable in Protobuf 3.x) but provide legacy Visual Studio projects files. Search their output directories in 64-bit builds. --- Modules/FindProtobuf.cmake | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index f01bd41..335c408 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -9,8 +9,9 @@ # ``PROTOBUF_SRC_ROOT_FOLDER`` # When compiling with MSVC, if this cache variable is set # the protobuf-default VS project build locations -# (vsprojects/Debug & vsprojects/Release) will be searched -# for libraries and binaries. +# (vsprojects/Debug and vsprojects/Release +# or vsprojects/x64/Debug and vsprojects/x64/Release) +# will be searched for libraries and binaries. # ``PROTOBUF_IMPORT_DIRS`` # List of additional directories to be searched for # imported .proto files. @@ -146,18 +147,22 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) set(${HDRS} ${${HDRS}} PARENT_SCOPE) endfunction() +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_PROTOBUF_ARCH_DIR x64/) +endif() + # Internal function: search for normal library as well as a debug one # if the debug one is specified also include debug/optimized keywords # in *_LIBRARIES variable function(_protobuf_find_libraries name filename) find_library(${name}_LIBRARY NAMES ${filename} - PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release) + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release) mark_as_advanced(${name}_LIBRARY) find_library(${name}_LIBRARY_DEBUG NAMES ${filename} - PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug) + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug) mark_as_advanced(${name}_LIBRARY_DEBUG) if(NOT ${name}_LIBRARY_DEBUG) @@ -234,8 +239,8 @@ find_program(PROTOBUF_PROTOC_EXECUTABLE NAMES protoc DOC "The Google Protocol Buffers Compiler" PATHS - ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release - ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug + ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release + ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug ) mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE) -- cgit v0.12 From 6a77a77a62f6bfb66cea622621d6d1b68e775664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=2E=20Jo=C3=ABl=20Lamotte?= Date: Tue, 11 Aug 2015 01:01:25 +0200 Subject: ExternalProject: Tell "hg clone" not to implicitly update By default Mercurial command "clone" will implicitly call "update" with the "default" branch after downloading the cloned repository. However ExternalProject_Add() always generates a second "update" command after cloning with a tag which is either specified or "tip" (equivalent to "default" by default). Therefore ExternalProject will first clone then update to default branch then update to another specified branch if provided. This leads to potentially very long clone operation (in particular when the repository default branch contain subrepos) which can lead to transaction abort triggered by the server. Simply use "hg clone -U" to avoid the implicit update during clone. Our following call to "hg update" will take care of updating anyway. --- Modules/ExternalProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index fdb146a..0fbf7c3 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -609,7 +609,7 @@ if(error_code) endif() execute_process( - COMMAND \"${hg_EXECUTABLE}\" clone \"${hg_repository}\" \"${src_name}\" + COMMAND \"${hg_EXECUTABLE}\" clone -U \"${hg_repository}\" \"${src_name}\" WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code ) -- cgit v0.12 From 48c6e7f2cfc95fc851cf9711d9588f3498e647c4 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Tue, 11 Aug 2015 09:52:51 +0200 Subject: CTest: Report to CDash the compiler version used to build the project The compiler version reported since commit v2.8.2~1018 (CTest-side support for compiler name and compiler version, 2009-10-12) only reported the version of the compiler used to build CMake, and only if it defined "_COMPILER_VERSION". Instead use the version of the compiler used to build the project CTest is testing. --- Modules/DartConfiguration.tcl.in | 1 + Source/cmCTest.cxx | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 918b407..2da8354 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -69,6 +69,7 @@ UpdateType: @UPDATE_TYPE@ # Compiler info Compiler: @CMAKE_CXX_COMPILER@ +CompilerVersion: @CMAKE_CXX_COMPILER_VERSION@ # Dynamic analysis (MemCheck) PurifyCommand: @PURIFYCOMMAND@ diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f65bd29..b976469 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1546,9 +1546,8 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append) xml.Attribute("Append", "true"); } xml.Attribute("CompilerName", this->GetCTestConfiguration("Compiler")); -#ifdef _COMPILER_VERSION - xml.Attribute("CompilerVersion", _COMPILER_VERSION); -#endif + xml.Attribute("CompilerVersion", + this->GetCTestConfiguration("CompilerVersion")); xml.Attribute("OSName", info.GetOSName()); xml.Attribute("Hostname", info.GetHostname()); xml.Attribute("OSRelease", info.GetOSRelease()); -- cgit v0.12 From 586b2e5e3633db1e1749dc2bdd69f6240b714139 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Aug 2015 14:06:09 -0400 Subject: Tests: Fix CMAKE_MAKE_PROGRAM selection in CMakeOnly tests Use the explicitly-tested make program, if any. --- Tests/CMakeOnly/Test.cmake.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index 8d3258b..0ae8af1 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -2,6 +2,11 @@ if (NOT TEST_SOURCE) set(TEST_SOURCE "${TEST}") endif () +set(make_program "@CMake_TEST_EXPLICIT_MAKE_PROGRAM@") +if(make_program) + set(maybe_make_program "-DCMAKE_MAKE_PROGRAM=${make_program}") +endif() + set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST_SOURCE}") set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") file(REMOVE_RECURSE "${binary_dir}") @@ -11,6 +16,7 @@ execute_process( "${source_dir}" -G "@CMAKE_GENERATOR@" -A "@CMAKE_GENERATOR_PLATFORM@" -T "@CMAKE_GENERATOR_TOOLSET@" + ${maybe_make_program} WORKING_DIRECTORY "${binary_dir}" RESULT_VARIABLE result ) -- cgit v0.12 From c180f0cbc224bf7f3fe9bcfdeea2d3c712c61084 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Aug 2015 14:09:22 -0400 Subject: Tests: Fix CMAKE_MAKE_PROGRAM selection in FortranC.Flags test Use the explicitly-tested make program, if any. --- Tests/FortranC/Flags.cmake.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in index 2300fc6..cf361a5 100644 --- a/Tests/FortranC/Flags.cmake.in +++ b/Tests/FortranC/Flags.cmake.in @@ -12,11 +12,17 @@ configure_file("${src}/test_opt.sh.in" "${bld}/fc.sh" @ONLY) set(ID) set(COMMAND) +set(make_program "@CMake_TEST_EXPLICIT_MAKE_PROGRAM@") +if(make_program) + set(maybe_make_program "-DCMAKE_MAKE_PROGRAM=${make_program}") +endif() + execute_process( WORKING_DIRECTORY "${bld}" COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@" -A "@CMAKE_GENERATOR_PLATFORM@" -T "@CMAKE_GENERATOR_TOOLSET@" + ${maybe_make_program} "-DFortranC_TEST_FLAGS=1" "-DCMAKE_C_COMPILER=${bld}/cc.sh" "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" -- cgit v0.12 From b583800203aea14aa03629bd27ad07d3f9440b17 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 12 Aug 2015 00:01:06 -0400 Subject: 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 40653ad..04813b0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150811) +set(CMake_VERSION_PATCH 20150812) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 50c9f521e2debce5beb538050fd12d802964a4b1 Mon Sep 17 00:00:00 2001 From: Christopher Meng Date: Wed, 12 Aug 2015 10:30:53 +0800 Subject: FindPkgConfig: Capitalize first letter of all message()s This makes FindPkgConfig output more formal and more consistent with many other messages produced by CMake. --- Modules/FindPkgConfig.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 53c17f1..526a62e 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -192,9 +192,9 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # give out status message telling checked module if (NOT ${_is_silent}) if (_pkg_check_modules_cnt EQUAL 1) - message(STATUS "checking for module '${_pkg_check_modules_list}'") + message(STATUS "Checking for module '${_pkg_check_modules_list}'") else() - message(STATUS "checking for modules '${_pkg_check_modules_list}'") + message(STATUS "Checking for modules '${_pkg_check_modules_list}'") endif() endif() @@ -327,7 +327,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # evaluate result and tell failures if (_pkgconfig_retval) if(NOT ${_is_silent}) - message(STATUS " package '${_pkg_check_modules_pkg}' not found") + message(STATUS " Package '${_pkg_check_modules_pkg}' not found") endif() set(_pkg_check_modules_failed 1) @@ -361,7 +361,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) if (NOT ${_is_silent}) - message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") endif () endforeach() @@ -529,7 +529,7 @@ macro(pkg_search_module _prefix _module0) _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) - message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + message(STATUS "Checking for one of the modules '${_pkg_modules_alt}'") endif () # iterate through all modules and stop at the first working one. -- cgit v0.12 From dc64d8250b686c26a557f58dfad46a0a2101299e Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 10 Aug 2015 13:21:40 -0400 Subject: HP-UX: Fix linker search type flags for C shared libs on HP-UX Since commit v2.8.7~31^2 (HP: Drive shared library linking with compiler front end, 2011-12-12) the C compiler is used to link shared libraries instead of calling the linker directly, so linker options need to be wrapped as -Wl,-foo instead of -foo. --- Modules/Platform/HP-UX.cmake | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 65cc731..581301b 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -33,18 +33,11 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES # Initialize C and CXX link type selection flags. These flags are # used when building a shared library, shared module, or executable # that links to other libraries to select whether to use the static or -# shared versions of the libraries. Note that C modules and shared -# libs are built using ld directly so we leave off the "-Wl," portion. -foreach(type SHARED_LIBRARY SHARED_MODULE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-a archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-a default") -endforeach() -foreach(type EXE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-a,default") -endforeach() +# shared versions of the libraries. foreach(type SHARED_LIBRARY SHARED_MODULE EXE) - set(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Wl,-a,default") + foreach(lang C CXX) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-a,archive") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,default") + endforeach() endforeach() -- cgit v0.12 From e36a05fd7f7d008c4c1e75ebf46eac3072ef71b1 Mon Sep 17 00:00:00 2001 From: Robert Goulet Date: Tue, 11 Aug 2015 15:18:39 -0400 Subject: cmTarget: Detect and diagnose recursion in GetOutputInfo --- Source/cmTarget.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d3170e4..d2d4c67 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -66,6 +66,8 @@ struct cmTarget::OutputInfo std::string OutDir; std::string ImpDir; std::string PdbDir; + bool empty() const + { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); } }; //---------------------------------------------------------------------------- @@ -2609,19 +2611,35 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( config_upper = cmSystemTools::UpperCase(config); } typedef cmTargetInternals::OutputInfoMapType OutputInfoMapType; - OutputInfoMapType::const_iterator i = + OutputInfoMapType::iterator i = this->Internal->OutputInfoMap.find(config_upper); if(i == this->Internal->OutputInfoMap.end()) { + // Add empty info in map to detect potential recursion. OutputInfo info; + OutputInfoMapType::value_type entry(config_upper, info); + i = this->Internal->OutputInfoMap.insert(entry).first; + + // Compute output directories. this->ComputeOutputDir(config, false, info.OutDir); this->ComputeOutputDir(config, true, info.ImpDir); if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } - OutputInfoMapType::value_type entry(config_upper, info); - i = this->Internal->OutputInfoMap.insert(entry).first; + + // Now update the previously-prepared map entry. + i->second = info; + } + else if(i->second.empty()) + { + // An empty map entry indicates we have been called recursively + // from the above block. + this->Makefile->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", + this->GetBacktrace()); + return 0; } return &i->second; } -- cgit v0.12 From d25819bc2623b5144ffc57b694500993ac5759b4 Mon Sep 17 00:00:00 2001 From: Robert Goulet Date: Tue, 11 Aug 2015 15:19:03 -0400 Subject: Add generator expression support to OUTPUT_DIRECTORY target properties If {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY is set with a genex then do not add the per-config subdirectory on multi-config generators. This will allow projects to use $ to place the per-config part of the directory path somewhere other than the end. --- Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst | 3 +++ Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst | 3 +++ Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst | 3 +++ Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt | 7 +++++-- Help/release/dev/OUTPUT_DIRECTORY-genex.rst | 7 +++++++ Source/cmTarget.cxx | 17 +++++++++++++-- Tests/ExportImport/Export/CMakeLists.txt | 17 +++++++++++++-- Tests/ExportImport/Export/testExe4.c | 24 ++++++++++++++++++++++ Tests/ExportImport/Import/A/CMakeLists.txt | 12 +++++++++++ Tests/ExportImport/Import/A/imp_testExe1.c | 3 ++- .../GeneratorExpression/RunCMakeTest.cmake | 1 + .../TARGET_FILE-recursion-result.txt | 1 + .../TARGET_FILE-recursion-stderr.txt | 4 ++++ .../TARGET_FILE-recursion.cmake | 3 +++ 14 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 Help/release/dev/OUTPUT_DIRECTORY-genex.rst create mode 100644 Tests/ExportImport/Export/testExe4.c create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake diff --git a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst index 29991eb..12f8bb7 100644 --- a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_ARCHIVE_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``ARCHIVE_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst index 6fc0142..28dd404 100644 --- a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_LIBRARY_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``LIBRARY_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst index c100346..94fb277 100644 --- a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY_` variable if it is set when a target is created. + +Contents of ``RUNTIME_OUTPUT_DIRECTORY_`` may use +:manual:`generator expressions `. diff --git a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt index 0b3d31c..3ae5448 100644 --- a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt +++ b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt @@ -1,8 +1,11 @@ Output directory in which to build |XXX| target files. This property specifies the directory into which |xxx| target files -should be built. Multi-configuration generators (VS, Xcode) append a -per-configuration subdirectory to the specified directory. +should be built. The property value may use +:manual:`generator expressions `. +Multi-configuration generators (VS, Xcode) append a per-configuration +subdirectory to the specified directory unless a generator expression +is used. This property is initialized by the value of the variable |CMAKE_XXX_OUTPUT_DIRECTORY| if it is set when a target is created. diff --git a/Help/release/dev/OUTPUT_DIRECTORY-genex.rst b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst new file mode 100644 index 0000000..8b839c0 --- /dev/null +++ b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst @@ -0,0 +1,7 @@ +OUTPUT_DIRECTORY-genex +---------------------- + +* The :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, + :prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and + :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target properties learned to + support :manual:`generator expressions `. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d2d4c67..a94c2dd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3520,7 +3520,10 @@ bool cmTarget::ComputeOutputDir(const std::string& config, if(const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - out = config_outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(config_outdir); + out = cge->Evaluate(this->Makefile, config); // Skip per-configuration subdirectory. conf = ""; @@ -3528,7 +3531,17 @@ bool cmTarget::ComputeOutputDir(const std::string& config, else if(const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - out = outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr cge = + ge.Parse(outdir); + out = cge->Evaluate(this->Makefile, config); + + // Skip per-configuration subdirectory if the value contained a + // generator expression. + if (out != outdir) + { + conf = ""; + } } else if(this->GetType() == cmTarget::EXECUTABLE) { diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index df3f178..7fdfaa8 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -105,6 +105,19 @@ target_link_libraries(testLib4 add_executable(testExe3 testExe3.c) set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) +# Test _OUTPUT_DIRECTORY[_] properties with generator expressions +add_executable(testExe4 testExe4.c) +target_link_libraries(testExe4 testExe1lib) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG testLib7D-$) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE testLib7R-$) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY testLib7-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG testLib5D-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE testLib5R-$) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY testLib5-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG testExe4D-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE testExe4R-$) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY testExe4-$) + # Test cyclic dependencies. add_library(testLibCycleA STATIC testLibCycleA1.c testLibCycleA2.c testLibCycleA3.c) @@ -450,7 +463,7 @@ install(FILES # Install and export from install tree. install( TARGETS - testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 + testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLib7 testLibCycleA testLibCycleB @@ -511,7 +524,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 NAMESPACE bld_ FILE ExportBuildTree.cmake ) -export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe2lib +export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibPerConfigDest diff --git a/Tests/ExportImport/Export/testExe4.c b/Tests/ExportImport/Export/testExe4.c new file mode 100644 index 0000000..731057e --- /dev/null +++ b/Tests/ExportImport/Export/testExe4.c @@ -0,0 +1,24 @@ +#include + +int main(int argc, const char* argv[]) +{ + if(argc < 2) + { + fprintf(stderr, "Must specify output file.\n"); + return 1; + } + { + FILE* f = fopen(argv[1], "w"); + if(f) + { + fprintf(f, "int generated_by_testExe4() { return 0; }\n"); + fclose(f); + } + else + { + fprintf(stderr, "Error writing to %s\n", argv[1]); + return 1; + } + } + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index a74bad1..0f56495 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -19,11 +19,17 @@ add_custom_command( COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c DEPENDS exp_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/exp_generated4.c + COMMAND exp_testExe4 ${Import_BINARY_DIR}/exp_generated4.c + DEPENDS exp_testExe4 + ) add_executable(imp_testExe1 imp_testExe1.c ${Import_BINARY_DIR}/exp_generated.c ${Import_BINARY_DIR}/exp_generated3.c + ${Import_BINARY_DIR}/exp_generated4.c ) # Try linking to a library imported from the install tree. @@ -53,11 +59,17 @@ add_custom_command( COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c DEPENDS bld_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/bld_generated4.c + COMMAND bld_testExe4 ${Import_BINARY_DIR}/bld_generated4.c + DEPENDS bld_testExe4 + ) add_executable(imp_testExe1b imp_testExe1.c ${Import_BINARY_DIR}/bld_generated.c ${Import_BINARY_DIR}/bld_generated3.c + ${Import_BINARY_DIR}/bld_generated4.c ) # Try linking to a library imported from the build tree. diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 56cdd2c..0a74309 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -1,5 +1,6 @@ extern int generated_by_testExe1(); extern int generated_by_testExe3(); +extern int generated_by_testExe4(); extern int testLib2(); extern int testLib3(); extern int testLib4(); @@ -24,5 +25,5 @@ int main() return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + testLib5() + testLib6() + testLib7() + testLibCycleA1() + testLibPerConfigDest() - + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); + + generated_by_testExe3() + generated_by_testExe4() + testLib4lib() + testLib4libcfg()); } diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index cba3941..21fc851 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -25,6 +25,7 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(TARGET_FILE-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt new file mode 100644 index 0000000..5b15526 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TARGET_FILE-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty1' OUTPUT_DIRECTORY depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake new file mode 100644 index 0000000..7633be1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $) -- cgit v0.12 From 706542615828488a5ad197d0ef3dd5e42eb739c4 Mon Sep 17 00:00:00 2001 From: Curl Upstream Date: Tue, 11 Aug 2015 20:13:01 +0200 Subject: curl 7.44.0 (reduced) Extract upstream curl using the following shell code. url=git://github.com/bagder/curl.git && v=7.44.0 && r=1a7f66a3 && paths=" CMake/* CMakeLists.txt COPYING include/curl/*.h include/curl/curlbuild.h.cmake lib/*.c lib/*.h lib/CMakeLists.txt lib/Makefile.inc lib/curl_config.h.cmake lib/libcurl.rc lib/vtls/*.c lib/vtls/*.h " && mkdir curl-$v-g$r-reduced && git clone $url curl-git && date=$(cd curl-git && git log -n 1 --format='%cd' $r) && (cd curl-git && git checkout $r && git archive --format=tar $r -- $paths) | (cd curl-$v-g$r-reduced && tar xv && rm lib/config-*.h) && echo "g$r date: $date" --- CMake/CurlCheckCSourceCompiles.cmake | 71 - CMake/CurlCheckCSourceRuns.cmake | 83 -- CMake/CurlTests.c | 316 +---- CMake/FindGSS.cmake | 289 ++++ CMake/Macros.cmake | 18 +- CMake/OtherTests.cmake | 204 ++- CMake/Platforms/WindowsCache.cmake | 2 +- CMakeLists.txt | 430 ++++-- COPYING | 2 +- include/curl/curl.h | 94 +- include/curl/curlver.h | 18 +- include/curl/mprintf.h | 9 +- include/curl/multi.h | 38 +- include/curl/typecheck-gcc.h | 2 + lib/CMakeLists.txt | 28 +- lib/Makefile.inc | 86 +- lib/amigaos.c | 4 +- lib/asyn-ares.c | 37 +- lib/asyn-thread.c | 45 +- lib/base64.c | 23 +- lib/bundles.c | 110 -- lib/bundles.h | 45 - lib/conncache.c | 179 ++- lib/conncache.h | 21 +- lib/connect.c | 227 ++-- lib/connect.h | 2 +- lib/cookie.c | 208 ++- lib/curl_addrinfo.c | 59 +- lib/curl_addrinfo.h | 4 + lib/curl_config.h.cmake | 12 +- lib/curl_des.c | 63 + lib/curl_des.h | 34 + lib/curl_endian.c | 236 ++++ lib/curl_endian.h | 70 + lib/curl_fnmatch.c | 7 +- lib/curl_gssapi.c | 53 +- lib/curl_gssapi.h | 19 +- lib/curl_md4.h | 12 +- lib/curl_memory.h | 3 + lib/curl_memrchr.c | 8 +- lib/curl_multibyte.c | 18 +- lib/curl_multibyte.h | 12 +- lib/curl_ntlm.c | 79 +- lib/curl_ntlm.h | 10 +- lib/curl_ntlm_core.c | 292 ++-- lib/curl_ntlm_core.h | 59 +- lib/curl_ntlm_msgs.c | 461 ++----- lib/curl_ntlm_msgs.h | 34 - lib/curl_ntlm_wb.c | 46 +- lib/curl_ntlm_wb.h | 7 +- lib/curl_printf.h | 56 + lib/curl_rtmp.c | 27 +- lib/curl_sasl.c | 1158 ++++++++++++++-- lib/curl_sasl.h | 164 ++- lib/curl_sasl_gssapi.c | 392 ++++++ lib/curl_sasl_sspi.c | 861 ++++++++++-- lib/curl_sec.h | 4 +- lib/curl_setup.h | 53 +- lib/curl_sspi.c | 30 +- lib/curl_sspi.h | 191 +-- lib/curl_threads.c | 15 +- lib/curl_threads.h | 9 +- lib/curlx.h | 5 +- lib/dict.c | 16 +- lib/easy.c | 180 +-- lib/escape.c | 28 +- lib/file.c | 63 +- lib/fileinfo.c | 6 +- lib/formdata.c | 127 +- lib/ftp.c | 305 +++-- lib/ftp.h | 11 +- lib/ftplistparser.c | 57 +- lib/getinfo.c | 55 +- lib/gopher.c | 16 +- lib/hash.c | 72 +- lib/hash.h | 10 +- lib/hmac.c | 6 +- lib/hostasyn.c | 24 +- lib/hostcheck.c | 7 +- lib/hostip.c | 287 ++-- lib/hostip.h | 22 +- lib/hostip4.c | 15 +- lib/hostip6.c | 17 +- lib/hostsyn.c | 6 +- lib/http.c | 378 +++--- lib/http.h | 64 +- lib/http2.c | 1184 +++++++++++----- lib/http2.h | 17 +- lib/http_chunks.c | 12 +- lib/http_digest.c | 549 +------- lib/http_digest.h | 21 +- lib/http_negotiate.c | 163 +-- lib/http_negotiate.h | 6 +- lib/http_negotiate_sspi.c | 118 +- lib/http_proxy.c | 64 +- lib/http_proxy.h | 7 +- lib/idn_win32.c | 29 +- lib/if2ip.c | 87 +- lib/if2ip.h | 13 +- lib/imap.c | 989 ++------------ lib/imap.h | 23 +- lib/inet_ntop.c | 3 +- lib/inet_ntop.h | 4 +- lib/krb5.c | 36 +- lib/ldap.c | 622 ++++++--- lib/md4.c | 502 +++---- lib/md5.c | 579 ++++---- lib/memdebug.c | 39 +- lib/memdebug.h | 20 +- lib/multi.c | 819 ++++++----- lib/multihandle.h | 52 +- lib/multiif.h | 22 +- lib/netrc.c | 20 +- lib/non-ascii.c | 55 +- lib/nwlib.c | 8 +- lib/openldap.c | 142 +- lib/parsedate.c | 2 +- lib/pingpong.c | 56 +- lib/pipeline.c | 119 +- lib/pipeline.h | 12 + lib/pop3.c | 972 ++----------- lib/pop3.h | 23 +- lib/progress.c | 6 +- lib/rtsp.c | 24 +- lib/security.c | 187 ++- lib/select.c | 12 +- lib/sendf.c | 218 +-- lib/sendf.h | 6 +- lib/setup-os400.h | 18 +- lib/setup-vms.h | 47 +- lib/share.c | 27 +- lib/share.h | 4 +- lib/slist.c | 4 +- lib/smb.c | 976 +++++++++++++ lib/smb.h | 271 ++++ lib/smtp.c | 1019 +++----------- lib/smtp.h | 23 +- lib/socks.c | 42 +- lib/socks_gssapi.c | 80 +- lib/socks_sspi.c | 59 +- lib/splay.c | 10 +- lib/ssh.c | 160 ++- lib/ssh.h | 36 +- lib/strdup.c | 33 +- lib/strdup.h | 3 +- lib/strerror.c | 38 +- lib/strtoofft.h | 11 +- lib/telnet.c | 165 ++- lib/tftp.c | 163 +-- lib/timeval.c | 12 +- lib/transfer.c | 145 +- lib/transfer.h | 5 +- lib/url.c | 744 ++++++---- lib/url.h | 6 +- lib/urldata.h | 162 ++- lib/version.c | 23 +- lib/vtls/axtls.c | 34 +- lib/vtls/axtls.h | 23 +- lib/vtls/curl_darwinssl.c | 2485 ---------------------------------- lib/vtls/curl_darwinssl.h | 77 -- lib/vtls/curl_schannel.c | 1346 ------------------ lib/vtls/curl_schannel.h | 137 -- lib/vtls/cyassl.c | 273 +++- lib/vtls/cyassl.h | 30 +- lib/vtls/darwinssl.c | 2484 +++++++++++++++++++++++++++++++++ lib/vtls/darwinssl.h | 76 ++ lib/vtls/gskit.c | 326 ++--- lib/vtls/gskit.h | 26 +- lib/vtls/gtls.c | 398 +++++- lib/vtls/gtls.h | 37 +- lib/vtls/nss.c | 599 ++++---- lib/vtls/nssg.h | 41 +- lib/vtls/openssl.c | 1091 +++++++++------ lib/vtls/openssl.h | 35 +- lib/vtls/polarssl.c | 197 +-- lib/vtls/polarssl.h | 26 +- lib/vtls/polarssl_threadlock.c | 5 +- lib/vtls/qssl.c | 527 ------- lib/vtls/qssl.h | 62 - lib/vtls/schannel.c | 1501 ++++++++++++++++++++ lib/vtls/schannel.h | 118 ++ lib/vtls/vtls.c | 355 ++++- lib/vtls/vtls.h | 55 +- lib/wildcard.c | 20 +- lib/x509asn1.c | 55 +- lib/x509asn1.h | 11 +- 186 files changed, 18453 insertions(+), 15051 deletions(-) delete mode 100644 CMake/CurlCheckCSourceCompiles.cmake delete mode 100644 CMake/CurlCheckCSourceRuns.cmake create mode 100644 CMake/FindGSS.cmake delete mode 100644 lib/bundles.c delete mode 100644 lib/bundles.h create mode 100644 lib/curl_des.c create mode 100644 lib/curl_des.h create mode 100644 lib/curl_endian.c create mode 100644 lib/curl_endian.h create mode 100644 lib/curl_printf.h create mode 100644 lib/curl_sasl_gssapi.c create mode 100644 lib/smb.c create mode 100644 lib/smb.h delete mode 100644 lib/vtls/curl_darwinssl.c delete mode 100644 lib/vtls/curl_darwinssl.h delete mode 100644 lib/vtls/curl_schannel.c delete mode 100644 lib/vtls/curl_schannel.h create mode 100644 lib/vtls/darwinssl.c create mode 100644 lib/vtls/darwinssl.h delete mode 100644 lib/vtls/qssl.c delete mode 100644 lib/vtls/qssl.h create mode 100644 lib/vtls/schannel.c create mode 100644 lib/vtls/schannel.h diff --git a/CMake/CurlCheckCSourceCompiles.cmake b/CMake/CurlCheckCSourceCompiles.cmake deleted file mode 100644 index c5d2bab..0000000 --- a/CMake/CurlCheckCSourceCompiles.cmake +++ /dev/null @@ -1,71 +0,0 @@ -# - Check if the source code provided in the SOURCE argument compiles. -# CURL_CHECK_C_SOURCE_COMPILES(SOURCE VAR) -# - macro which checks if the source code compiles -# SOURCE - source code to try to compile -# VAR - variable to store whether the source code compiled -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -macro(CURL_CHECK_C_SOURCE_COMPILES SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") - set(message "${VAR}") - # If the number of arguments is greater than 2 (SOURCE VAR) - if(${ARGC} GREATER 2) - # then add the third argument as a message - set(message "${ARGV2} (${VAR})") - endif() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - endif() - if(CMAKE_REQUIRED_INCLUDES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - endif() - set(src "") - foreach(def ${EXTRA_DEFINES}) - set(src "${src}#define ${def} 1\n") - endforeach(def) - foreach(inc ${HEADER_INCLUDES}) - set(src "${src}#include <${inc}>\n") - endforeach(inc) - - set(src "${src}\nint main() { ${SOURCE} ; return 0; }") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - IMMEDIATE) - message(STATUS "Performing Test ${message}") - try_compile(${VAR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - if(${VAR}) - set(${VAR} 1 CACHE INTERNAL "Test ${message}") - message(STATUS "Performing Test ${message} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${message} succeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${src}\n") - else() - message(STATUS "Performing Test ${message} - Failed") - set(${VAR} "" CACHE INTERNAL "Test ${message}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${message} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${src}\n") - endif() - endif() -endmacro() diff --git a/CMake/CurlCheckCSourceRuns.cmake b/CMake/CurlCheckCSourceRuns.cmake deleted file mode 100644 index 6b14af8..0000000 --- a/CMake/CurlCheckCSourceRuns.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# - Check if the source code provided in the SOURCE argument compiles and runs. -# CURL_CHECK_C_SOURCE_RUNS(SOURCE VAR) -# - macro which checks if the source code runs -# SOURCE - source code to try to compile -# VAR - variable to store size if the type exists. -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -macro(CURL_CHECK_C_SOURCE_RUNS SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") - set(message "${VAR}") - # If the number of arguments is greater than 2 (SOURCE VAR) - if(${ARGC} GREATER 2) - # then add the third argument as a message - set(message "${ARGV2} (${VAR})") - endif(${ARGC} GREATER 2) - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - else(CMAKE_REQUIRED_LIBRARIES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) - endif(CMAKE_REQUIRED_LIBRARIES) - if(CMAKE_REQUIRED_INCLUDES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - else(CMAKE_REQUIRED_INCLUDES) - set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) - endif(CMAKE_REQUIRED_INCLUDES) - set(src "") - foreach(def ${EXTRA_DEFINES}) - set(src "${src}#define ${def} 1\n") - endforeach(def) - foreach(inc ${HEADER_INCLUDES}) - set(src "${src}#include <${inc}>\n") - endforeach(inc) - - set(src "${src}\nint main() { ${SOURCE} ; return 0; }") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - IMMEDIATE) - message(STATUS "Performing Test ${message}") - try_run(${VAR} ${VAR}_COMPILED - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - # if it did not compile make the return value fail code of 1 - if(NOT ${VAR}_COMPILED) - set(${VAR} 1) - endif(NOT ${VAR}_COMPILED) - # if the return value was 0 then it worked - set(result_var ${${VAR}}) - if("${result_var}" EQUAL 0) - set(${VAR} 1 CACHE INTERNAL "Test ${message}") - message(STATUS "Performing Test ${message} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${message} succeded with the following output:\n" - "${OUTPUT}\n" - "Return value: ${${VAR}}\n" - "Source file was:\n${src}\n") - else("${result_var}" EQUAL 0) - message(STATUS "Performing Test ${message} - Failed") - set(${VAR} "" CACHE INTERNAL "Test ${message}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${message} failed with the following output:\n" - "${OUTPUT}\n" - "Return value: ${result_var}\n" - "Source file was:\n${src}\n") - endif("${result_var}" EQUAL 0) - endif("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") -endmacro(CURL_CHECK_C_SOURCE_RUNS) diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index 199871a..04d5e7e 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -71,264 +71,88 @@ main () } #endif -#ifdef HAVE_GETHOSTBYADDR_R_5 +/* tests for gethostbyaddr_r or gethostbyname_r */ +#if defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \ + defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \ + defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) +# define _REENTRANT + /* no idea whether _REENTRANT is always set, just invent a new flag */ +# define TEST_GETHOSTBYFOO_REENTRANT +#endif +#if defined(HAVE_GETHOSTBYADDR_R_5) || \ + defined(HAVE_GETHOSTBYADDR_R_7) || \ + defined(HAVE_GETHOSTBYADDR_R_8) || \ + defined(HAVE_GETHOSTBYNAME_R_3) || \ + defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(TEST_GETHOSTBYFOO_REENTRANT) #include #include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -struct hostent_data hdata; -int rc; -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -rc = gethostbyaddr_r(address, length, type, &h, &hdata); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_5_REENTRANT -#define _REENTRANT -#include -#include -int -main () -{ - -char * address; -int length;q -int type; -struct hostent h; -struct hostent_data hdata; -int rc; -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -rc = gethostbyaddr_r(address, length, type, &h, &hdata); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_7 -#include -#include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; - -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -hp = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &h_errnop); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_7_REENTRANT -#define _REENTRANT -#include -#include -int -main () +int main(void) { - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; - -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -hp = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &h_errnop); - ; - return 0; -} + char *address = "example.com"; + int length = 0; + int type = 0; + struct hostent h; + int rc = 0; +#if defined(HAVE_GETHOSTBYADDR_R_5) || \ + defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \ + \ + defined(HAVE_GETHOSTBYNAME_R_3) || \ + defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) + struct hostent_data hdata; +#elif defined(HAVE_GETHOSTBYADDR_R_7) || \ + defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \ + defined(HAVE_GETHOSTBYADDR_R_8) || \ + defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \ + \ + defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \ + defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) + char buffer[8192]; + int h_errnop; + struct hostent *hp; #endif -#ifdef HAVE_GETHOSTBYADDR_R_8 -#include -#include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; -int rc; - -#ifndef gethostbyaddr_r - (void)gethostbyaddr_r; -#endif -rc = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &hp, &h_errnop); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYADDR_R_8_REENTRANT -#define _REENTRANT -#include -#include -int -main () -{ - -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; -int rc; #ifndef gethostbyaddr_r (void)gethostbyaddr_r; #endif -rc = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &hp, &h_errnop); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_3 -#include -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ - -struct hostent_data data; -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_3_REENTRANT -#define _REENTRANT -#include -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ - -struct hostent_data data; -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_5 -#include -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_5_REENTRANT -#define _REENTRANT -#include -#include -#undef NULL -#define NULL (void *)0 -int -main () -{ - -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL); - ; +#if defined(HAVE_GETHOSTBYADDR_R_5) || \ + defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) + rc = gethostbyaddr_r(address, length, type, &h, &hdata); +#elif defined(HAVE_GETHOSTBYADDR_R_7) || \ + defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) + hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop); + (void)hp; +#elif defined(HAVE_GETHOSTBYADDR_R_8) || \ + defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) + rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop); +#endif + +#if defined(HAVE_GETHOSTBYNAME_R_3) || \ + defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) + rc = gethostbyname_r(address, &h, &hdata); +#elif defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) + rc = gethostbyname_r(address, &h, buffer, 8192, 0, &h_errnop); + (void)hp; /* not used for test */ +#elif defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) + rc = gethostbyname_r(address, &h, buffer, 8192, &hp, &h_errnop); +#endif + + (void)length; + (void)type; + (void)rc; return 0; } #endif -#ifdef HAVE_GETHOSTBYNAME_R_6 -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); - ; - return 0; -} -#endif -#ifdef HAVE_GETHOSTBYNAME_R_6_REENTRANT -#define _REENTRANT -#include -#include -#undef NULL -#define NULL (void *)0 - -int -main () -{ - -#ifndef gethostbyname_r - (void)gethostbyname_r; -#endif -gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL); - ; - return 0; -} -#endif #ifdef HAVE_SOCKLEN_T #ifdef _WIN32 #include diff --git a/CMake/FindGSS.cmake b/CMake/FindGSS.cmake new file mode 100644 index 0000000..dfaeaf3 --- /dev/null +++ b/CMake/FindGSS.cmake @@ -0,0 +1,289 @@ +# - Try to find the GSS Kerberos library +# Once done this will define +# +# GSS_ROOT_DIR - Set this variable to the root installation of GSS +# +# Read-Only variables: +# GSS_FOUND - system has the Heimdal library +# GSS_FLAVOUR - "MIT" or "Heimdal" if anything found. +# GSS_INCLUDE_DIR - the Heimdal include directory +# GSS_LIBRARIES - The libraries needed to use GSS +# GSS_LINK_DIRECTORIES - Directories to add to linker search path +# GSS_LINKER_FLAGS - Additional linker flags +# GSS_COMPILER_FLAGS - Additional compiler flags +# GSS_VERSION - This is set to version advertised by pkg-config or read from manifest. +# In case the library is found but no version info availabe it'll be set to "unknown" + +set(_MIT_MODNAME mit-krb5-gssapi) +set(_HEIMDAL_MODNAME heimdal-gssapi) + +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckTypeSize) + +set(_GSS_ROOT_HINTS + "${GSS_ROOT_DIR}" + "$ENV{GSS_ROOT_DIR}" +) + +# try to find library using system pkg-config if user didn't specify root dir +if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}") + if(UNIX) + find_package(PkgConfig QUIET) + pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME}) + list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}") + elseif(WIN32) + list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]") + endif() +endif() + +if(NOT _GSS_FOUND) #not found by pkg-config. Let's take more traditional approach. + find_file(_GSS_CONFIGURE_SCRIPT + NAMES + "krb5-config" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + ) + + # if not found in user-supplied directories, maybe system knows better + find_file(_GSS_CONFIGURE_SCRIPT + NAMES + "krb5-config" + PATH_SUFFIXES + bin + ) + + if(_GSS_CONFIGURE_SCRIPT) + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi" + OUTPUT_VARIABLE _GSS_CFLAGS + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) +message(STATUS "CFLAGS: ${_GSS_CFLAGS}") + if(NOT _GSS_CONFIGURE_FAILED) # 0 means success + # should also work in an odd case when multiple directories are given + string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS) + string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}") + string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}") + + foreach(_flag ${_GSS_CFLAGS}) + if(_flag MATCHES "^-I.*") + string(REGEX REPLACE "^-I" "" _val "${_flag}") + list(APPEND _GSS_INCLUDE_DIR "${_val}") + else() + list(APPEND _GSS_COMPILER_FLAGS "${_flag}") + endif() + endforeach() + endif() + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi" + OUTPUT_VARIABLE _GSS_LIB_FLAGS + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) +message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}") + if(NOT _GSS_CONFIGURE_FAILED) # 0 means success + # this script gives us libraries and link directories. Blah. We have to deal with it. + string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS) + string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") + string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") + + foreach(_flag ${_GSS_LIB_FLAGS}) + if(_flag MATCHES "^-l.*") + string(REGEX REPLACE "^-l" "" _val "${_flag}") + list(APPEND _GSS_LIBRARIES "${_val}") + elseif(_flag MATCHES "^-L.*") + string(REGEX REPLACE "^-L" "" _val "${_flag}") + list(APPEND _GSS_LINK_DIRECTORIES "${_val}") + else() + list(APPEND _GSS_LINKER_FLAGS "${_flag}") + endif() + endforeach() + endif() + + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version" + OUTPUT_VARIABLE _GSS_VERSION + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) + + # older versions may not have the "--version" parameter. In this case we just don't care. + if(_GSS_CONFIGURE_FAILED) + set(_GSS_VERSION 0) + endif() + + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor" + OUTPUT_VARIABLE _GSS_VENDOR + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) + + # older versions may not have the "--vendor" parameter. In this case we just don't care. + if(_GSS_CONFIGURE_FAILED) + set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter + else() + if(_GSS_VENDOR MATCHES ".*H|heimdal.*") + set(GSS_FLAVOUR "Heimdal") + else() + set(GSS_FLAVOUR "MIT") + endif() + endif() + + else() # either there is no config script or we are on platform that doesn't provide one (Windows?) + + find_path(_GSS_INCLUDE_DIR + NAMES + "gssapi/gssapi.h" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + include + inc + ) + + if(_GSS_INCLUDE_DIR) #jay, we've found something + set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}") + check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS) + + if(_GSS_HAVE_MIT_HEADERS) + set(GSS_FLAVOUR "MIT") + else() + # prevent compiling the header - just check if we can include it + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__") + check_include_file( "roken.h" _GSS_HAVE_ROKEN_H) + + check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H) + if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H) + set(GSS_FLAVOUR "Heimdal") + endif() + set(CMAKE_REQUIRED_DEFINITIONS "") + endif() + else() + # I'm not convienced if this is the right way but this is what autotools do at the moment + find_path(_GSS_INCLUDE_DIR + NAMES + "gssapi.h" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + include + inc + ) + + if(_GSS_INCLUDE_DIR) + set(GSS_FLAVOUR "Heimdal") + endif() + endif() + + # if we have headers, check if we can link libraries + if(GSS_FLAVOUR) + set(_GSS_LIBDIR_SUFFIXES "") + set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS}) + get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH) + list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT}) + + if(WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64") + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi64") + else() + set(_GSS_LIBNAME "libgssapi") + endif() + else() + list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386") + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi32") + else() + set(_GSS_LIBNAME "libgssapi") + endif() + endif() + else() + list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi_krb5") + else() + set(_GSS_LIBNAME "gssapi") + endif() + endif() + + find_library(_GSS_LIBRARIES + NAMES + ${_GSS_LIBNAME} + HINTS + ${_GSS_LIBDIR_HINTS} + PATH_SUFFIXES + ${_GSS_LIBDIR_SUFFIXES} + ) + + endif() + + endif() +else() + if(_GSS_PKG_${_MIT_MODNAME}_VERSION) + set(GSS_FLAVOUR "MIT") + set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION) + else() + set(GSS_FLAVOUR "Heimdal") + set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION) + endif() +endif() + +set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIR}) +set(GSS_LIBRARIES ${_GSS_LIBRARIES}) +set(GSS_LINK_DIRECTORIES ${_GSS_LINK_DIRECTORIES}) +set(GSS_LINKER_FLAGS ${_GSS_LINKER_FLAGS}) +set(GSS_COMPILER_FLAGS ${_GSS_COMPILER_FLAGS}) +set(GSS_VERSION ${_GSS_VERSION}) + +if(GSS_FLAVOUR) + + if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest") + else() + set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest") + endif() + + if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}") + file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str + REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$") + + string(REGEX MATCH "[0-9]\\.[^\"]+" + GSS_VERSION "${heimdal_version_str}") + endif() + + if(NOT GSS_VERSION) + set(GSS_VERSION "Heimdal Unknown") + endif() + elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT") + get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE) + if(WIN32 AND _MIT_VERSION) + set(GSS_VERSION "${_MIT_VERSION}") + else() + set(GSS_VERSION "MIT Unknown") + endif() + endif() +endif() + + +include(FindPackageHandleStandardArgs) + +set(_GSS_REQUIRED_VARS GSS_LIBRARIES GSS_FLAVOUR) + +find_package_handle_standard_args(GSS + REQUIRED_VARS + ${_GSS_REQUIRED_VARS} + VERSION_VAR + GSS_VERSION + FAIL_MESSAGE + "Could NOT find GSS, try to set the path to GSS root folder in the system variable GSS_ROOT_DIR" +) + +mark_as_advanced(GSS_INCLUDE_DIR GSS_LIBRARIES) diff --git a/CMake/Macros.cmake b/CMake/Macros.cmake index 80a8833..dab005f 100644 --- a/CMake/Macros.cmake +++ b/CMake/Macros.cmake @@ -1,7 +1,10 @@ #File defines convenience macros for available feature testing # This macro checks if the symbol exists in the library and if it -# does, it prepends library to the list. +# does, it prepends library to the list. It is intended to be called +# multiple times with a sequence of possibly dependent libraries in +# order of least-to-most-dependent. Some libraries depend on others +# to link correctly. macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}" ${VARIABLE}) @@ -11,8 +14,11 @@ macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) endmacro(CHECK_LIBRARY_EXISTS_CONCAT) # Check if header file exists and add it to the list. +# This macro is intended to be called multiple times with a sequence of +# possibly dependent header files. Some headers depend on others to be +# compiled correctly. macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) - check_include_file("${FILE}" ${VARIABLE}) + check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE}) if(${VARIABLE}) set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE}) set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}") @@ -21,7 +27,7 @@ endmacro(CHECK_INCLUDE_FILE_CONCAT) # For other curl specific tests, use this macro. macro(CURL_INTERNAL_TEST CURL_TEST) - if("${CURL_TEST}" MATCHES "^${CURL_TEST}$") + if(NOT DEFINED "${CURL_TEST}") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LIBRARIES) @@ -49,11 +55,11 @@ macro(CURL_INTERNAL_TEST CURL_TEST) "Performing Curl Test ${CURL_TEST} failed with the following output:\n" "${OUTPUT}\n") endif(${CURL_TEST}) - endif("${CURL_TEST}" MATCHES "^${CURL_TEST}$") + endif() endmacro(CURL_INTERNAL_TEST) macro(CURL_INTERNAL_TEST_RUN CURL_TEST) - if("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$") + if(NOT DEFINED "${CURL_TEST}_COMPILE") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LIBRARIES) @@ -85,5 +91,5 @@ macro(CURL_INTERNAL_TEST_RUN CURL_TEST) file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" "\n\n") endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) - endif("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$") + endif() endmacro(CURL_INTERNAL_TEST_RUN) diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake index 9cd5eac..4f07f22 100644 --- a/CMake/OtherTests.cmake +++ b/CMake/OtherTests.cmake @@ -1,15 +1,10 @@ -include(CurlCheckCSourceCompiles) -set(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2") -set(HEADER_INCLUDES) -set(headers_hack) +include(CheckCSourceCompiles) +# The begin of the sources (macros and includes) +set(_source_epilogue "#undef inline") macro(add_header_include check header) if(${check}) - set(headers_hack - "${headers_hack}\n#include <${header}>") - #SET(HEADER_INCLUDES - # ${HEADER_INCLUDES} - # "${header}") + set(_source_epilogue "${_source_epilogue}\n#include <${header}>") endif(${check}) endmacro(add_header_include) @@ -18,8 +13,8 @@ if(HAVE_WINDOWS_H) add_header_include(HAVE_WINDOWS_H "windows.h") add_header_include(HAVE_WINSOCK2_H "winsock2.h") add_header_include(HAVE_WINSOCK_H "winsock.h") - set(EXTRA_DEFINES ${EXTRA_DEFINES} - "__unused7\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#define __unused3") + set(_source_epilogue + "${_source_epilogue}\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif") set(signature_call_conv "PASCAL") if(HAVE_LIBWS2_32) set(CMAKE_REQUIRED_LIBRARIES ws2_32) @@ -29,14 +24,12 @@ else(HAVE_WINDOWS_H) add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h") endif(HAVE_WINDOWS_H) -set(EXTRA_DEFINES_BACKUP "${EXTRA_DEFINES}") -set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") -curl_check_c_source_compiles("recv(0, 0, 0, 0)" curl_cv_recv) +check_c_source_compiles("${_source_epilogue} +int main(void) { + recv(0, 0, 0, 0); + return 0; +}" curl_cv_recv) if(curl_cv_recv) - # AC_CACHE_CHECK([types of arguments and return type for recv], - #[curl_cv_func_recv_args], [ - #SET(curl_cv_func_recv_args "unknown") - #for recv_retv in 'int' 'ssize_t'; do if(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown") foreach(recv_retv "int" "ssize_t" ) foreach(recv_arg1 "int" "ssize_t" "SOCKET") @@ -44,17 +37,23 @@ if(curl_cv_recv) foreach(recv_arg3 "size_t" "int" "socklen_t" "unsigned int") foreach(recv_arg4 "int" "unsigned int") if(NOT curl_cv_func_recv_done) - set(curl_cv_func_recv_test "UNKNOWN") - set(extern_line "extern ${recv_retv} ${signature_call_conv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})\;") - set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") - curl_check_c_source_compiles(" + unset(curl_cv_func_recv_test CACHE) + check_c_source_compiles(" + ${_source_epilogue} + extern ${recv_retv} ${signature_call_conv} + recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4}); + int main(void) { ${recv_arg1} s=0; ${recv_arg2} buf=0; ${recv_arg3} len=0; ${recv_arg4} flags=0; - ${recv_retv} res = recv(s, buf, len, flags)" - curl_cv_func_recv_test - "${recv_retv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})") + ${recv_retv} res = recv(s, buf, len, flags); + (void) res; + return 0; + }" + curl_cv_func_recv_test) + message(STATUS + "Tested: ${recv_retv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})") if(curl_cv_func_recv_test) set(curl_cv_func_recv_args "${recv_arg1},${recv_arg2},${recv_arg3},${recv_arg4},${recv_retv}") @@ -72,18 +71,13 @@ if(curl_cv_recv) endforeach(recv_arg2) endforeach(recv_arg1) endforeach(recv_retv) - else(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown") + else() string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG3 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" RECV_TYPE_ARG4 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" RECV_TYPE_RETV "${curl_cv_func_recv_args}") - #MESSAGE("RECV_TYPE_ARG1 ${RECV_TYPE_ARG1}") - #MESSAGE("RECV_TYPE_ARG2 ${RECV_TYPE_ARG2}") - #MESSAGE("RECV_TYPE_ARG3 ${RECV_TYPE_ARG3}") - #MESSAGE("RECV_TYPE_ARG4 ${RECV_TYPE_ARG4}") - #MESSAGE("RECV_TYPE_RETV ${RECV_TYPE_RETV}") - endif(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown") + endif() if("${curl_cv_func_recv_args}" STREQUAL "unknown") message(FATAL_ERROR "Cannot find proper types to use for recv args") @@ -94,12 +88,12 @@ endif(curl_cv_recv) set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv") set(HAVE_RECV 1) -curl_check_c_source_compiles("send(0, 0, 0, 0)" curl_cv_send) +check_c_source_compiles("${_source_epilogue} +int main(void) { + send(0, 0, 0, 0); + return 0; +}" curl_cv_send) if(curl_cv_send) - # AC_CACHE_CHECK([types of arguments and return type for send], - #[curl_cv_func_send_args], [ - #SET(curl_cv_func_send_args "unknown") - #for send_retv in 'int' 'ssize_t'; do if(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown") foreach(send_retv "int" "ssize_t" ) foreach(send_arg1 "int" "ssize_t" "SOCKET") @@ -107,19 +101,24 @@ if(curl_cv_send) foreach(send_arg3 "size_t" "int" "socklen_t" "unsigned int") foreach(send_arg4 "int" "unsigned int") if(NOT curl_cv_func_send_done) - set(curl_cv_func_send_test "UNKNOWN") - set(extern_line "extern ${send_retv} ${signature_call_conv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})\;") - set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") - curl_check_c_source_compiles(" + unset(curl_cv_func_send_test CACHE) + check_c_source_compiles(" + ${_source_epilogue} + extern ${send_retv} ${signature_call_conv} + send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4}); + int main(void) { ${send_arg1} s=0; ${send_arg2} buf=0; ${send_arg3} len=0; ${send_arg4} flags=0; - ${send_retv} res = send(s, buf, len, flags)" - curl_cv_func_send_test - "${send_retv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})") + ${send_retv} res = send(s, buf, len, flags); + (void) res; + return 0; + }" + curl_cv_func_send_test) + message(STATUS + "Tested: ${send_retv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})") if(curl_cv_func_send_test) - #MESSAGE("Found arguments: ${curl_cv_func_send_test}") string(REGEX REPLACE "(const) .*" "\\1" send_qual_arg2 "${send_arg2}") string(REGEX REPLACE "const (.*)" "\\1" send_arg2 "${send_arg2}") set(curl_cv_func_send_args @@ -138,20 +137,14 @@ if(curl_cv_send) endforeach(send_arg2) endforeach(send_arg1) endforeach(send_retv) - else(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown") + else() string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG3 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG4 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" SEND_TYPE_RETV "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" SEND_QUAL_ARG2 "${curl_cv_func_send_args}") - #MESSAGE("SEND_TYPE_ARG1 ${SEND_TYPE_ARG1}") - #MESSAGE("SEND_TYPE_ARG2 ${SEND_TYPE_ARG2}") - #MESSAGE("SEND_TYPE_ARG3 ${SEND_TYPE_ARG3}") - #MESSAGE("SEND_TYPE_ARG4 ${SEND_TYPE_ARG4}") - #MESSAGE("SEND_TYPE_RETV ${SEND_TYPE_RETV}") - #MESSAGE("SEND_QUAL_ARG2 ${SEND_QUAL_ARG2}") - endif(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown") + endif() if("${curl_cv_func_send_args}" STREQUAL "unknown") message(FATAL_ERROR "Cannot find proper types to use for send args") @@ -163,88 +156,71 @@ endif(curl_cv_send) set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send") set(HAVE_SEND 1) -set(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5") -curl_check_c_source_compiles("int flag = MSG_NOSIGNAL" HAVE_MSG_NOSIGNAL) - -set(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2") -set(HEADER_INCLUDES) -set(headers_hack) +check_c_source_compiles("${_source_epilogue} + int main(void) { + int flag = MSG_NOSIGNAL; + (void)flag; + return 0; + }" HAVE_MSG_NOSIGNAL) -macro(add_header_include check header) - if(${check}) - set(headers_hack - "${headers_hack}\n#include <${header}>") - #SET(HEADER_INCLUDES - # ${HEADER_INCLUDES} - # "${header}") - endif(${check}) -endmacro(add_header_include header) - -if(HAVE_WINDOWS_H) - set(EXTRA_DEFINES ${EXTRA_DEFINES} - "__unused7\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#define __unused3") - add_header_include(HAVE_WINDOWS_H "windows.h") - add_header_include(HAVE_WINSOCK2_H "winsock2.h") - add_header_include(HAVE_WINSOCK_H "winsock.h") -else(HAVE_WINDOWS_H) - add_header_include(HAVE_SYS_TYPES_H "sys/types.h") +if(NOT HAVE_WINDOWS_H) add_header_include(HAVE_SYS_TIME_H "sys/time.h") add_header_include(TIME_WITH_SYS_TIME "time.h") add_header_include(HAVE_TIME_H "time.h") -endif(HAVE_WINDOWS_H) -set(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5") -curl_check_c_source_compiles("struct timeval ts;\nts.tv_sec = 0;\nts.tv_usec = 0" HAVE_STRUCT_TIMEVAL) - - -include(CurlCheckCSourceRuns) -set(EXTRA_DEFINES) -set(HEADER_INCLUDES) +endif() +check_c_source_compiles("${_source_epilogue} +int main(void) { + struct timeval ts; + ts.tv_sec = 0; + ts.tv_usec = 0; + (void)ts; + return 0; +}" HAVE_STRUCT_TIMEVAL) + + +include(CheckCSourceRuns) +set(CMAKE_REQUIRED_FLAGS) if(HAVE_SYS_POLL_H) - set(HEADER_INCLUDES "sys/poll.h") + set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H") endif(HAVE_SYS_POLL_H) -curl_check_c_source_runs("return poll((void *)0, 0, 10 /*ms*/)" HAVE_POLL_FINE) +check_c_source_runs(" + #ifdef HAVE_SYS_POLL_H + # include + #endif + int main(void) { + return poll((void *)0, 0, 10 /*ms*/); + }" HAVE_POLL_FINE) set(HAVE_SIG_ATOMIC_T 1) -set(EXTRA_DEFINES) -set(HEADER_INCLUDES) +set(CMAKE_REQUIRED_FLAGS) if(HAVE_SIGNAL_H) - set(HEADER_INCLUDES "signal.h") + set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H") set(CMAKE_EXTRA_INCLUDE_FILES "signal.h") endif(HAVE_SIGNAL_H) check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T) if(HAVE_SIZEOF_SIG_ATOMIC_T) - curl_check_c_source_compiles("static volatile sig_atomic_t dummy = 0" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) + check_c_source_compiles(" + #ifdef HAVE_SIGNAL_H + # include + #endif + int main(void) { + static volatile sig_atomic_t dummy = 0; + (void)dummy; + return 0; + }" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) set(HAVE_SIG_ATOMIC_T_VOLATILE 1) endif(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) endif(HAVE_SIZEOF_SIG_ATOMIC_T) -set(CHECK_TYPE_SIZE_PREINCLUDE - "#undef inline") - if(HAVE_WINDOWS_H) - set(CHECK_TYPE_SIZE_PREINCLUDE "${CHECK_TYPE_SIZE_PREINCLUDE} - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - #include ") - if(HAVE_WINSOCK2_H) - set(CHECK_TYPE_SIZE_PREINCLUDE "${CHECK_TYPE_SIZE_PREINCLUDE}\n#include ") - endif(HAVE_WINSOCK2_H) -else(HAVE_WINDOWS_H) + set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) +else() + set(CMAKE_EXTRA_INCLUDE_FILES) if(HAVE_SYS_SOCKET_H) - set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} - "sys/socket.h") + set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) endif(HAVE_SYS_SOCKET_H) - if(HAVE_NETINET_IN_H) - set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} - "netinet/in.h") - endif(HAVE_NETINET_IN_H) - if(HAVE_ARPA_INET_H) - set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} - "arpa/inet.h") - endif(HAVE_ARPA_INET_H) -endif(HAVE_WINDOWS_H) +endif() check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE) if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE) diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index 3533a54..6fc2991 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -5,6 +5,7 @@ if(NOT UNIX) set(HAVE_LIBSOCKET 0) set(NOT_NEED_LIBNSL 0) set(HAVE_LIBNSL 0) + set(HAVE_GETHOSTNAME 1) set(HAVE_LIBZ 0) set(HAVE_LIBCRYPTO 0) @@ -14,7 +15,6 @@ if(NOT UNIX) set(HAVE_ARPA_INET_H 0) set(HAVE_DLFCN_H 0) set(HAVE_FCNTL_H 1) - set(HAVE_FEATURES_H 0) set(HAVE_INTTYPES_H 0) set(HAVE_IO_H 1) set(HAVE_MALLOC_H 1) diff --git a/CMakeLists.txt b/CMakeLists.txt index 845c330..9a42cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -48,27 +48,17 @@ project( CURL C ) message(WARNING "the curl cmake build system is poorly maintained. Be aware") file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) -string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)" - LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS}) -string (REGEX MATCH "([0-9]+)" - LIBCURL_VERSION_MJ ${LIBCURL_VERSION_MJ}) -string (REGEX MATCH - "LIBCURL_VERSION_MINOR[ \t]+([0-9]+)" - LIBCURL_VERSION_MI ${CURL_VERSION_H_CONTENTS}) -string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_MI ${LIBCURL_VERSION_MI}) -string (REGEX MATCH - "LIBCURL_VERSION_PATCH[ \t]+([0-9]+)" - LIBCURL_VERSION_PT ${CURL_VERSION_H_CONTENTS}) -string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_PT ${LIBCURL_VERSION_PT}) -set (CURL_MAJOR_VERSION ${LIBCURL_VERSION_MJ}) -set (CURL_MINOR_VERSION ${LIBCURL_VERSION_MI}) -set (CURL_PATCH_VERSION ${LIBCURL_VERSION_PT}) +string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" + CURL_VERSION ${CURL_VERSION_H_CONTENTS}) +string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) +string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" + CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS}) +string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) include_regular_expression("^.*$") # Sukender: Is it necessary? # Setup package meta-data # SET(PACKAGE "curl") -set(CURL_VERSION ${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION}) message(STATUS "curl version=[${CURL_VERSION}]") # SET(PACKAGE_TARNAME "curl") # SET(PACKAGE_NAME "curl") @@ -84,12 +74,35 @@ include_directories( ${CURL_SOURCE_DIR}/include ) option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON) option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON) option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF) -option(CURL_USE_ARES "Set to ON to enable c-ares support" OFF) +option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) +option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF) + +option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF) +option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF) + +if (ENABLE_DEBUG) + # DEBUGBUILD will be defined only for Debug builds + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUGBUILD>) + else() + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUGBUILD) + endif() + set(ENABLE_CURLDEBUG ON) +endif() + +if (ENABLE_CURLDEBUG) + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG) +endif() + # initialize CURL_LIBS set(CURL_LIBS "") -if(CURL_USE_ARES) - set(USE_ARES ${CURL_USE_ARES}) +if(ENABLE_THREADED_RESOLVER AND ENABLE_ARES) + message(FATAL_ERROR "Options ENABLE_THREADED_RESOLVER and ENABLE_ARES are mutually exclusive") +endif() + +if(ENABLE_ARES) + set(USE_ARES 1) find_package(CARES REQUIRED) list(APPEND CURL_LIBS ${CARES_LIBRARY} ) set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY}) @@ -171,9 +184,52 @@ option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF) mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF) mark_as_advanced(DISABLED_THREADSAFE) -option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF) +option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) mark_as_advanced(ENABLE_IPV6) +if(ENABLE_IPV6) + include(CheckStructHasMember) + check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" + HAVE_SOCKADDR_IN6_SIN6_ADDR) + check_struct_has_member("struct sockaddr_in6" sin6_scope_id "netinet/in.h" + HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) + if(NOT HAVE_SOCKADDR_IN6_SIN6_ADDR) + message(WARNING "struct sockaddr_in6 not available, disabling IPv6 support") + # Force the feature off as this name is used as guard macro... + set(ENABLE_IPV6 OFF + CACHE BOOL "Define if you want to enable IPv6 support" FORCE) + endif() +endif() +option(ENABLE_MANUAL "to provide the built-in manual" ON) +unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars? +if(ENABLE_MANUAL) + find_program(NROFF NAMES gnroff nroff) + if(NROFF) + # Need a way to write to stdin, this will do + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test") + # Tests for a valid nroff option to generate a manpage + foreach(_MANOPT "-man" "-mandoc") + execute_process(COMMAND "${NROFF}" ${_MANOPT} + OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT + INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" + ERROR_QUIET) + # Save the option if it was valid + if(NROFF_MANOPT_OUTPUT) + message("Found *nroff option: -- ${_MANOPT}") + set(NROFF_MANOPT ${_MANOPT}) + set(USE_MANUAL 1) + break() + endif() + endforeach() + # No need for the temporary file + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt") + if(NOT USE_MANUAL) + message(WARNING "Found no *nroff option to get plaintext from man pages") + endif() + else() + message(WARNING "Found no *nroff program") + endif() +endif() # We need ansi c-flags, especially on HP set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") @@ -200,9 +256,22 @@ include (CheckCSourceCompiles) # On windows preload settings if(WIN32) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_") include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) endif(WIN32) +if(ENABLE_THREADED_RESOLVER) + check_include_file_concat("pthread.h" HAVE_PTHREAD_H) + if(HAVE_PTHREAD_H) + set(CMAKE_THREAD_PREFER_PTHREAD 1) + find_package(Threads) + if(CMAKE_USE_PTHREADS_INIT) + set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + set(USE_THREADS_POSIX 1) + endif() + endif() +endif() + # Check for all needed libraries check_library_exists_concat("dl" dlopen HAVE_LIBDL) check_library_exists_concat("socket" connect HAVE_LIBSOCKET) @@ -219,19 +288,49 @@ if(NOT NOT_NEED_LIBNSL) check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL) endif(NOT NOT_NEED_LIBNSL) +check_function_exists(gethostname HAVE_GETHOSTNAME) + if(WIN32) check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32) check_library_exists_concat("winmm" getch HAVE_LIBWINMM) endif() +option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) +mark_as_advanced(CMAKE_USE_OPENSSL) + +set(USE_OPENSSL OFF) +set(HAVE_LIBCRYPTO OFF) +set(HAVE_LIBSSL OFF) + +if(CMAKE_USE_OPENSSL) + find_package(OpenSSL) + if(OPENSSL_FOUND) + list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) + set(USE_OPENSSL ON) + set(HAVE_LIBCRYPTO ON) + set(HAVE_LIBSSL ON) + include_directories(${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) + check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) + check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) + check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) + check_include_file("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) + check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) + check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H) + check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H) + check_include_file("openssl/rand.h" HAVE_OPENSSL_RAND_H) + endif() +endif() + if(NOT CURL_DISABLE_LDAP) if(WIN32) - option(CURL_LDAP_WIN "Use Windows LDAP implementation" ON) - if(CURL_LDAP_WIN) + option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON) + if(USE_WIN32_LDAP) check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32) if(NOT HAVE_WLDAP32) - set(CURL_LDAP_WIN OFF) + set(USE_WIN32_LDAP OFF) endif() endif() endif() @@ -241,13 +340,14 @@ if(NOT CURL_DISABLE_LDAP) set(CMAKE_LDAP_LIB "ldap" CACHE STRING "Name or full path to ldap library") set(CMAKE_LBER_LIB "lber" CACHE STRING "Name or full path to lber library") - if(CMAKE_USE_OPENLDAP AND CURL_LDAP_WIN) - message(FATAL_ERROR "Cannot use CURL_LDAP_WIN and CMAKE_USE_OPENLDAP at the same time") + if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP) + message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time") endif() # Now that we know, we're not using windows LDAP... - if(NOT CURL_LDAP_WIN) + if(NOT USE_WIN32_LDAP) # Check for LDAP + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP) check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER) else() @@ -301,8 +401,8 @@ if(NOT CURL_DISABLE_LDAP) return 0; }" ) - set(CMAKE_REQUIRED_DEFINITIONS "-DLDAP_DEPRECATED=1" "-DWIN32_LEAN_AND_MEAN") - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1") + list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB}) if(HAVE_LIBLBER) list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB}) endif() @@ -336,9 +436,6 @@ check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN) # Check for symbol dlopen (same as HAVE_LIBDL) check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) -# For other tests to use the same libraries -set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS}) - option(CURL_ZLIB "Set to ON to enable building cURL with zlib support." ON) set(HAVE_LIBZ OFF) set(HAVE_ZLIB_H OFF) @@ -350,39 +447,10 @@ if(CURL_ZLIB) set(HAVE_ZLIB ON) set(HAVE_LIBZ ON) list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) + include_directories(${ZLIB_INCLUDE_DIRS}) endif() endif() -option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) -mark_as_advanced(CMAKE_USE_OPENSSL) - -set(USE_SSLEAY OFF) -set(USE_OPENSSL OFF) -set(HAVE_LIBCRYPTO OFF) -set(HAVE_LIBSSL OFF) - -if(CMAKE_USE_OPENSSL) - find_package(OpenSSL) - if(OPENSSL_FOUND) - list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) - set(USE_SSLEAY ON) - set(USE_OPENSSL ON) - set(HAVE_LIBCRYPTO ON) - set(HAVE_LIBSSL ON) - include_directories(${OPENSSL_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) - check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) - check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) - check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H) - check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H) - check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H) - check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H) - check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H) - check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H) - check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H) - endif(OPENSSL_FOUND) -endif(CMAKE_USE_OPENSSL) - #libSSH2 option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON) mark_as_advanced(CMAKE_USE_LIBSSH2) @@ -396,6 +464,7 @@ if(CMAKE_USE_LIBSSH2) list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY}) set(CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}") + include_directories("${LIBSSH2_INCLUDE_DIR}") set(HAVE_LIBSSH2 ON) set(USE_LIBSSH2 ON) @@ -416,20 +485,82 @@ if(CMAKE_USE_LIBSSH2) endif(LIBSSH2_FOUND) endif(CMAKE_USE_LIBSSH2) -# If we have features.h, then do the _BSD_SOURCE magic -check_include_file("features.h" HAVE_FEATURES_H) +option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF) +mark_as_advanced(CMAKE_USE_GSSAPI) + +if(CMAKE_USE_GSSAPI) + find_package(GSS) + + set(HAVE_GSSAPI ${GSS_FOUND}) + if(GSS_FOUND) + + message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"") + + set(CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR}) + check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) + check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) + check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) + + if(GSS_FLAVOUR STREQUAL "Heimdal") + set(HAVE_GSSHEIMDAL ON) + else() # MIT + set(HAVE_GSSMIT ON) + set(_INCLUDE_LIST "") + if(HAVE_GSSAPI_GSSAPI_H) + list(APPEND _INCLUDE_LIST "gssapi/gssapi.h") + endif() + if(HAVE_GSSAPI_GSSAPI_GENERIC_H) + list(APPEND _INCLUDE_LIST "gssapi/gssapi_generic.h") + endif() + if(HAVE_GSSAPI_GSSAPI_KRB5_H) + list(APPEND _INCLUDE_LIST "gssapi/gssapi_krb5.h") + endif() + + string(REPLACE ";" " " _COMPILER_FLAGS_STR "${GSS_COMPILER_FLAGS}") + string(REPLACE ";" " " _LINKER_FLAGS_STR "${GSS_LINKER_FLAGS}") + + foreach(_dir ${GSS_LINK_DIRECTORIES}) + set(_LINKER_FLAGS_STR "${_LINKER_FLAGS_STR} -L\"${_dir}\"") + endforeach() + + set(CMAKE_REQUIRED_FLAGS "${_COMPILER_FLAGS_STR} ${_LINKER_FLAGS_STR}") + set(CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES}) + check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" ${_INCLUDE_LIST} HAVE_GSS_C_NT_HOSTBASED_SERVICE) + if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE) + set(HAVE_OLD_GSSMIT ON) + endif() + + endif() + + include_directories(${GSS_INCLUDE_DIR}) + link_directories(${GSS_LINK_DIRECTORIES}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") + list(APPEND CURL_LIBS ${GSS_LIBRARIES}) + + else() + message(WARNING "GSSAPI support has been requested but no supporting libraries found. Skipping.") + endif() +endif() + +option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON) +if(ENABLE_UNIX_SOCKETS) + include(CheckStructHasMember) + check_struct_has_member("struct sockaddr_un" sun_path "sys/un.h" USE_UNIX_SOCKETS) +else() + unset(USE_UNIX_SOCKETS CACHE) +endif() # Check for header files if(NOT UNIX) - check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) - check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) -endif(NOT UNIX) -check_include_file_concat("stdio.h" HAVE_STDIO_H) -if(NOT UNIX) check_include_file_concat("windows.h" HAVE_WINDOWS_H) check_include_file_concat("winsock.h" HAVE_WINSOCK_H) + check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) + check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) endif(NOT UNIX) +check_include_file_concat("stdio.h" HAVE_STDIO_H) check_include_file_concat("inttypes.h" HAVE_INTTYPES_H) check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H) check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H) @@ -454,9 +585,6 @@ check_include_file_concat("des.h" HAVE_DES_H) check_include_file_concat("err.h" HAVE_ERR_H) check_include_file_concat("errno.h" HAVE_ERRNO_H) check_include_file_concat("fcntl.h" HAVE_FCNTL_H) -check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) -check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) -check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) check_include_file_concat("idn-free.h" HAVE_IDN_FREE_H) check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H) check_include_file_concat("io.h" HAVE_IO_H) @@ -576,6 +704,12 @@ find_file(RANDOM_FILE urandom /dev) mark_as_advanced(RANDOM_FILE) # Check for some functions that are used +if(HAVE_LIBWS2_32) + set(CMAKE_REQUIRED_LIBRARIES ws2_32) +elseif(HAVE_LIBSOCKET) + set(CMAKE_REQUIRED_LIBRARIES socket) +endif() + check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME) check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET) check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL) @@ -618,7 +752,6 @@ if(CMAKE_USE_OPENSSL) HAVE_CRYPTO_CLEANUP_ALL_EX_DATA) if(HAVE_LIBCRYPTO AND HAVE_LIBSSL) set(USE_OPENSSL 1) - set(USE_SSLEAY 1) endif(HAVE_LIBCRYPTO AND HAVE_LIBSSL) endif(CMAKE_USE_OPENSSL) check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) @@ -639,6 +772,7 @@ check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R) check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT) check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR) check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK) +check_symbol_exists(getaddrinfo "${CURL_INCLUDES}" HAVE_GETADDRINFO) check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO) check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS) check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE) @@ -677,12 +811,7 @@ if(NOT HAVE_STRICMP) set(HAVE_LDAP_URL_PARSE 1) endif(NOT HAVE_STRICMP) - - # Do curl specific tests -if(HAVE_LIBWS2_32) - set(CMAKE_REQUIRED_LIBRARIES ws2_32) -endif() foreach(CURL_TEST HAVE_FCNTL_O_NONBLOCK HAVE_IOCTLSOCKET @@ -869,24 +998,6 @@ if(MSVC) add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) endif(MSVC) -# Sets up the dependencies (zlib, OpenSSL, etc.) of a cURL subproject according to options. -# TODO This is far to be complete! -function(SETUP_CURL_DEPENDENCIES TARGET_NAME) - if(CURL_ZLIB AND ZLIB_FOUND) - include_directories(${ZLIB_INCLUDE_DIR}) - endif() - - if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND) - include_directories(${OPENSSL_INCLUDE_DIR}) - endif() - - if(CMAKE_USE_LIBSSH2 AND LIBSSH2_FOUND) - include_directories(${LIBSSH2_INCLUDE_DIR}) - endif() - - target_link_libraries(${TARGET_NAME} ${CURL_LIBS}) -endfunction() - # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it). function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE) file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT) @@ -911,6 +1022,133 @@ if(BUILD_CURL_TESTS) add_subdirectory(tests) endif() +# TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL, WINSSL, DARWINSSL +if(USE_OPENSSL) + set(SSL_ENABLED 1) +endif() + +# Helper to populate a list (_items) with a label when conditions (the remaining +# args) are satisfied +function(_add_if label) + # TODO need to disable policy CMP0054 (CMake 3.1) to allow this indirection + if(${ARGN}) + set(_items ${_items} "${label}" PARENT_SCOPE) + endif() +endfunction() + +# Clear list and try to detect available features +set(_items) +_add_if("SSL" SSL_ENABLED) +_add_if("IPv6" ENABLE_IPV6) +_add_if("unix-sockets" USE_UNIX_SOCKETS) +_add_if("libz" HAVE_LIBZ) +_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX) +_add_if("IDN" HAVE_LIBIDN) +# TODO SSP1 (WinSSL) check is missing +_add_if("SSPI" USE_WINDOWS_SSPI) +_add_if("GSS-API" HAVE_GSSAPI) +# TODO SSP1 missing for SPNEGO +_add_if("SPNEGO" NOT CURL_DISABLE_CRYPTO_AUTH AND + (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) +_add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND + (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) +# NTLM support requires crypto function adaptions from various SSL libs +# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS, DARWINSSL +if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR + USE_WINDOWS_SSPI OR GNUTLS_ENABLED OR NSS_ENABLED OR DARWINSSL_ENABLED)) + _add_if("NTLM" 1) + # TODO missing option (autoconf: --enable-ntlm-wb) + _add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED) +endif() +# TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP +_add_if("TLS-SRP" USE_TLS_SRP) +# TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header +_add_if("HTTP2" USE_NGHTTP2) +string(REPLACE ";" " " SUPPORT_FEATURES "${_items}") +message(STATUS "Enabled features: ${SUPPORT_FEATURES}") + +# Clear list and try to detect available protocols +set(_items) +_add_if("HTTP" NOT CURL_DISABLE_HTTP) +_add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED) +_add_if("FTP" NOT CURL_DISABLE_FTP) +_add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED) +_add_if("FILE" NOT CURL_DISABLE_FILE) +_add_if("TELNET" NOT CURL_DISABLE_TELNET) +_add_if("LDAP" NOT CURL_DISABLE_LDAP) +# CURL_DISABLE_LDAP implies CURL_DISABLE_LDAPS +# TODO check HAVE_LDAP_SSL (in autoconf this is enabled with --enable-ldaps) +_add_if("LDAPS" NOT CURL_DISABLE_LDAPS AND + ((USE_OPENLDAP AND SSL_ENABLED) OR + (NOT USE_OPENLDAP AND HAVE_LDAP_SSL))) +_add_if("DICT" NOT CURL_DISABLE_DICT) +_add_if("TFTP" NOT CURL_DISABLE_TFTP) +_add_if("GOPHER" NOT CURL_DISABLE_GOPHER) +_add_if("POP3" NOT CURL_DISABLE_POP3) +_add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED) +_add_if("IMAP" NOT CURL_DISABLE_IMAP) +_add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED) +_add_if("SMTP" NOT CURL_DISABLE_SMTP) +_add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED) +_add_if("SCP" USE_LIBSSH2) +_add_if("SFTP" USE_LIBSSH2) +_add_if("RTSP" NOT CURL_DISABLE_RTSP) +_add_if("RTMP" USE_LIBRTMP) +list(SORT _items) +string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}") +message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}") + +# curl-config needs the following options to be set. +set(CC "${CMAKE_C_COMPILER}") +# TODO probably put a -D... options here? +set(CONFIGURE_OPTIONS "") +# TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB? +set(CPPFLAG_CURL_STATICLIB "") +# TODO need to set this (see CURL_CHECK_CA_BUNDLE in acinclude.m4) +set(CURL_CA_BUNDLE "") +set(CURLVERSION "${CURL_VERSION}") +set(ENABLE_SHARED "yes") +if(CURL_STATICLIB) + # Broken: LIB