I have been meaning to try and create such a patch for a while. The
idea behind the patch is that you can specify the location of the out
of source build directory on the command line. By itself, this really
isn't all that useful save having to type mkdir 'some dir', cd 'some
dir', and 'cmake ..'
I think the use in this feature comes from being able to do something
like the following from WITHIN the source tree
$> cmake -B ./debug -DDebug=1 .
$> cmake -B ./release -DRelease=1 .
This will create directories 'debug' and 'release' in the source tree
where it will put all of the cmake cache files and whatnot from the
build. Each directory will then be using the appropriate things
triggered by having set the -D ... note... this is just a simple
example
I used the -B flag (as it was already there and I couldn't tell what
else it was currently doing) ... but pardon me if it actually had a
previous purpose.
This patch is not meat to be exhaustive (as I might have missed a
usage scenario with cache files or whatnot), but it does demonstrate
the capability I am looking for.
Feedback is welcome...or if you think this feature is utterly
worthless let me know :) I wanna hear why it can't work (don't just
say...well, you could have just made the directory and done all that
within it...yea...I know...but the point is that I didn't have to :) )
~Roman
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index d4b29f5..d4b9912 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -544,10 +544,22 @@ void cmake::SetArgs(const std::vector<std::string>& args)
{
// There is no local generate anymore. Ignore -O option.
}
+ //this will set the output directory to the path specified
else if(arg.find("-B",0) == 0)
{
directoriesSet = true;
std::string path = arg.substr(2);
+
+ if (path.empty())
+ {
+ if(++i >= args.size())
+ {
+ cmSystemTools::Error("No path specified for -B");
+ return;
+ }
+ path = args[i];
+ }
+
path = cmSystemTools::CollapseFullPath(path.c_str());
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeOutputDirectory(path.c_str());
@@ -753,23 +765,26 @@ void cmake::SetDirectoriesFromFile(const char* arg)
{
this->SetHomeDirectory(listPath.c_str());
this->SetStartDirectory(listPath.c_str());
-
- if(argIsFile)
- {
- // Source CMakeLists.txt file given. It was probably dropped
- // onto the executable in a GUI. Default to an in-source build.
- this->SetHomeOutputDirectory(listPath.c_str());
- this->SetStartOutputDirectory(listPath.c_str());
- }
- else
+
+ if (this->HomeOutputDirectory.empty())
{
- // Source directory given on command line. Use current working
- // directory as build tree.
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeOutputDirectory(cwd.c_str());
- this->SetStartOutputDirectory(cwd.c_str());
+ if(argIsFile)
+ {
+ // Source CMakeLists.txt file given. It was probably dropped
+ // onto the executable in a GUI. Default to an in-source build.
+ this->SetHomeOutputDirectory(listPath.c_str());
+ }
+ else
+ {
+ // Source directory given on command line. Use current working
+ // directory as build tree.
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ this->SetHomeOutputDirectory(cwd.c_str());
+ }
+
+ this->SetStartOutputDirectory(this->HomeOutputDirectory.c_str());
+ return;
}
- return;
}
// We didn't find a CMakeLists.txt or CMakeCache.txt file from the
@@ -779,8 +794,11 @@ void cmake::SetDirectoriesFromFile(const char* arg)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
this->SetHomeDirectory(full.c_str());
this->SetStartDirectory(full.c_str());
- this->SetHomeOutputDirectory(cwd.c_str());
- this->SetStartOutputDirectory(cwd.c_str());
+
+ if (this->HomeOutputDirectory.empty())
+ this->SetHomeOutputDirectory(cwd.c_str());
+
+ this->SetStartOutputDirectory(this->HomeOutputDirectory.c_str());
}
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake