ENH: Added ARCHIVE option to the TARGETS mode of the INSTALL command. It is a third option added to RUNTIME and LIBRARY property types. Static libraries and import libraries are now treated as ARCHIVE targets instead of LIBRARY targets. This adds a level of granularity necessary for upcoming features. Also updated the CVS CMake patch level set in CMake_VERSION_PATCH from 4 to 5 to allow users of this version to know whether this incompatible change is present.

This commit is contained in:
Brad King 2006-03-24 16:11:24 -05:00
parent a18297e2ca
commit ca5647c92c
5 changed files with 126 additions and 39 deletions

View File

@ -5,7 +5,7 @@ MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
# The CMake version number. # The CMake version number.
SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 3) SET(CMake_VERSION_MINOR 3)
SET(CMake_VERSION_PATCH 4) SET(CMake_VERSION_PATCH 5)
SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}") SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}")

View File

@ -99,11 +99,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
bool doing_targets = true; bool doing_targets = true;
bool doing_destination = false; bool doing_destination = false;
bool doing_permissions = false; bool doing_permissions = false;
bool archive_settings = true;
bool library_settings = true; bool library_settings = true;
bool runtime_settings = true; bool runtime_settings = true;
std::vector<cmTarget*> targets; std::vector<cmTarget*> targets;
const char* archive_destination = 0;
const char* library_destination = 0; const char* library_destination = 0;
const char* runtime_destination = 0; const char* runtime_destination = 0;
std::string archive_permissions;
std::string library_permissions; std::string library_permissions;
std::string runtime_permissions; std::string runtime_permissions;
for(unsigned int i=1; i < args.size(); ++i) for(unsigned int i=1; i < args.size(); ++i)
@ -122,12 +125,23 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_destination = false; doing_destination = false;
doing_permissions = true; doing_permissions = true;
} }
else if(args[i] == "ARCHIVE")
{
// Switch to setting only archive properties.
doing_targets = false;
doing_destination = false;
doing_permissions = false;
archive_settings = true;
library_settings = false;
runtime_settings = false;
}
else if(args[i] == "LIBRARY") else if(args[i] == "LIBRARY")
{ {
// Switch to setting only library properties. // Switch to setting only library properties.
doing_targets = false; doing_targets = false;
doing_destination = false; doing_destination = false;
doing_permissions = false; doing_permissions = false;
archive_settings = false;
library_settings = true; library_settings = true;
runtime_settings = false; runtime_settings = false;
} }
@ -137,6 +151,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
doing_targets = false; doing_targets = false;
doing_destination = false; doing_destination = false;
doing_permissions = false; doing_permissions = false;
archive_settings = false;
library_settings = false; library_settings = false;
runtime_settings = true; runtime_settings = true;
} }
@ -174,6 +189,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
else if(doing_destination) else if(doing_destination)
{ {
// Set the destination in the active set(s) of properties. // Set the destination in the active set(s) of properties.
if(archive_settings)
{
archive_destination = args[i].c_str();
}
if(library_settings) if(library_settings)
{ {
library_destination = args[i].c_str(); library_destination = args[i].c_str();
@ -187,6 +206,18 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
else if(doing_permissions) else if(doing_permissions)
{ {
// Set the permissions in the active set(s) of properties. // Set the permissions in the active set(s) of properties.
if(archive_settings)
{
// Check the requested permission.
if(!this->CheckPermissions(args[i], archive_permissions))
{
cmOStringStream e;
e << args[0] << " given invalid permission \""
<< args[i] << "\".";
this->SetError(e.str().c_str());
return false;
}
}
if(library_settings) if(library_settings)
{ {
// Check the requested permission. // Check the requested permission.
@ -227,15 +258,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
{ {
return true; return true;
} }
if(!library_destination && !runtime_destination) if(!archive_destination && !library_destination && !runtime_destination)
{ {
this->SetError("TARGETS given no DESTINATION!"); this->SetError("TARGETS given no DESTINATION!");
return false; return false;
} }
// Compute destination paths. // Compute destination paths.
std::string archive_dest;
std::string library_dest; std::string library_dest;
std::string runtime_dest; std::string runtime_dest;
this->ComputeDestination(archive_destination, archive_dest);
this->ComputeDestination(library_destination, library_dest); this->ComputeDestination(library_destination, library_dest);
this->ComputeDestination(runtime_destination, runtime_dest); this->ComputeDestination(runtime_destination, runtime_dest);
@ -255,12 +288,12 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// platform. // platform.
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
// This is a DLL platform. // This is a DLL platform.
if(library_destination) if(archive_destination)
{ {
// The import library uses the LIBRARY properties. // The import library uses the ARCHIVE properties.
this->Makefile->AddInstallGenerator( this->Makefile->AddInstallGenerator(
new cmInstallTargetGenerator(target, library_dest.c_str(), true, new cmInstallTargetGenerator(target, archive_dest.c_str(), true,
library_permissions.c_str())); archive_permissions.c_str()));
} }
if(runtime_destination) if(runtime_destination)
{ {
@ -278,13 +311,39 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
new cmInstallTargetGenerator(target, library_dest.c_str(), false, new cmInstallTargetGenerator(target, library_dest.c_str(), false,
library_permissions.c_str())); library_permissions.c_str()));
} }
else
{
cmOStringStream e;
e << "TARGETS given no LIBRARY DESTINATION for shared library "
"target \"" << target.GetName() << "\".";
this->SetError(e.str().c_str());
return false;
}
#endif #endif
} }
break; break;
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
{
// Static libraries use ARCHIVE properties.
if(archive_destination)
{
this->Makefile->AddInstallGenerator(
new cmInstallTargetGenerator(target, archive_dest.c_str(), false,
archive_permissions.c_str()));
}
else
{
cmOStringStream e;
e << "TARGETS given no ARCHIVE DESTINATION for static library "
"target \"" << target.GetName() << "\".";
this->SetError(e.str().c_str());
return false;
}
}
break;
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
{ {
// Static libraries and modules use LIBRARY properties. // Modules use LIBRARY properties.
if(library_destination) if(library_destination)
{ {
this->Makefile->AddInstallGenerator( this->Makefile->AddInstallGenerator(
@ -294,16 +353,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
else else
{ {
cmOStringStream e; cmOStringStream e;
e << "TARGETS given no LIBRARY DESTINATION for "; e << "TARGETS given no LIBRARY DESTINATION for module target \""
if(target.GetType() == cmTarget::STATIC_LIBRARY) << target.GetName() << "\".";
{
e << "static library";
}
else
{
e << "module";
}
e << " target \"" << target.GetName() << "\".";
this->SetError(e.str().c_str()); this->SetError(e.str().c_str());
return false; return false;
} }

View File

@ -88,22 +88,26 @@ public:
"when a single file is installed by the command. " "when a single file is installed by the command. "
"\n" "\n"
"The TARGETS signature:\n" "The TARGETS signature:\n"
" INSTALL(TARGETS targets... [[LIBRARY|RUNTIME]\n" " INSTALL(TARGETS targets... [[ARCHIVE|LIBRARY|RUNTIME]\n"
" [DESTINATION <dir>]\n" " [DESTINATION <dir>]\n"
" [PERMISSIONS permissions...]\n" " [PERMISSIONS permissions...]\n"
" ] [...])\n" " ] [...])\n"
"The TARGETS form specifies rules for installing targets from a " "The TARGETS form specifies rules for installing targets from a "
"project. There are two kinds of target files that may be " "project. There are three kinds of target files that may be "
"installed: library and runtime. Static libraries and modules " "installed: archive, library, and runtime. "
"are always treated as library targets. Executables are always "
"treated as runtime targets. For non-DLL platforms, shared libraries " "Executables are always treated as runtime targets. "
"are treated as library targets. For DLL platforms, the DLL part of " "Static libraries are always treated as archive targets. "
"a shared library is treated as a runtime target and the corresponding " "Module libraries are always treated as library targets. "
"import library is treated as a library target. All Windows-based " "For non-DLL platforms shared libraries are treated as library targets. "
"systems including Cygwin are DLL platforms. The LIBRARY and RUNTIME " "For DLL platforms the DLL part of a shared library is treated as "
"arguments change the type of target to which the following properties " "a runtime target and the corresponding import library is treated as "
"apply. If neither is given the installation properties apply to " "an archive target. "
"both target types. If only one is given then only targets of that " "All Windows-based systems including Cygwin are DLL platforms. "
"The ARCHIVE, LIBRARY, and RUNTIME "
"arguments change the type of target to which the subsequent properties "
"apply. If none is given the installation properties apply to "
"all target types. If only one is given then only targets of that "
"type will be installed (which can be used to install just a DLL or " "type will be installed (which can be used to install just a DLL or "
"just an import library)." "just an import library)."
"\n" "\n"
@ -113,14 +117,16 @@ public:
"targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n" "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n"
" INSTALL(TARGETS myExe mySharedLib myStaticLib\n" " INSTALL(TARGETS myExe mySharedLib myStaticLib\n"
" RUNTIME DESTINATION bin\n" " RUNTIME DESTINATION bin\n"
" LIBRARY DESTINATION lib)\n" " LIBRARY DESTINATION lib\n"
" ARCHIVE DESTINATION lib/static)\n"
" INSTALL(TARGETS mySharedLib DESTINATION /some/full/path)\n" " INSTALL(TARGETS mySharedLib DESTINATION /some/full/path)\n"
"will install myExe to <prefix>/bin and myStaticLib to <prefix>/lib. " "will install myExe to <prefix>/bin and myStaticLib to "
"<prefix>/lib/static. "
"On non-DLL platforms mySharedLib will be installed to <prefix>/lib and " "On non-DLL platforms mySharedLib will be installed to <prefix>/lib and "
"/some/full/path. On DLL platforms the mySharedLib DLL will be " "/some/full/path. On DLL platforms the mySharedLib DLL will be "
"installed to <prefix>/bin and /some/full/path and its import library " "installed to <prefix>/bin and /some/full/path and its import library "
"will be installed to <prefix>/lib and /some/full/path. On non-DLL " "will be installed to <prefix>/lib/static and /some/full/path. "
"platforms mySharedLib will be installed to <prefix>/lib and " "On non-DLL platforms mySharedLib will be installed to <prefix>/lib and "
"/some/full/path." "/some/full/path."
"\n" "\n"
"The FILES signature:\n" "The FILES signature:\n"

View File

@ -22,7 +22,10 @@ SET(EXTRA_INSTALL_FLAGS)
MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}") MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}")
IF(STAGE2) IF(STAGE2)
SET(LIBPATHS "${CMAKE_INSTALL_PREFIX}/MyTest/lib") SET(LIBPATHS
${CMAKE_INSTALL_PREFIX}/MyTest/lib/static
${CMAKE_INSTALL_PREFIX}/MyTest/lib
)
SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX}) SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX})
SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX}) SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX}) SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX})
@ -63,6 +66,12 @@ IF(STAGE2)
TARGET_LINK_LIBRARIES(SimpleInstallS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY}) TARGET_LINK_LIBRARIES(SimpleInstallS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY})
SET(install_target SimpleInstallS2) SET(install_target SimpleInstallS2)
IF("${TEST1_LIBRARY}" MATCHES "static")
MESSAGE(STATUS "test1 correctly found in lib/static")
ELSE("${TEST1_LIBRARY}" MATCHES "static")
MESSAGE(SEND_ERROR "test1 not found in lib/static!")
ENDIF("${TEST1_LIBRARY}" MATCHES "static")
# Make sure the test executable can run from the install tree. # Make sure the test executable can run from the install tree.
SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
@ -93,9 +102,15 @@ ELSE(STAGE2)
ADD_DEPENDENCIES(test4 test2) ADD_DEPENDENCIES(test4 test2)
INSTALL(TARGETS SimpleInstall test1 test2 test3 INSTALL(TARGETS SimpleInstall test1 test2 test3
RUNTIME DESTINATION MyTest/bin LIBRARY DESTINATION MyTest/lib) RUNTIME DESTINATION MyTest/bin # .exe, .dll
LIBRARY DESTINATION MyTest/lib # .so, module.dll, ...
ARCHIVE DESTINATION MyTest/lib/static # .a, .lib
)
INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
RUNTIME DESTINATION MyTest/bin LIBRARY DESTINATION MyTest/lib) RUNTIME DESTINATION MyTest/bin
LIBRARY DESTINATION MyTest/lib
ARCHIVE DESTINATION MyTest/lib/static
)
INSTALL(FILES lib1.h DESTINATION MyTest/include/foo) INSTALL(FILES lib1.h DESTINATION MyTest/include/foo)
INSTALL(FILES lib2.h INSTALL(FILES lib2.h
DESTINATION MyTest/include/foo DESTINATION MyTest/include/foo

View File

@ -22,7 +22,10 @@ SET(EXTRA_INSTALL_FLAGS)
MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}") MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}")
IF(STAGE2) IF(STAGE2)
SET(LIBPATHS "${CMAKE_INSTALL_PREFIX}/MyTest/lib") SET(LIBPATHS
${CMAKE_INSTALL_PREFIX}/MyTest/lib/static
${CMAKE_INSTALL_PREFIX}/MyTest/lib
)
SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX}) SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX})
SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX}) SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX}) SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX})
@ -63,6 +66,12 @@ IF(STAGE2)
TARGET_LINK_LIBRARIES(SimpleInstallS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY}) TARGET_LINK_LIBRARIES(SimpleInstallS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY})
SET(install_target SimpleInstallS2) SET(install_target SimpleInstallS2)
IF("${TEST1_LIBRARY}" MATCHES "static")
MESSAGE(STATUS "test1 correctly found in lib/static")
ELSE("${TEST1_LIBRARY}" MATCHES "static")
MESSAGE(SEND_ERROR "test1 not found in lib/static!")
ENDIF("${TEST1_LIBRARY}" MATCHES "static")
# Make sure the test executable can run from the install tree. # Make sure the test executable can run from the install tree.
SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
@ -93,9 +102,15 @@ ELSE(STAGE2)
ADD_DEPENDENCIES(test4 test2) ADD_DEPENDENCIES(test4 test2)
INSTALL(TARGETS SimpleInstall test1 test2 test3 INSTALL(TARGETS SimpleInstall test1 test2 test3
RUNTIME DESTINATION MyTest/bin LIBRARY DESTINATION MyTest/lib) RUNTIME DESTINATION MyTest/bin # .exe, .dll
LIBRARY DESTINATION MyTest/lib # .so, module.dll, ...
ARCHIVE DESTINATION MyTest/lib/static # .a, .lib
)
INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
RUNTIME DESTINATION MyTest/bin LIBRARY DESTINATION MyTest/lib) RUNTIME DESTINATION MyTest/bin
LIBRARY DESTINATION MyTest/lib
ARCHIVE DESTINATION MyTest/lib/static
)
INSTALL(FILES lib1.h DESTINATION MyTest/include/foo) INSTALL(FILES lib1.h DESTINATION MyTest/include/foo)
INSTALL(FILES lib2.h INSTALL(FILES lib2.h
DESTINATION MyTest/include/foo DESTINATION MyTest/include/foo