--- Help/command/find_library.rst | 5 +++++ Help/manual/cmake-properties.7.rst | 1 + Modules/FindPkgConfig.cmake | 5 ++++- Source/cmFindLibraryCommand.cxx | 9 ++++++--- Source/cmFindPackageCommand.cxx | 22 +++++++++++++++++----- Source/cmFindPackageCommand.h | 1 + 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst index 67bd5e7..414f787 100644 --- a/Help/command/find_library.rst +++ b/Help/command/find_library.rst @@ -48,6 +48,11 @@ path to the framework ``/A.framework``. When a full path to a framework is used as a library, CMake will use a ``-framework A``, and a ``-F`` to link the framework to the target. +If the :prop_gbl:`FIND_LIBRARY_USE_CUSTOM_SUFFIX` global property is set +all search paths will be tested as normal, with `LIB_SUFFIX` appended, and +with all matches of ``lib/`` replaced with `lib${LIB_SUFFIX}/`. This property +overrides both FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS. + If the :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` global property is set all search paths will be tested as normal, with ``32/`` appended, and with all matches of ``lib/`` replaced with ``lib32/``. This property is diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 173ba36..3b86909 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -24,6 +24,7 @@ Properties of Global Scope /prop_gbl/DISABLED_FEATURES /prop_gbl/ENABLED_FEATURES /prop_gbl/ENABLED_LANGUAGES + /prop_gbl/FIND_LIBRARY_USE_CUSTOM_SUFFIX /prop_gbl/FIND_LIBRARY_USE_LIB32_PATHS /prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS /prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 704040f..87decf9 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -250,7 +250,10 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma if(NOT DEFINED CMAKE_SYSTEM_NAME OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" AND NOT CMAKE_CROSSCOMPILING)) - if(EXISTS "/etc/debian_version") # is this a debian system ? + get_property(uselibcustom GLOBAL PROPERTY FIND_LIBRARY_USE_CUSTOM_SUFFIX) + if(uselibcustom) + list(APPEND _lib_dirs "lib${LIB_SUFFIX}/pkgconfig") + elseif(EXISTS "/etc/debian_version") # is this a debian system ? if(CMAKE_LIBRARY_ARCHITECTURE) list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") endif() diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index ed85887..5b8b1d8 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -42,15 +42,18 @@ bool cmFindLibraryCommand return true; } - if (this->Makefile->GetState()->GetGlobalPropertyAsBool( + if (this->Makefile->GetDefinition("FIND_LIBRARY_USE_CUSTOM_SUFFIX") && + this->Makefile->GetDefinition("LIB_SUFFIX") ) { + this->AddArchitecturePaths(this->Makefile->GetDefinition("LIB_SUFFIX")); + } + else if (this->Makefile->GetState()->GetGlobalPropertyAsBool( "FIND_LIBRARY_USE_LIB32_PATHS")) { // add special 32 bit paths if this is a 32 bit compile. if (this->Makefile->PlatformIs32Bit()) { this->AddArchitecturePaths("32"); } } - - if(this->Makefile->GetState() + else if(this->Makefile->GetState() ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) { // add special 64 bit paths if this is a 64 bit compile. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index e6a7e75..725273e 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -45,6 +45,7 @@ cmFindPackageCommand::cmFindPackageCommand() this->UseConfigFiles = true; this->UseFindModules = true; this->DebugMode = false; + this->UseLibCustomPaths = false; this->UseLib32Paths = false; this->UseLib64Paths = false; this->PolicyScope = true; @@ -118,15 +119,19 @@ bool cmFindPackageCommand this->LibraryArchitecture = arch; } + if (this->Makefile->GetState()->GetGlobalPropertyAsBool( + "FIND_LIBRARY_USE_CUSTOM_SUFFIX")) { + this->UseLibCustomPaths = true; + std::cout << "FIND_LIBRARY_USE_CUSTOM_SUFFIX" << std::endl; + } // Lookup whether lib32 paths should be used. - if (this->Makefile->PlatformIs32Bit() && + else if (this->Makefile->PlatformIs32Bit() && this->Makefile->GetState()->GetGlobalPropertyAsBool( "FIND_LIBRARY_USE_LIB32_PATHS")) { this->UseLib32Paths = true; } - // Lookup whether lib64 paths should be used. - if(this->Makefile->PlatformIs64Bit() && + else if(this->Makefile->PlatformIs64Bit() && this->Makefile->GetState() ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) { @@ -2117,11 +2122,18 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { common.push_back("lib/"+this->LibraryArchitecture); } - if (this->UseLib32Paths) + if (this->UseLibCustomPaths && + this->Makefile->GetDefinition("LIB_SUFFIX")) { + std::string custom_lib = "lib"; + custom_lib += this->Makefile->GetDefinition("LIB_SUFFIX"); + common.push_back(custom_lib.c_str()); + std::cout << "UseLibCustomPaths() - " << custom_lib << std::endl; + } + else if (this->UseLib32Paths) { common.push_back("lib32"); } - if(this->UseLib64Paths) + else if(this->UseLib64Paths) { common.push_back("lib64"); } diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index d6f7a23..2c9024f 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -138,6 +138,7 @@ private: bool NoUserRegistry; bool NoSystemRegistry; bool DebugMode; + bool UseLibCustomPaths; bool UseLib32Paths; bool UseLib64Paths; bool PolicyScope; -- 2.7.3