ENH: Added target property CLEAN_DIRECT_OUTPUT to not clean all forms of a library name so that static and shared libraries of the same name can coexist in a single build directory.

This commit is contained in:
Brad King 2006-08-03 09:42:48 -04:00
parent 24b55bfe11
commit 441d208bb3
3 changed files with 101 additions and 49 deletions

View File

@ -305,7 +305,41 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Construct a list of files associated with this library that may // Construct a list of files associated with this library that may
// need to be cleaned. // need to be cleaned.
std::vector<std::string> libCleanFiles; std::vector<std::string> libCleanFiles;
if(this->Target->GetPropertyAsBool("CLEAN_DIRECT_OUTPUT"))
{ {
// The user has requested that only the files directly built
// by this target be cleaned instead of all possible names.
libCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
if(targetNameReal != targetName)
{
libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(targetNameSO != targetName &&
targetNameSO != targetNameReal)
{
libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(!targetNameImport.empty() &&
targetNameImport != targetName &&
targetNameImport != targetNameReal &&
targetNameImport != targetNameSO)
{
libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
}
else
{
// This target may switch between static and shared based
// on a user option or the BUILD_SHARED_LIBS switch. Clean
// all possible names.
std::string cleanStaticName; std::string cleanStaticName;
std::string cleanSharedName; std::string cleanSharedName;
std::string cleanSharedSOName; std::string cleanSharedSOName;

View File

@ -133,6 +133,13 @@ public:
"the target in an IDE like visual studio. VS_KEYWORD can be set " "the target in an IDE like visual studio. VS_KEYWORD can be set "
"to change the visual studio keyword, for example QT integration " "to change the visual studio keyword, for example QT integration "
"works better if this is set to Qt4VSv1.0.\n" "works better if this is set to Qt4VSv1.0.\n"
"When a library is built CMake by default generates code to remove "
"any existing library using all possible names. This is needed "
"to support libraries that switch between STATIC and SHARED by "
"a user option. However when using OUTPUT_NAME to build a static "
"and shared library of the same name using different logical target "
"names the two targets will remove each other's files. This can be "
"prevented by setting the CLEAN_DIRECT_OUTPUT property to 1.\n"
"The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the "
"old way to specify CMake scripts to run before and after " "old way to specify CMake scripts to run before and after "
"installing a target. They are used only when the old " "installing a target. They are used only when the old "

View File

@ -1158,6 +1158,17 @@ void cmTarget::GetFullNameInternal(TargetType type,
return; return;
} }
// Return an empty name for the import library if this platform
// does not support import libraries.
if(implib &&
!this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
{
outPrefix = "";
outBase = "";
outSuffix = "";
return;
}
// The implib option is only allowed for shared libraries. // The implib option is only allowed for shared libraries.
if(type != cmTarget::SHARED_LIBRARY) if(type != cmTarget::SHARED_LIBRARY)
{ {