diff options
author | Brad King <brad.king@kitware.com> | 2009-02-27 16:23:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-02-27 16:23:14 (GMT) |
commit | 1d3308156e1fc1646873b22317265c61288e9e42 (patch) | |
tree | ff65855bca8ae897c19ce112d54d654bab2a049c /Source/cmMakefile.cxx | |
parent | 99b37665c91e91d70576298fef7bab71f794c985 (diff) | |
download | CMake-1d3308156e1fc1646873b22317265c61288e9e42.zip CMake-1d3308156e1fc1646873b22317265c61288e9e42.tar.gz CMake-1d3308156e1fc1646873b22317265c61288e9e42.tar.bz2 |
ENH: Enforce unique binary directories
The second argument of add_subdirectory must name a unique binary
directory or the build files will clobber each other. This enforces
uniqueness with an error message.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3a8ab2a..d22cebd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1536,6 +1536,21 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, } } + // Make sure the binary directory is unique. + cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); + if(!gg->BinaryDirectoryIsNew(binPath)) + { + cmOStringStream e; + e << "The binary directory\n" + << " " << binPath << "\n" + << "is already used to build another source directory, so it cannot " + << "be used to build source directory\n" + << " " << srcPath << "\n" + << "Specify a unique binary directory name."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + // create a new local generator and set its parent cmLocalGenerator *lg2 = this->LocalGenerator->GetGlobalGenerator()->CreateLocalGenerator(); |