Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSubdirCommand.cxx
blob3ee67c97f55b28d971db242e3a8f17fb9c2770d1
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSubdirCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/23 15:27:59 $
7 Version: $Revision: 1.19 $
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 "cmSubdirCommand.h"
19 // cmSubdirCommand
20 bool cmSubdirCommand
21 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
23 if(args.size() < 1 )
25 this->SetError("called with incorrect number of arguments");
26 return false;
28 bool res = true;
29 bool excludeFromAll = false;
30 bool preorder = false;
32 for(std::vector<std::string>::const_iterator i = args.begin();
33 i != args.end(); ++i)
35 if(*i == "EXCLUDE_FROM_ALL")
37 excludeFromAll = true;
38 continue;
40 if(*i == "PREORDER")
42 preorder = true;
43 continue;
46 // if they specified a relative path then compute the full
47 std::string srcPath =
48 std::string(this->Makefile->GetCurrentDirectory()) +
49 "/" + i->c_str();
50 if (cmSystemTools::FileIsDirectory(srcPath.c_str()))
52 std::string binPath =
53 std::string(this->Makefile->GetCurrentOutputDirectory()) +
54 "/" + i->c_str();
55 this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
56 excludeFromAll, preorder, false);
58 // otherwise it is a full path
59 else if ( cmSystemTools::FileIsDirectory(i->c_str()) )
61 // we must compute the binPath from the srcPath, we just take the last
62 // element from the source path and use that
63 std::string binPath =
64 std::string(this->Makefile->GetCurrentOutputDirectory()) +
65 "/" + cmSystemTools::GetFilenameName(i->c_str());
66 this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(),
67 excludeFromAll, preorder, false);
69 else
71 std::string error = "Incorrect SUBDIRS command. Directory: ";
72 error += *i + " does not exists.";
73 this->SetError(error.c_str());
74 res = false;
77 return res;