1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmProjectCommand.h"
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
20 this->SetError("PROJECT called with incorrect number of arguments");
23 this->Makefile->SetProjectName(args[0].c_str());
25 std::string bindir = args[0];
26 bindir += "_BINARY_DIR";
27 std::string srcdir = args[0];
28 srcdir += "_SOURCE_DIR";
30 this->Makefile->AddCacheDefinition
32 this->Makefile->GetCurrentOutputDirectory(),
33 "Value Computed by CMake", cmCacheManager::STATIC);
34 this->Makefile->AddCacheDefinition
36 this->Makefile->GetCurrentDirectory(),
37 "Value Computed by CMake", cmCacheManager::STATIC);
39 bindir = "PROJECT_BINARY_DIR";
40 srcdir = "PROJECT_SOURCE_DIR";
42 this->Makefile->AddDefinition(bindir.c_str(),
43 this->Makefile->GetCurrentOutputDirectory());
44 this->Makefile->AddDefinition(srcdir.c_str(),
45 this->Makefile->GetCurrentDirectory());
47 this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
49 // Set the CMAKE_PROJECT_NAME variable to be the highest-level
50 // project name in the tree. If there are two project commands
51 // in the same CMakeLists.txt file, and it is the top level
52 // CMakeLists.txt file, then go with the last one, so that
53 // CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
55 if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")
56 || (this->Makefile->GetLocalGenerator()->GetParent() == 0) )
58 this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
59 this->Makefile->AddCacheDefinition
60 ("CMAKE_PROJECT_NAME",
62 "Value Computed by CMake", cmCacheManager::STATIC);
65 std::vector<std::string> languages;
68 for(size_t i =1; i < args.size(); ++i)
70 languages.push_back(args[i]);
75 // if no language is specified do c and c++
76 languages.push_back("C");
77 languages.push_back("CXX");
79 this->Makefile->EnableLanguage(languages, false);
80 std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE";
81 const char* include = this->Makefile->GetDefinition(extraInclude.c_str());
84 std::string fullFilePath;
86 this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),
88 if(!readit && !cmSystemTools::GetFatalErrorOccured())
91 "could not find file:\n"
94 this->SetError(m.c_str());