diff options
author | Brad King <brad.king@kitware.com> | 2007-03-08 19:57:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-03-08 19:57:28 (GMT) |
commit | 33ee83714d3cea644f9d1cd6654c2e7b1f3cdc5d (patch) | |
tree | 5f2f82863c856ed2f5c1f04158eb228ac1477c24 /Source/cmTarget.cxx | |
parent | ea19994b13273cf6e1f7677cc29ce53cf1a59768 (diff) | |
download | CMake-33ee83714d3cea644f9d1cd6654c2e7b1f3cdc5d.zip CMake-33ee83714d3cea644f9d1cd6654c2e7b1f3cdc5d.tar.gz CMake-33ee83714d3cea644f9d1cd6654c2e7b1f3cdc5d.tar.bz2 |
ENH: Replaced LibraryOutputPath and ExecutableOutputPath variables in Makefile and VS generators to instead ask each target for its output path. This significantly reduces total code size and centralizes previously duplicate code. It is also a step towards bug#2240.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 76 |
1 files changed, 48 insertions, 28 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5feb3bc..8298751 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1093,34 +1093,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) const char* cmTarget::GetDirectory(const char* config) { - switch( this->GetType() ) - { - case cmTarget::STATIC_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::SHARED_LIBRARY: - this->Directory = - this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); - break; - case cmTarget::EXECUTABLE: - this->Directory = - this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - break; - default: - this->Directory = this->Makefile->GetStartOutputDirectory(); - break; - } - if(this->Directory.empty()) - { - this->Directory = this->Makefile->GetStartOutputDirectory(); - } - // if LIBRARY_OUTPUT_PATH or EXECUTABLE_OUTPUT_PATH was relative - // then make them full paths because this directory MUST - // be a full path or things will not work!!! - if(!cmSystemTools::FileIsFullPath(this->Directory.c_str())) - { - this->Directory = this->Makefile->GetCurrentOutputDirectory() + - std::string("/") + this->Directory; - } + this->Directory = this->GetOutputDir(); if(config) { // Add the configuration's subdirectory. @@ -1956,3 +1929,50 @@ std::string cmTarget::GetInstallNameDirForInstallTree(const char*) return ""; } } + +//---------------------------------------------------------------------------- +const char* cmTarget::GetOutputDir() +{ + if(this->OutputDir.empty()) + { + // Lookup the output path for this target type. + switch(this->GetType()) + { + case cmTarget::STATIC_LIBRARY: + case cmTarget::MODULE_LIBRARY: + case cmTarget::SHARED_LIBRARY: + this->OutputDir = + this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); + break; + case cmTarget::EXECUTABLE: + this->OutputDir = + this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); + break; + } + if(this->OutputDir.empty()) + { + this->OutputDir = "."; + } + + // Convert the output path to a full path in case it is + // specified as a relative path. Treat a relative path as + // relative to the current output directory for this makefile. + this->OutputDir = + cmSystemTools::CollapseFullPath + (this->OutputDir.c_str(), this->Makefile->GetStartOutputDirectory()); + + // Make sure the output path exists on disk. + if(!cmSystemTools::MakeDirectory(this->OutputDir.c_str())) + { + cmSystemTools::Error("Error failed to create output directory:", + this->OutputDir.c_str()); + } + + // TODO: This came from cmLocalUnixMakefileGenerator3::FormatOutputPath. + // Where should it go. Is it still needed? + // Add this as a link directory automatically. + // this->Makefile->AddLinkDirectory(path.c_str()); + } + + return this->OutputDir.c_str(); +} |