1
/*=========================================================================
3
Program: CMake - Cross-Platform Makefile Generator
4
Module: $RCSfile: cmMakefileLibraryTargetGenerator.cxx,v $
6
Date: $Date: 2008-10-24 15:18:52 $
7
Version: $Revision: 1.58.2.5 $
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
=========================================================================*/
1
/*============================================================================
2
CMake - Cross Platform Makefile Generator
3
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5
Distributed under the OSI-approved BSD License (the "License");
6
see accompanying file Copyright.txt for details.
8
This software is distributed WITHOUT ANY WARRANTY; without even the
9
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
See the License for more information.
11
============================================================================*/
17
12
#include "cmMakefileLibraryTargetGenerator.h"
19
14
#include "cmGeneratedFileStream.h"
146
146
this->LocalGenerator->AppendFlags
147
147
(extraFlags, this->Target->GetProperty("LINK_FLAGS"));
148
148
std::string linkFlagsConfig = "LINK_FLAGS_";
150
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName.c_str());
149
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
151
150
this->LocalGenerator->AppendFlags
152
151
(extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
154
153
this->LocalGenerator->AddConfigVariableFlags
155
(extraFlags, "CMAKE_SHARED_LINKER_FLAGS",
156
this->LocalGenerator->ConfigurationName.c_str());
157
if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN")
158
|| this->Makefile->IsOn("MINGW")))
160
const std::vector<cmSourceFile*>& sources =
161
this->Target->GetSourceFiles();
162
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
163
i != sources.end(); ++i)
165
cmSourceFile* sf = *i;
166
if(sf->GetExtension() == "def")
170
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
172
this->Convert(sf->GetFullPath().c_str(),
173
cmLocalGenerator::START_OUTPUT,
174
cmLocalGenerator::SHELL);
154
(extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
155
this->AddModuleDefinitionFlag(extraFlags);
178
157
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
448
422
this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT,
449
423
cmLocalGenerator::SHELL);
451
// Add the link message.
452
std::string buildEcho = "Linking ";
453
buildEcho += linkLanguage;
425
if(!this->NoRuleMessages)
427
// Add the link message.
428
std::string buildEcho = "Linking ";
429
buildEcho += linkLanguage;
430
switch(this->Target->GetType())
432
case cmTarget::STATIC_LIBRARY:
433
buildEcho += " static library ";
435
case cmTarget::SHARED_LIBRARY:
436
buildEcho += " shared library ";
438
case cmTarget::MODULE_LIBRARY:
439
buildEcho += " shared module ";
442
buildEcho += " library ";
445
buildEcho += targetOutPath.c_str();
446
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
447
cmLocalUnixMakefileGenerator3::EchoLink);
454
450
const char* forbiddenFlagVar = 0;
455
451
switch(this->Target->GetType())
457
case cmTarget::STATIC_LIBRARY:
458
buildEcho += " static library ";
460
453
case cmTarget::SHARED_LIBRARY:
461
454
forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS";
462
buildEcho += " shared library ";
464
456
case cmTarget::MODULE_LIBRARY:
465
457
forbiddenFlagVar = "_CREATE_SHARED_MODULE_FORBIDDEN_FLAGS";
466
buildEcho += " shared module ";
469
buildEcho += " library ";
472
buildEcho += targetOutPath.c_str();
473
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
474
cmLocalUnixMakefileGenerator3::EchoLink);
476
// Construct a list of files associated with this library that may
477
// need to be cleaned.
462
// Clean files associated with this library.
478
463
std::vector<std::string> libCleanFiles;
479
if(this->Target->GetPropertyAsBool("CLEAN_DIRECT_OUTPUT"))
481
// The user has requested that only the files directly built
482
// by this target be cleaned instead of all possible names.
483
libCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
484
cmLocalGenerator::START_OUTPUT,
485
cmLocalGenerator::UNCHANGED));
486
if(targetNameReal != targetName)
488
libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
489
cmLocalGenerator::START_OUTPUT,
490
cmLocalGenerator::UNCHANGED));
492
if(targetNameSO != targetName &&
493
targetNameSO != targetNameReal)
495
libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(),
496
cmLocalGenerator::START_OUTPUT,
497
cmLocalGenerator::UNCHANGED));
499
if(!targetNameImport.empty())
501
libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
502
cmLocalGenerator::START_OUTPUT,
503
cmLocalGenerator::UNCHANGED));
508
// This target may switch between static and shared based
509
// on a user option or the BUILD_SHARED_LIBS switch. Clean
510
// all possible names.
511
std::string cleanStaticName;
512
std::string cleanSharedName;
513
std::string cleanSharedSOName;
514
std::string cleanSharedRealName;
515
std::string cleanImportName;
516
std::string cleanPDBName;
517
this->Target->GetLibraryCleanNames(
524
this->LocalGenerator->ConfigurationName.c_str());
525
std::string cleanFullStaticName = outpath + cleanStaticName;
526
std::string cleanFullSharedName = outpath + cleanSharedName;
527
std::string cleanFullSharedSOName = outpath + cleanSharedSOName;
528
std::string cleanFullSharedRealName = outpath + cleanSharedRealName;
529
std::string cleanFullImportName = outpathImp + cleanImportName;
530
std::string cleanFullPDBName = outpath + cleanPDBName;
531
libCleanFiles.push_back
532
(this->Convert(cleanFullStaticName.c_str(),
533
cmLocalGenerator::START_OUTPUT,
534
cmLocalGenerator::UNCHANGED));
535
if(cleanSharedRealName != cleanStaticName)
537
libCleanFiles.push_back(this->Convert(cleanFullSharedRealName.c_str(),
538
cmLocalGenerator::START_OUTPUT,
539
cmLocalGenerator::UNCHANGED));
541
if(cleanSharedSOName != cleanStaticName &&
542
cleanSharedSOName != cleanSharedRealName)
544
libCleanFiles.push_back(this->Convert(cleanFullSharedSOName.c_str(),
545
cmLocalGenerator::START_OUTPUT,
546
cmLocalGenerator::UNCHANGED));
548
if(cleanSharedName != cleanStaticName &&
549
cleanSharedName != cleanSharedSOName &&
550
cleanSharedName != cleanSharedRealName)
552
libCleanFiles.push_back(this->Convert(cleanFullSharedName.c_str(),
553
cmLocalGenerator::START_OUTPUT,
554
cmLocalGenerator::UNCHANGED));
556
if(!cleanImportName.empty())
558
libCleanFiles.push_back(this->Convert(cleanFullImportName.c_str(),
559
cmLocalGenerator::START_OUTPUT,
560
cmLocalGenerator::UNCHANGED));
464
libCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
465
cmLocalGenerator::START_OUTPUT,
466
cmLocalGenerator::UNCHANGED));
467
if(targetNameReal != targetName)
469
libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
470
cmLocalGenerator::START_OUTPUT,
471
cmLocalGenerator::UNCHANGED));
473
if(targetNameSO != targetName &&
474
targetNameSO != targetNameReal)
476
libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(),
477
cmLocalGenerator::START_OUTPUT,
478
cmLocalGenerator::UNCHANGED));
480
if(!targetNameImport.empty())
482
libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
483
cmLocalGenerator::START_OUTPUT,
484
cmLocalGenerator::UNCHANGED));
563
// List the PDB for cleaning only when the whole target is
564
// cleaned. We do not want to delete the .pdb file just before
565
// linking the target.
566
this->CleanFiles.push_back
567
(this->Convert(cleanFullPDBName.c_str(),
568
cmLocalGenerator::START_OUTPUT,
569
cmLocalGenerator::UNCHANGED));
487
// List the PDB for cleaning only when the whole target is
488
// cleaned. We do not want to delete the .pdb file just before
489
// linking the target.
490
this->CleanFiles.push_back
491
(this->Convert(targetFullPathPDB.c_str(),
492
cmLocalGenerator::START_OUTPUT,
493
cmLocalGenerator::UNCHANGED));
573
496
// There may be a manifest file for this target. Add it to the