1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmTargetLinkLibrariesCommand.cxx,v $
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 "cmTargetLinkLibrariesCommand.h"
19 // cmTargetLinkLibrariesCommand
20 bool cmTargetLinkLibrariesCommand
21 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
23 // must have one argument
26 this->SetError("called with incorrect number of arguments");
30 // but we might not have any libs after variable expansion
35 // add libraries, nothe that there is an optional prefix
36 // of debug and optimized than can be used
37 std::vector
<std::string
>::const_iterator i
= args
.begin();
39 for(++i
; i
!= args
.end(); ++i
)
47 ("The \"debug\" argument must be followed by a library");
50 this->Makefile
->AddLinkLibraryForTarget(args
[0].c_str(),i
->c_str(),
53 else if (*i
== "optimized")
59 "The \"optimized\" argument must be followed by a library");
62 this->Makefile
->AddLinkLibraryForTarget(args
[0].c_str(),i
->c_str(),
65 else if (*i
== "general")
71 "The \"general\" argument must be followed by a library");
74 this->Makefile
->AddLinkLibraryForTarget(args
[0].c_str(),i
->c_str(),
79 // make sure the type is correct if it is currently general. So if you
80 // do a target_link_libraries(foo optimized bar) it will stay optimized
81 // and not use the lookup. As there maybe the case where someone has
82 // specifed that a library is both debug and optimized. (this check is
83 // only there for backwards compatibility when mixing projects built
84 // with old versions of CMake and new)
85 cmTarget::LinkLibraryType llt
= cmTarget::GENERAL
;
86 std::string linkType
= args
[0];
87 linkType
+= "_LINK_TYPE";
88 const char* linkTypeString
=
89 this->Makefile
->GetDefinition( linkType
.c_str() );
92 if(strcmp(linkTypeString
, "debug") == 0)
94 llt
= cmTarget::DEBUG
;
96 if(strcmp(linkTypeString
, "optimized") == 0)
98 llt
= cmTarget::OPTIMIZED
;
101 this->Makefile
->AddLinkLibraryForTarget(args
[0].c_str(),i
->c_str(),llt
);