STYLE: Fix typo in GetFilenameLastExtension docs
[cmake.git] / Source / cmProjectCommand.cxx
blob79c18ad5c83e66535646424f9a18b64dadcd6dff
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmProjectCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.25 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmProjectCommand.h"
19 // cmProjectCommand
20 bool cmProjectCommand
21 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
23 if(args.size() < 1 )
25 this->SetError("PROJECT called with incorrect number of arguments");
26 return false;
28 this->Makefile->SetProjectName(args[0].c_str());
30 std::string bindir = args[0];
31 bindir += "_BINARY_DIR";
32 std::string srcdir = args[0];
33 srcdir += "_SOURCE_DIR";
35 this->Makefile->AddCacheDefinition
36 (bindir.c_str(),
37 this->Makefile->GetCurrentOutputDirectory(),
38 "Value Computed by CMake", cmCacheManager::STATIC);
39 this->Makefile->AddCacheDefinition
40 (srcdir.c_str(),
41 this->Makefile->GetCurrentDirectory(),
42 "Value Computed by CMake", cmCacheManager::STATIC);
44 bindir = "PROJECT_BINARY_DIR";
45 srcdir = "PROJECT_SOURCE_DIR";
47 this->Makefile->AddDefinition(bindir.c_str(),
48 this->Makefile->GetCurrentOutputDirectory());
49 this->Makefile->AddDefinition(srcdir.c_str(),
50 this->Makefile->GetCurrentDirectory());
52 this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
54 // Set the CMAKE_PROJECT_NAME variable to be the highest-level
55 // project name in the tree. This is always the first PROJECT
56 // command encountered.
57 if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME"))
59 this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
62 std::vector<std::string> languages;
63 if(args.size() > 1)
65 for(size_t i =1; i < args.size(); ++i)
67 languages.push_back(args[i]);
70 else
72 // if no language is specified do c and c++
73 languages.push_back("C");
74 languages.push_back("CXX");
76 this->Makefile->EnableLanguage(languages, false);
77 return true;