1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmAddExecutableCommand.cxx,v $
6 Date: $Date: 2008-02-11 22:33:46 $
7 Version: $Revision: 1.35 $
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 "cmAddExecutableCommand.h"
19 // cmExecutableCommand
20 bool cmAddExecutableCommand
21 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
25 this->SetError("called with incorrect number of arguments");
28 std::vector
<std::string
>::const_iterator s
= args
.begin();
30 std::string exename
= *s
;
33 bool use_win32
= false;
34 bool use_macbundle
= false;
35 bool excludeFromAll
= false;
36 bool importTarget
= false;
37 while ( s
!= args
.end() )
44 else if ( *s
== "MACOSX_BUNDLE" )
49 else if(*s
== "EXCLUDE_FROM_ALL")
52 excludeFromAll
= true;
54 else if(*s
== "IMPORTED")
65 // Special modifiers are not allowed with IMPORTED signature.
66 if(importTarget
&& (use_win32
|| use_macbundle
|| excludeFromAll
))
70 this->SetError("may not be given WIN32 for an IMPORTED target.");
72 else if(use_macbundle
)
75 "may not be given MACOSX_BUNDLE for an IMPORTED target.");
77 else // if(excludeFromAll)
80 "may not be given EXCLUDE_FROM_ALL for an IMPORTED target.");
85 // Handle imported target creation.
88 // Make sure the target does not already exist.
89 if(this->Makefile
->FindTargetToUse(exename
.c_str()))
92 e
<< "cannot create imported target \"" << exename
93 << "\" because another target with the same name already exists.";
94 this->SetError(e
.str().c_str());
98 // Create the imported target.
99 this->Makefile
->AddImportedTarget(exename
.c_str(), cmTarget::EXECUTABLE
);
103 // Enforce name uniqueness.
106 if(!this->Makefile
->EnforceUniqueName(exename
, msg
))
108 this->SetError(msg
.c_str());
116 ("called with incorrect number of arguments, no sources provided");
120 std::vector
<std::string
> srclists(s
, args
.end());
121 cmTarget
* tgt
= this->Makefile
->AddExecutable(exename
.c_str(), srclists
,
125 tgt
->SetProperty("WIN32_EXECUTABLE", "ON");
129 tgt
->SetProperty("MACOSX_BUNDLE", "ON");