summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraCodeBlocksGenerator.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-09-26 08:26:28 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-09-26 08:26:28 (GMT)
commit253dafd025d84849caae90b2407d444e304a571d (patch)
tree38eeb753c212f9157654f3c94328a96f7c716791 /Source/cmExtraCodeBlocksGenerator.cxx
parent680c780b22e8cf445c2abaa740695773233cf1a3 (diff)
downloadCMake-253dafd025d84849caae90b2407d444e304a571d.zip
CMake-253dafd025d84849caae90b2407d444e304a571d.tar.gz
CMake-253dafd025d84849caae90b2407d444e304a571d.tar.bz2
Fix bug #9529.
Set the working_dir entry in the codeblocks project file of executable targets to the directory where the executable is created. Then when running CB, executing the target (not building), will run it from that directory. Alex
Diffstat (limited to 'Source/cmExtraCodeBlocksGenerator.cxx')
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 203e206..2bfb8cf 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -544,11 +544,32 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
if (target!=0)
{
int cbTargetType = this->GetCBTargetType(target);
+ std::string workingDir = makefile->GetStartOutputDirectory();
+ if ( target->GetType()==cmTarget::EXECUTABLE)
+ {
+ // Determine the directory where the executable target is created, and
+ // set the working directory to this dir.
+ const char* runtimeOutputDir = makefile->GetDefinition(
+ "CMAKE_RUNTIME_OUTPUT_DIRECTORY");
+ if (runtimeOutputDir != 0)
+ {
+ workingDir = runtimeOutputDir;
+ }
+ else
+ {
+ const char* executableOutputDir = makefile->GetDefinition(
+ "EXECUTABLE_OUTPUT_PATH");
+ if (executableOutputDir != 0)
+ {
+ workingDir = executableOutputDir;
+ }
+ }
+ }
+
const char* buildType = makefile->GetDefinition("CMAKE_BUILD_TYPE");
fout<<" <Option output=\"" << target->GetLocation(buildType)
<< "\" prefix_auto=\"0\" extension_auto=\"0\" />\n"
- " <Option working_dir=\""
- << makefile->GetStartOutputDirectory() << "\" />\n"
+ " <Option working_dir=\"" << workingDir << "\" />\n"
" <Option object_output=\"./\" />\n"
" <Option type=\"" << cbTargetType << "\" />\n"
" <Option compiler=\"" << compiler << "\" />\n"