Introduce "generator expressions" to add_test()
[cmake.git] / Source / cmProjectCommand.cxx
blob14390e7b79b3f4a8dbce1b1534633b23e1c7cfd4
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmProjectCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-10-15 17:56:06 $
7 Version: $Revision: 1.26 $
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());
60 this->Makefile->AddCacheDefinition
61 ("CMAKE_PROJECT_NAME",
62 args[0].c_str(),
63 "Value Computed by CMake", cmCacheManager::STATIC);
66 std::vector<std::string> languages;
67 if(args.size() > 1)
69 for(size_t i =1; i < args.size(); ++i)
71 languages.push_back(args[i]);
74 else
76 // if no language is specified do c and c++
77 languages.push_back("C");
78 languages.push_back("CXX");
80 this->Makefile->EnableLanguage(languages, false);
81 return true;