diff options
author | Brad King <brad.king@kitware.com> | 2011-06-08 12:46:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-06-08 14:04:44 (GMT) |
commit | b41ad3b399c591f8f35eaacf056ffd9016b9e0bc (patch) | |
tree | 5d44f207b90ac15c1ed6b34358cdfe62e7e9ca27 /Source | |
parent | 0f939ee16478ad638bb380a75b4867b072a09306 (diff) | |
download | CMake-b41ad3b399c591f8f35eaacf056ffd9016b9e0bc.zip CMake-b41ad3b399c591f8f35eaacf056ffd9016b9e0bc.tar.gz CMake-b41ad3b399c591f8f35eaacf056ffd9016b9e0bc.tar.bz2 |
Teach find_(library|package) about Linux multiarch (#12037)
Implement support for multiarch as specified here:
http://wiki.debian.org/Multiarch
https://wiki.ubuntu.com/MultiarchSpec
Detect the <arch> part of <prefix>/lib/<arch> from the implicit library
search path from each compiler to set CMAKE_<lang>_LIBRARY_ARCHITECTURE.
Define CMAKE_LIBRARY_ARCHITECTURE using one of these values (they should
all be the same). Teach the find_library and find_package commands to
search <prefix>/lib/<arch> whenever they would search <prefix>/lib.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentVariables.cxx | 20 | ||||
-rw-r--r-- | Source/cmFindBase.cxx | 12 | ||||
-rw-r--r-- | Source/cmFindLibraryCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 24 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.h | 1 | ||||
-rw-r--r-- | Source/cmFindPathCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 2 |
7 files changed, 59 insertions, 6 deletions
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 994445d..ea25e60 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -822,6 +822,18 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "set to the output of uname -r. On other " "systems this is set to major-minor version numbers.",false, "Variables That Describe the System"); + cm->DefineProperty + ("CMAKE_LIBRARY_ARCHITECTURE", cmProperty::VARIABLE, + "Target architecture library directory name, if detected.", + "This is the value of CMAKE_<lang>_LIBRARY_ARCHITECTURE as " + "detected for one of the enabled languages.",false, + "Variables That Describe the System"); + cm->DefineProperty + ("CMAKE_LIBRARY_ARCHITECTURE_REGEX", cmProperty::VARIABLE, + "Regex matching possible target architecture library directory names.", + "This is used to detect CMAKE_<lang>_LIBRARY_ARCHITECTURE from the " + "implicit linker search path by matching the <arch> name.",false, + "Variables That Describe the System"); cm->DefineProperty ("CMAKE_HOST_SYSTEM", cmProperty::VARIABLE, @@ -1360,6 +1372,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables for Languages"); cm->DefineProperty + ("CMAKE_<LANG>_LIBRARY_ARCHITECTURE", cmProperty::VARIABLE, + "Target architecture library directory name detected for <lang>.", + "If the <lang> compiler passes to the linker an architecture-specific " + "system library search directory such as <prefix>/lib/<arch> this " + "variable contains the <arch> name if/as detected by CMake.",false, + "Variables for Languages"); + + cm->DefineProperty ("CMAKE_<LANG>_LINKER_PREFERENCE_PROPAGATES", cmProperty::VARIABLE, "True if CMAKE_<LANG>_LINKER_PREFERENCE propagates across targets.", "This is used when CMake selects a linker language for a target. " diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index d0fe99f..ce9deb1 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -72,12 +72,14 @@ void cmFindBase::GenerateDocumentation() "1. Search paths specified in cmake-specific cache variables. " "These are intended to be used on the command line with a -DVAR=value. " "This can be skipped if NO_CMAKE_PATH is passed.\n" + "XXX_EXTRA_PREFIX_ENTRY" " <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_PREFIX_PATH\n" " CMAKE_XXX_PATH\n" " CMAKE_XXX_MAC_PATH\n" "2. Search paths specified in cmake-specific environment variables. " "These are intended to be set in the user's shell configuration. " "This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" + "XXX_EXTRA_PREFIX_ENTRY" " <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_PREFIX_PATH\n" " CMAKE_XXX_PATH\n" " CMAKE_XXX_MAC_PATH\n" @@ -92,6 +94,7 @@ void cmFindBase::GenerateDocumentation() "5. Search cmake variables defined in the Platform files " "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " "is passed.\n" + "XXX_EXTRA_PREFIX_ENTRY" " <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_SYSTEM_PREFIX_PATH\n" " CMAKE_SYSTEM_XXX_PATH\n" " CMAKE_SYSTEM_XXX_MAC_PATH\n" @@ -346,6 +349,15 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths, { dir += "/"; } + if(subdir == "lib") + { + const char* arch = + this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); + if(arch && *arch) + { + this->AddPathInternal(dir+"lib/"+arch, pathType); + } + } std::string add = dir + subdir; if(add != "/") { diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index b309376..6355a85 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -44,6 +44,10 @@ void cmFindLibraryCommand::GenerateDocumentation() "SEARCH_XXX", "library"); cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "lib"); + cmSystemTools::ReplaceString( + this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", + " <prefix>/lib/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and\n"); cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY"); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index b77273c..5f106bc 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -243,9 +243,9 @@ void cmFindPackageCommand::GenerateDocumentation() " <prefix>/(cmake|CMake)/ (W)\n" " <prefix>/<name>*/ (W)\n" " <prefix>/<name>*/(cmake|CMake)/ (W)\n" - " <prefix>/(share|lib)/cmake/<name>*/ (U)\n" - " <prefix>/(share|lib)/<name>*/ (U)\n" - " <prefix>/(share|lib)/<name>*/(cmake|CMake)/ (U)\n" + " <prefix>/(lib/<arch>|lib|share)/cmake/<name>*/ (U)\n" + " <prefix>/(lib/<arch>|lib|share)/<name>*/ (U)\n" + " <prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/ (U)\n" "On systems supporting OS X Frameworks and Application Bundles " "the following directories are searched for frameworks or bundles " "containing a configuration file:\n" @@ -257,6 +257,7 @@ void cmFindPackageCommand::GenerateDocumentation() " <prefix>/<name>.app/Contents/Resources/CMake/ (A)\n" "In all cases the <name> is treated as case-insensitive and corresponds " "to any of the names specified (<package> or names given by NAMES). " + "Paths with lib/<arch> are enabled if CMAKE_LIBRARY_ARCHITECTURE is set. " "If PATH_SUFFIXES is specified the suffixes are appended to each " "(W) or (U) directory entry one-by-one.\n" "This set of directories is intended to work in cooperation with " @@ -362,6 +363,13 @@ bool cmFindPackageCommand // Check for debug mode. this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE"); + // Lookup target architecture, if any. + if(const char* arch = + this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) + { + this->LibraryArchitecture = arch; + } + // Lookup whether lib64 paths should be used. if(this->Makefile->PlatformIs64Bit() && this->Makefile->GetCMakeInstance() @@ -2189,6 +2197,10 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) // Construct list of common install locations (lib and share). std::vector<std::string> common; + if(!this->LibraryArchitecture.empty()) + { + common.push_back("lib/"+this->LibraryArchitecture); + } if(this->UseLib64Paths) { common.push_back("lib64"); @@ -2196,7 +2208,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) common.push_back("lib"); common.push_back("share"); - // PREFIX/(share|lib)/cmake/(Foo|foo|FOO).*/ + // PREFIX/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/ { cmFindPackageFileList lister(this); lister @@ -2210,7 +2222,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } - // PREFIX/(share|lib)/(Foo|foo|FOO).*/ + // PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/ { cmFindPackageFileList lister(this); lister @@ -2223,7 +2235,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } - // PREFIX/(share|lib)/(Foo|foo|FOO).*/(cmake|CMake)/ + // PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/ { cmFindPackageFileList lister(this); lister diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 4229d37..2b2e1da 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -141,6 +141,7 @@ private: bool DebugMode; bool UseLib64Paths; bool PolicyScope; + std::string LibraryArchitecture; std::vector<std::string> Names; std::vector<std::string> Configs; std::set<std::string> IgnoredPaths; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 83b651b..846d187 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -46,6 +46,8 @@ void cmFindPathCommand::GenerateDocumentation() cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "include"); cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", ""); + cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"); if(!this->IncludeFileInPath) diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 71cfdcb..7c56ad7 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -42,6 +42,8 @@ void cmFindProgramCommand::GenerateDocumentation() cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "[s]bin"); cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", ""); + cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM"); } |