diff options
| author | Brad King <brad.king@kitware.com> | 2015-09-22 17:57:08 (GMT) |
|---|---|---|
| committer | Brad King <brad.king@kitware.com> | 2015-09-22 17:57:08 (GMT) |
| commit | 2e6063068c94d4045e699fed51e6d1e9af344bbf (patch) | |
| tree | d11025f71134b3238e52655640dcdf2158425597 /Source/cmCommonTargetGenerator.cxx | |
| parent | 81739e9215ef10d870f14404b0ec5eb4bee16ce4 (diff) | |
| parent | 3bb707f0a1408dc0381ecbf4ec934e9f14d8927c (diff) | |
| download | CMake-2e6063068c94d4045e699fed51e6d1e9af344bbf.zip CMake-2e6063068c94d4045e699fed51e6d1e9af344bbf.tar.gz CMake-2e6063068c94d4045e699fed51e6d1e9af344bbf.tar.bz2 | |
Merge branch 'improve-variable-help-formatting' into revert-cmake-W-options
Resolve conflicts in
Help/variable/CMAKE_ERROR_DEPRECATED.rst
Help/variable/CMAKE_WARN_DEPRECATED.rst
by integrating changes from both sides.
Diffstat (limited to 'Source/cmCommonTargetGenerator.cxx')
| -rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 130 |
1 files changed, 87 insertions, 43 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 2225fdc..4840e89 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<cmLocalCommonGenerator*>(gt->LocalGenerator)) @@ -101,47 +105,47 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) } //---------------------------------------------------------------------------- -const char* cmCommonTargetGenerator::GetFortranModuleDirectory() +std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const { - // Compute the module directory. - if(!this->FortranModuleDirectoryComputed) + 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) { - 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)) { - // 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()); + // 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; } - this->FortranModuleDirectoryComputed = true; - } - // Return the computed directory. - if(this->FortranModuleDirectory.empty()) - { - return 0; + // Make sure the module output directory exists. + cmSystemTools::MakeDirectory(mod_dir); } - else + return mod_dir; +} + +//---------------------------------------------------------------------------- +std::string cmCommonTargetGenerator::GetFortranModuleDirectory() +{ + // Compute the module directory. + if(!this->FortranModuleDirectoryComputed) { - return this->FortranModuleDirectory.c_str(); + this->FortranModuleDirectoryComputed = true; + this->FortranModuleDirectory = this->ComputeFortranModuleDirectory(); } + + // Return the computed directory. + return this->FortranModuleDirectory; } //---------------------------------------------------------------------------- @@ -155,19 +159,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, + this->WorkingDirectory, + 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); } @@ -267,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<std::string> const& frameworks = cli->GetFrameworkPaths(); for(std::vector<std::string>::const_iterator i = frameworks.begin(); @@ -368,3 +378,37 @@ std::string cmCommonTargetGenerator::GetIncludes(std::string const& l) } return i->second; } + +std::vector<std::string> +cmCommonTargetGenerator::GetLinkedTargetDirectories() const +{ + std::vector<std::string> dirs; + std::set<cmTarget const*> emitted; + if (cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) + { + 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); + dirs.push_back(di); + } + } + } + return dirs; +} |
