From 2db5cc8c31cf281d9f106433fbfe3060d97fa664 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Jun 2003 09:44:31 -0400 Subject: [PATCH] BUG: When executable output path is not set, we still need to generate the full path to the executable target. --- Source/cmLocalUnixMakefileGenerator.cxx | 31 +++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 33d55727b..badaa0ae3 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -1093,9 +1093,21 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, std::string buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); buildType = cmSystemTools::UpperCase(buildType); std::string flags; - std::string target = m_ExecutableOutputPath + name - + cmSystemTools::GetExecutableExtension(); + + // Construct the full path to the executable that will be generated. + std::string target = m_ExecutableOutputPath; + if(target.length() == 0) + { + target = m_Makefile->GetCurrentOutputDirectory(); + if(target.size() && target[target.size()-1] != '/') + { + target += "/"; + } + } + target += name; + target += cmSystemTools::GetExecutableExtension(); target = cmSystemTools::ConvertToOutputPath(target.c_str()); + std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; std::string depend = "$("; depend += this->CreateMakeVariable(name, "_SRC_OBJS") @@ -1189,6 +1201,21 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, target.c_str(), depend.c_str(), commands); + + // If there is no executable output path, add a rule with the + // relative path to the executable. This is necessary for + // try-compile to work in this case. + if(m_ExecutableOutputPath.length() == 0) + { + target = name; + target += cmSystemTools::GetExecutableExtension(); + target = cmSystemTools::ConvertToOutputPath(target.c_str()); + this->OutputMakeRule(fout, + comment.c_str(), + target.c_str(), + depend.c_str(), + commands); + } }