summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-06-10 14:58:36 (GMT)
committerBrad King <brad.king@kitware.com>2016-06-17 18:22:29 (GMT)
commit49f10f0d24420f7d96c5153ba64a16b3f43c4736 (patch)
treebd6ae93de51dc222b30bb127bb5d336dc157df90 /Source/cmGeneratorTarget.cxx
parent0392f72bef5f1394c2dba3740f2a701fe1a98f0d (diff)
downloadCMake-49f10f0d24420f7d96c5153ba64a16b3f43c4736.zip
CMake-49f10f0d24420f7d96c5153ba64a16b3f43c4736.tar.gz
CMake-49f10f0d24420f7d96c5153ba64a16b3f43c4736.tar.bz2
cmGeneratorTarget: Adopt Fortran module directory generation
Move code to create/get the fortran module directory from the cmCommonTargetGenerator to cmGeneratorTarget. Rename the ComputeFortranModuleDirectory method to CreateFortranModuleDirectory as this method *creates* the directory if it is missing.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 5f4b074..15b44a6 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -258,6 +258,7 @@ void CreatePropertyGeneratorExpressions(
cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
: Target(t)
+ , FortranModuleDirectoryCreated(false)
, SourceFileFlagsConstructed(false)
, PolicyWarnedCMP0022(false)
, DebugIncludesDone(false)
@@ -3842,6 +3843,40 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major,
}
}
+std::string cmGeneratorTarget::GetFortranModuleDirectory() const
+{
+ if (!this->FortranModuleDirectoryCreated) {
+ this->FortranModuleDirectory = true;
+ this->FortranModuleDirectory = this->CreateFortranModuleDirectory();
+ }
+
+ return this->FortranModuleDirectory;
+}
+
+std::string cmGeneratorTarget::CreateFortranModuleDirectory() const
+{
+ static std::string mod_dir;
+ const char* target_mod_dir = this->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->LocalGenerator->GetCurrentBinaryDirectory();
+ mod_dir += "/";
+ mod_dir += target_mod_dir;
+ }
+
+ // Make sure the module output directory exists.
+ cmSystemTools::MakeDirectory(mod_dir);
+ }
+ return mod_dir;
+}
+
std::string cmGeneratorTarget::GetFrameworkVersion() const
{
assert(this->GetType() != cmState::INTERFACE_LIBRARY);