2006-02-19 23:25:27 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmInstallTargetGenerator.h"
|
|
|
|
|
2006-02-20 03:29:30 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmMakefile.h"
|
2006-06-14 20:28:32 +04:00
|
|
|
#include "cmake.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmInstallTargetGenerator
|
2006-03-04 03:29:35 +03:00
|
|
|
::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib,
|
2006-08-17 22:48:54 +04:00
|
|
|
const char* file_permissions,
|
2006-05-05 22:57:19 +04:00
|
|
|
std::vector<std::string> const& configurations,
|
2006-10-05 19:31:57 +04:00
|
|
|
const char* component, bool optional):
|
2007-06-19 19:11:06 +04:00
|
|
|
cmInstallGenerator(dest), Target(&t), ImportLibrary(implib),
|
2006-08-17 22:48:54 +04:00
|
|
|
FilePermissions(file_permissions), Configurations(configurations),
|
2006-10-05 19:31:57 +04:00
|
|
|
Component(component), Optional(optional)
|
2006-02-19 23:25:27 +03:00
|
|
|
{
|
2006-02-20 01:27:47 +03:00
|
|
|
this->Target->SetHaveInstallRule(true);
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmInstallTargetGenerator
|
|
|
|
::~cmInstallTargetGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
|
|
|
|
{
|
|
|
|
// Compute the build tree directory from which to copy the target.
|
|
|
|
std::string fromDir;
|
|
|
|
if(this->Target->NeedRelinkBeforeInstall())
|
|
|
|
{
|
|
|
|
fromDir = this->Target->GetMakefile()->GetStartOutputDirectory();
|
2006-06-14 20:28:32 +04:00
|
|
|
fromDir += cmake::GetCMakeFilesDirectory();
|
|
|
|
fromDir += "/CMakeRelink.dir/";
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-09 17:30:16 +03:00
|
|
|
fromDir = this->Target->GetDirectory(0, this->ImportLibrary);
|
2006-02-19 23:25:27 +03:00
|
|
|
fromDir += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write variable settings to do per-configuration references.
|
2007-06-19 19:11:06 +04:00
|
|
|
this->PrepareScriptReference(os, this->Target, "BUILD", true, this->ImportLibrary, false);
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Create the per-configuration reference.
|
2006-02-24 21:13:14 +03:00
|
|
|
std::string fromName = this->GetScriptReference(this->Target, "BUILD",
|
2007-06-19 19:11:06 +04:00
|
|
|
this->ImportLibrary, false);
|
2006-02-19 23:25:27 +03:00
|
|
|
std::string fromFile = fromDir;
|
|
|
|
fromFile += fromName;
|
|
|
|
|
2006-03-03 20:58:48 +03:00
|
|
|
// Choose the final destination. This may be modified for certain
|
|
|
|
// target types.
|
|
|
|
std::string destination = this->Destination;
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Setup special properties for some target types.
|
2006-08-22 00:55:03 +04:00
|
|
|
std::string literal_args;
|
2006-02-19 23:25:27 +03:00
|
|
|
std::string props;
|
|
|
|
const char* properties = 0;
|
|
|
|
cmTarget::TargetType type = this->Target->GetType();
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
{
|
|
|
|
// Add shared library installation properties if this platform
|
|
|
|
// supports them.
|
2006-08-01 23:36:49 +04:00
|
|
|
const char* lib_version = 0;
|
|
|
|
const char* lib_soversion = 0;
|
|
|
|
|
|
|
|
// Versioning is supported only for shared libraries and modules,
|
|
|
|
// and then only when the platform supports an soname flag.
|
|
|
|
cmGlobalGenerator* gg =
|
2006-08-03 05:30:58 +04:00
|
|
|
(this->Target->GetMakefile()
|
|
|
|
->GetLocalGenerator()->GetGlobalGenerator());
|
2006-08-01 23:36:49 +04:00
|
|
|
if(const char* linkLanguage = this->Target->GetLinkerLanguage(gg))
|
2006-02-19 23:25:27 +03:00
|
|
|
{
|
2006-08-01 23:36:49 +04:00
|
|
|
std::string sonameFlagVar = "CMAKE_SHARED_LIBRARY_SONAME_";
|
|
|
|
sonameFlagVar += linkLanguage;
|
|
|
|
sonameFlagVar += "_FLAG";
|
|
|
|
if(this->Target->GetMakefile()->GetDefinition(sonameFlagVar.c_str()))
|
|
|
|
{
|
|
|
|
lib_version = this->Target->GetProperty("VERSION");
|
|
|
|
lib_soversion = this->Target->GetProperty("SOVERSION");
|
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
2006-08-01 23:36:49 +04:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
if(lib_version)
|
|
|
|
{
|
|
|
|
props += " VERSION ";
|
|
|
|
props += lib_version;
|
|
|
|
}
|
|
|
|
if(lib_soversion)
|
|
|
|
{
|
|
|
|
props += " SOVERSION ";
|
|
|
|
props += lib_soversion;
|
|
|
|
}
|
|
|
|
properties = props.c_str();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
{
|
|
|
|
// Add executable installation properties if this platform
|
|
|
|
// supports them.
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
const char* exe_version = 0;
|
|
|
|
#else
|
|
|
|
const char* exe_version = this->Target->GetProperty("VERSION");
|
|
|
|
#endif
|
|
|
|
if(exe_version)
|
|
|
|
{
|
|
|
|
props += " VERSION ";
|
|
|
|
props += exe_version;
|
|
|
|
properties = props.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle OSX Bundles.
|
2006-03-28 19:58:14 +04:00
|
|
|
if(this->Target->GetMakefile()->IsOn("APPLE") &&
|
|
|
|
this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
|
2006-02-19 23:25:27 +03:00
|
|
|
{
|
|
|
|
// Compute the source locations of the bundle executable and
|
|
|
|
// Info.plist file.
|
2006-03-03 20:58:48 +03:00
|
|
|
this->PrepareScriptReference(os, this->Target, "INSTALL",
|
2007-06-19 19:11:06 +04:00
|
|
|
false, this->ImportLibrary, false);
|
2006-03-28 22:16:15 +04:00
|
|
|
fromFile += ".app";
|
|
|
|
type = cmTarget::INSTALL_DIRECTORY;
|
2006-08-22 00:55:03 +04:00
|
|
|
literal_args += " USE_SOURCE_PERMISSIONS";
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
// Nothing special for modules or static libraries.
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-02-20 00:10:23 +03:00
|
|
|
// An import library looks like a static library.
|
|
|
|
if(this->ImportLibrary)
|
|
|
|
{
|
|
|
|
type = cmTarget::STATIC_LIBRARY;
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Write code to install the target file.
|
2006-08-17 22:48:54 +04:00
|
|
|
const char* no_dir_permissions = 0;
|
2006-08-22 00:55:03 +04:00
|
|
|
const char* no_rename = 0;
|
2006-10-05 19:31:57 +04:00
|
|
|
bool optional = this->Optional | this->ImportLibrary;
|
2006-03-03 20:58:48 +03:00
|
|
|
this->AddInstallRule(os, destination.c_str(), type, fromFile.c_str(),
|
2006-10-05 19:31:57 +04:00
|
|
|
optional, properties,
|
2006-08-17 22:48:54 +04:00
|
|
|
this->FilePermissions.c_str(), no_dir_permissions,
|
2006-05-05 22:57:19 +04:00
|
|
|
this->Configurations,
|
2006-08-22 00:55:03 +04:00
|
|
|
this->Component.c_str(),
|
|
|
|
no_rename, literal_args.c_str());
|
2006-02-24 21:13:14 +03:00
|
|
|
|
|
|
|
// Fix the install_name settings in installed binaries.
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
if((type == cmTarget::SHARED_LIBRARY ||
|
2006-02-24 21:13:14 +03:00
|
|
|
type == cmTarget::MODULE_LIBRARY ||
|
2007-05-18 01:21:52 +04:00
|
|
|
type == cmTarget::EXECUTABLE))
|
2006-02-24 21:13:14 +03:00
|
|
|
{
|
2006-03-03 20:58:48 +03:00
|
|
|
this->AddInstallNamePatchRule(os, destination.c_str());
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
|
2007-06-15 19:12:07 +04:00
|
|
|
std::string quotedFullDestinationFilename = "\"$ENV{DESTDIR}";
|
|
|
|
quotedFullDestinationFilename += destination;
|
|
|
|
quotedFullDestinationFilename += "/";
|
|
|
|
quotedFullDestinationFilename += cmSystemTools::GetFilenameName(fromFile);
|
|
|
|
quotedFullDestinationFilename += "\"";
|
2007-06-15 21:00:54 +04:00
|
|
|
|
2007-06-15 19:12:07 +04:00
|
|
|
this->AddRanlibRule(os, type, quotedFullDestinationFilename);
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
|
2007-06-15 21:00:54 +04:00
|
|
|
this->AddStripRule(os, type, quotedFullDestinationFilename, optional);
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
|
|
|
|
2007-06-19 19:11:06 +04:00
|
|
|
|
|
|
|
std::string cmInstallTargetGenerator::GetInstallFilename(const char* config) const
|
|
|
|
{
|
|
|
|
return cmInstallTargetGenerator::GetInstallFilename(this->Target, config, this->ImportLibrary, false);
|
|
|
|
}
|
|
|
|
|
2007-06-15 22:27:33 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
|
|
|
|
const char* config,
|
|
|
|
bool implib,
|
|
|
|
bool useSOName)
|
|
|
|
{
|
|
|
|
std::string fname;
|
|
|
|
// Compute the name of the library.
|
|
|
|
if(target->GetType() == cmTarget::EXECUTABLE)
|
|
|
|
{
|
|
|
|
std::string targetName;
|
|
|
|
std::string targetNameReal;
|
|
|
|
std::string targetNameImport;
|
|
|
|
std::string targetNamePDB;
|
|
|
|
target->GetExecutableNames(targetName, targetNameReal,
|
|
|
|
targetNameImport, targetNamePDB,
|
|
|
|
config);
|
|
|
|
if(implib)
|
|
|
|
{
|
|
|
|
// Use the import library name.
|
|
|
|
fname = targetNameImport;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Use the canonical name.
|
|
|
|
fname = targetName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string targetName;
|
|
|
|
std::string targetNameSO;
|
|
|
|
std::string targetNameReal;
|
|
|
|
std::string targetNameImport;
|
|
|
|
std::string targetNamePDB;
|
|
|
|
target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
|
|
|
|
targetNameImport, targetNamePDB, config);
|
|
|
|
if(implib)
|
|
|
|
{
|
|
|
|
// Use the import library name.
|
|
|
|
fname = targetNameImport;
|
|
|
|
}
|
|
|
|
else if(useSOName)
|
|
|
|
{
|
|
|
|
// Use the soname.
|
|
|
|
fname = targetNameSO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Use the canonical name.
|
|
|
|
fname = targetName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return fname;
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmInstallTargetGenerator
|
2006-02-24 21:13:14 +03:00
|
|
|
::PrepareScriptReference(std::ostream& os, cmTarget* target,
|
|
|
|
const char* place, bool useConfigDir,
|
2007-06-19 19:11:06 +04:00
|
|
|
bool implib, bool useSOName)
|
2006-02-19 23:25:27 +03:00
|
|
|
{
|
|
|
|
// If the target name may vary with the configuration type then
|
|
|
|
// store all possible names ahead of time in variables.
|
|
|
|
std::string fname;
|
|
|
|
for(std::vector<std::string>::const_iterator i =
|
|
|
|
this->ConfigurationTypes->begin();
|
|
|
|
i != this->ConfigurationTypes->end(); ++i)
|
|
|
|
{
|
2006-02-24 21:13:14 +03:00
|
|
|
// Initialize the name.
|
2006-02-20 03:29:30 +03:00
|
|
|
fname = "";
|
2006-02-24 21:13:14 +03:00
|
|
|
|
|
|
|
if(useConfigDir)
|
|
|
|
{
|
|
|
|
// Start with the configuration's subdirectory.
|
|
|
|
target->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()->
|
2006-03-03 20:58:48 +03:00
|
|
|
AppendDirectoryForConfig("", i->c_str(), "/", fname);
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
|
|
|
|
2007-06-15 22:27:33 +04:00
|
|
|
fname += this->GetInstallFilename(target, i->c_str(),
|
2007-06-19 19:11:06 +04:00
|
|
|
implib, useSOName);
|
2006-02-20 03:29:30 +03:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Set a variable with the target name for this configuration.
|
2006-02-24 21:13:14 +03:00
|
|
|
os << "SET(" << target->GetName() << "_" << place
|
2007-06-19 19:11:06 +04:00
|
|
|
<< (implib? "_IMPNAME_" : "_NAME_") << *i
|
2006-02-19 23:25:27 +03:00
|
|
|
<< " \"" << fname << "\")\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-02-24 21:13:14 +03:00
|
|
|
std::string cmInstallTargetGenerator::GetScriptReference(cmTarget* target,
|
|
|
|
const char* place,
|
2007-06-19 19:11:06 +04:00
|
|
|
bool implib, bool useSOName)
|
2006-02-19 23:25:27 +03:00
|
|
|
{
|
|
|
|
if(this->ConfigurationTypes->empty())
|
|
|
|
{
|
2006-02-20 00:10:23 +03:00
|
|
|
// Reference the target by its one configuration name.
|
2007-06-15 22:27:33 +04:00
|
|
|
return this->GetInstallFilename(target, this->ConfigurationName,
|
2007-06-19 19:11:06 +04:00
|
|
|
implib, useSOName);
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-20 00:10:23 +03:00
|
|
|
// Reference the target using the per-configuration variable.
|
2006-02-19 23:25:27 +03:00
|
|
|
std::string ref = "${";
|
2006-02-24 21:13:14 +03:00
|
|
|
ref += target->GetName();
|
2007-06-19 19:11:06 +04:00
|
|
|
if(implib)
|
2006-02-19 23:25:27 +03:00
|
|
|
{
|
2006-02-24 21:13:14 +03:00
|
|
|
ref += "_";
|
|
|
|
ref += place;
|
2006-02-19 23:25:27 +03:00
|
|
|
ref += "_IMPNAME_";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-24 21:13:14 +03:00
|
|
|
ref += "_";
|
|
|
|
ref += place;
|
2006-02-19 23:25:27 +03:00
|
|
|
ref += "_NAME_";
|
|
|
|
}
|
|
|
|
ref += "${CMAKE_INSTALL_CONFIG_NAME}}";
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 21:13:14 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-05-11 23:50:11 +04:00
|
|
|
void cmInstallTargetGenerator
|
|
|
|
::AddInstallNamePatchRule(std::ostream& os,
|
|
|
|
const char* destination)
|
2006-02-24 21:13:14 +03:00
|
|
|
{
|
2007-05-18 01:43:32 +04:00
|
|
|
std::string installNameTool =
|
|
|
|
this->Target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
|
2007-05-18 01:21:52 +04:00
|
|
|
|
|
|
|
if(!installNameTool.size())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-24 21:13:14 +03:00
|
|
|
// Build a map of build-tree install_name to install-tree install_name for
|
|
|
|
// shared libraries linked to this target.
|
|
|
|
std::map<cmStdString, cmStdString> install_name_remap;
|
|
|
|
cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
|
|
|
|
const char* config = this->ConfigurationName;
|
|
|
|
if(config && cmSystemTools::UpperCase(config) == "DEBUG")
|
|
|
|
{
|
|
|
|
linkType = cmTarget::DEBUG;
|
|
|
|
}
|
|
|
|
// TODO: Merge with ComputeLinkInformation.
|
2006-03-15 19:02:08 +03:00
|
|
|
const cmTarget::LinkLibraryVectorType& inLibs =
|
|
|
|
this->Target->GetLinkLibraries();
|
|
|
|
for(cmTarget::LinkLibraryVectorType::const_iterator j = inLibs.begin();
|
2006-02-24 21:13:14 +03:00
|
|
|
j != inLibs.end(); ++j)
|
|
|
|
{
|
|
|
|
std::string lib = j->first;
|
|
|
|
if((this->Target->GetType() == cmTarget::EXECUTABLE ||
|
|
|
|
lib != this->Target->GetName()) &&
|
|
|
|
(j->second == cmTarget::GENERAL || j->second == linkType))
|
|
|
|
{
|
2006-05-11 23:50:11 +04:00
|
|
|
if(cmTarget* tgt = this->Target->GetMakefile()->
|
|
|
|
GetLocalGenerator()->GetGlobalGenerator()->
|
2007-05-22 18:24:59 +04:00
|
|
|
FindTarget(0, lib.c_str(), false))
|
2006-02-24 21:13:14 +03:00
|
|
|
{
|
|
|
|
if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
|
|
|
|
{
|
2006-05-11 23:50:11 +04:00
|
|
|
// If the build tree and install tree use different path
|
|
|
|
// components of the install_name field then we need to create a
|
|
|
|
// mapping to be applied after installation.
|
2006-02-24 21:13:14 +03:00
|
|
|
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string for_install =
|
|
|
|
tgt->GetInstallNameDirForInstallTree(config);
|
2006-02-24 21:13:14 +03:00
|
|
|
if(for_build != for_install)
|
|
|
|
{
|
|
|
|
// Map from the build-tree install_name.
|
|
|
|
this->PrepareScriptReference(os, tgt, "REMAP_FROM",
|
2007-06-19 19:11:06 +04:00
|
|
|
!for_build.empty(), false, true);
|
|
|
|
for_build += this->GetScriptReference(tgt, "REMAP_FROM", false, true);
|
2006-02-24 21:13:14 +03:00
|
|
|
|
|
|
|
// Map to the install-tree install_name.
|
|
|
|
this->PrepareScriptReference(os, tgt, "REMAP_TO",
|
2007-06-19 19:11:06 +04:00
|
|
|
false, false, true);
|
|
|
|
for_install += this->GetScriptReference(tgt, "REMAP_TO", false, true);
|
2006-02-24 21:13:14 +03:00
|
|
|
|
|
|
|
// Store the mapping entry.
|
|
|
|
install_name_remap[for_build] = for_install;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edit the install_name of the target itself if necessary.
|
2007-06-19 19:11:06 +04:00
|
|
|
this->PrepareScriptReference(os, this->Target, "REMAPPED", false, this->ImportLibrary, true);
|
2006-02-24 21:13:14 +03:00
|
|
|
std::string new_id;
|
|
|
|
if(this->Target->GetType() == cmTarget::SHARED_LIBRARY)
|
|
|
|
{
|
2006-05-11 23:50:11 +04:00
|
|
|
std::string for_build =
|
|
|
|
this->Target->GetInstallNameDirForBuildTree(config);
|
|
|
|
std::string for_install =
|
|
|
|
this->Target->GetInstallNameDirForInstallTree(config);
|
2006-02-24 21:13:14 +03:00
|
|
|
if(for_build != for_install)
|
|
|
|
{
|
|
|
|
// Prepare to refer to the install-tree install_name.
|
|
|
|
new_id = for_install;
|
2007-06-19 19:11:06 +04:00
|
|
|
new_id += this->GetScriptReference(this->Target, "REMAPPED", this->ImportLibrary, true);
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write a rule to run install_name_tool to set the install-tree
|
|
|
|
// install_name value and references.
|
|
|
|
if(!new_id.empty() || !install_name_remap.empty())
|
|
|
|
{
|
2006-05-11 23:50:11 +04:00
|
|
|
std::string component_test = "NOT CMAKE_INSTALL_COMPONENT OR "
|
|
|
|
"\"${CMAKE_INSTALL_COMPONENT}\" MATCHES \"^(";
|
2006-03-30 22:33:48 +04:00
|
|
|
component_test += this->Component;
|
|
|
|
component_test += ")$\"";
|
|
|
|
os << "IF(" << component_test << ")\n";
|
2007-05-18 01:21:52 +04:00
|
|
|
os << " EXECUTE_PROCESS(COMMAND \"" << installNameTool;
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
os << "\"";
|
2006-02-24 21:13:14 +03:00
|
|
|
if(!new_id.empty())
|
|
|
|
{
|
2006-03-30 22:33:48 +04:00
|
|
|
os << "\n -id \"" << new_id << "\"";
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
|
|
|
for(std::map<cmStdString, cmStdString>::const_iterator
|
|
|
|
i = install_name_remap.begin();
|
|
|
|
i != install_name_remap.end(); ++i)
|
|
|
|
{
|
2006-03-30 22:33:48 +04:00
|
|
|
os << "\n -change \"" << i->first << "\" \"" << i->second << "\"";
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
2006-06-01 23:08:36 +04:00
|
|
|
os << "\n \"$ENV{DESTDIR}" << destination << "/"
|
2007-06-19 19:11:06 +04:00
|
|
|
<< this->GetScriptReference(this->Target, "REMAPPED", this->ImportLibrary, true) << "\")\n";
|
2006-03-30 22:33:48 +04:00
|
|
|
os << "ENDIF(" << component_test << ")\n";
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
|
|
|
}
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
|
|
|
|
void cmInstallTargetGenerator::AddStripRule(std::ostream& os,
|
2007-06-15 21:00:54 +04:00
|
|
|
cmTarget::TargetType type,
|
2007-06-15 19:12:07 +04:00
|
|
|
const std::string& quotedFullDestinationFilename,
|
|
|
|
bool optional)
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
{
|
|
|
|
|
2007-06-15 21:00:54 +04:00
|
|
|
// don't strip static libraries, because it removes the only symbol table
|
|
|
|
// they have so you can't link to them anymore
|
|
|
|
if(type == cmTarget::STATIC_LIBRARY)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
// Don't handle OSX Bundles.
|
|
|
|
if(this->Target->GetMakefile()->IsOn("APPLE") &&
|
|
|
|
this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-15 21:00:54 +04:00
|
|
|
std::string optionalString;
|
2007-06-15 19:12:07 +04:00
|
|
|
if (optional)
|
|
|
|
{
|
2007-06-15 21:00:54 +04:00
|
|
|
optionalString = " AND EXISTS ";
|
|
|
|
optionalString += quotedFullDestinationFilename;
|
2007-06-15 19:12:07 +04:00
|
|
|
}
|
2007-06-15 21:00:54 +04:00
|
|
|
|
|
|
|
os << "IF(CMAKE_INSTALL_DO_STRIP" << optionalString << ")\n";
|
2007-06-15 19:12:07 +04:00
|
|
|
os << " EXECUTE_PROCESS(COMMAND \""
|
|
|
|
<< this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
|
|
|
|
<< "\" " << quotedFullDestinationFilename << " )\n";
|
2007-06-15 21:00:54 +04:00
|
|
|
os << "ENDIF(CMAKE_INSTALL_DO_STRIP" << optionalString << ")\n";
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
|
2007-06-15 19:12:07 +04:00
|
|
|
cmTarget::TargetType type,
|
|
|
|
const std::string& quotedFullDestinationFilename)
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
{
|
|
|
|
// Static libraries need ranlib on this platform.
|
|
|
|
if(type != cmTarget::STATIC_LIBRARY)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform post-installation processing on the file depending
|
|
|
|
// on its type.
|
|
|
|
if(!this->Target->GetMakefile()->IsOn("APPLE"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-18 16:49:06 +04:00
|
|
|
std::string ranlib = this->Target->GetMakefile()->GetRequiredDefinition(
|
|
|
|
"CMAKE_RANLIB");
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
if (!ranlib.size())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os << "EXECUTE_PROCESS(COMMAND \"";
|
|
|
|
os << ranlib;
|
2007-06-15 19:12:07 +04:00
|
|
|
os << "\" " << quotedFullDestinationFilename << " )\n";
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
}
|