ENH: put the 64 bit paths first
[cmake.git] / Source / cmIncludeCommand.cxx
blob999359babdf5f85dcc70f90aff3656f9a7dd27d5
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmIncludeCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2009-01-22 18:18:39 $
7 Version: $Revision: 1.22 $
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 "cmIncludeCommand.h"
20 // cmIncludeCommand
21 bool cmIncludeCommand
22 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
24 if (args.size()< 1 || args.size() > 4)
26 this->SetError("called with wrong number of arguments. "
27 "Include only takes one file.");
28 return false;
30 bool optional = false;
31 bool noPolicyScope = false;
32 std::string fname = args[0];
33 std::string resultVarName;
35 for (unsigned int i=1; i<args.size(); i++)
37 if (args[i] == "OPTIONAL")
39 if (optional)
41 this->SetError("called with invalid arguments: OPTIONAL used twice");
42 return false;
44 optional = true;
46 else if(args[i] == "RESULT_VARIABLE")
48 if (resultVarName.size() > 0)
50 this->SetError("called with invalid arguments: "
51 "only one result variable allowed");
52 return false;
54 if(++i < args.size())
56 resultVarName = args[i];
58 else
60 this->SetError("called with no value for RESULT_VARIABLE.");
61 return false;
64 else if(args[i] == "NO_POLICY_SCOPE")
66 noPolicyScope = true;
68 else if(i > 1) // compat.: in previous cmake versions the second
69 // parameter was ignore if it wasn't "OPTIONAL"
71 std::string errorText = "called with invalid argument: ";
72 errorText += args[i];
73 this->SetError(errorText.c_str());
74 return false;
78 if(!cmSystemTools::FileIsFullPath(fname.c_str()))
80 // Not a path. Maybe module.
81 std::string module = fname;
82 module += ".cmake";
83 std::string mfile = this->Makefile->GetModulesFile(module.c_str());
84 if ( mfile.size() )
86 fname = mfile.c_str();
89 std::string fullFilePath;
90 bool readit =
91 this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),
92 fname.c_str(), &fullFilePath,
93 noPolicyScope);
95 // add the location of the included file if a result variable was given
96 if (resultVarName.size())
98 this->Makefile->AddDefinition(resultVarName.c_str(),
99 readit?fullFilePath.c_str():"NOTFOUND");
102 if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured())
104 std::string m =
105 "could not find load file:\n"
106 " ";
107 m += fname;
108 this->SetError(m.c_str());
109 return false;
111 return true;