summaryrefslogtreecommitdiffstats
path: root/Source/cmProjectCommand.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2011-12-16 02:56:34 (GMT)
committerBrad King <brad.king@kitware.com>2011-12-20 19:16:25 (GMT)
commit5badf5f734119199fa42377b25d415532191a710 (patch)
treeb942dab683f4312cd67176b436b710859b5e55a2 /Source/cmProjectCommand.cxx
parent0a6543d957463f0a7f7a585cc43468174c1204a0 (diff)
downloadCMake-5badf5f734119199fa42377b25d415532191a710.zip
CMake-5badf5f734119199fa42377b25d415532191a710.tar.gz
CMake-5badf5f734119199fa42377b25d415532191a710.tar.bz2
Fix the case where cmake --build failed with two project cmds in one file.
This adds a test that uses two project commands in the same CMakeLists.txt file. It also adds a fix so that cmake --build will work in that case. The fix sets the name of the last project command in the top level CMakeLists.txt in the cache variable CMAKE_PROJECT_NAME. This variable is used by cmake --build to find the project name.
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r--Source/cmProjectCommand.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 1a831d9..6e3b6af 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -47,9 +47,13 @@ bool cmProjectCommand
this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
// Set the CMAKE_PROJECT_NAME variable to be the highest-level
- // project name in the tree. This is always the first PROJECT
- // command encountered.
- if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME"))
+ // project name in the tree. If there are two project commands
+ // in the same CMakeLists.txt file, and it is the top level
+ // CMakeLists.txt file, then go with the last one, so that
+ // CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
+ // will work.
+ if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")
+ || (this->Makefile->GetLocalGenerator()->GetParent() == 0) )
{
this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
this->Makefile->AddCacheDefinition