Teach find_library and find_package to search lib32 paths (#11260)

Add a ``FIND_LIBRARY_USE_LIB32_PATHS`` global property analogous to the
``FIND_LIBRARY_USE_LIB64_PATHS`` property.  This helps find commands on
multilib systems that use ``lib32`` directories and either do not have
``lib`` symlinks or point ``lib`` to ``lib64``.
This commit is contained in:
Daniel Scharrer 2016-06-10 16:11:18 +02:00 committed by Brad King
parent c5d71b28ec
commit 896ad251de
28 changed files with 110 additions and 27 deletions

View File

@ -49,6 +49,13 @@ path to the framework ``<fullPath>/A.framework``. When a full path to a
framework is used as a library, CMake will use a ``-framework A``, and a framework is used as a library, CMake will use a ``-framework A``, and a
``-F<fullPath>`` to link the framework to the target. ``-F<fullPath>`` to link the framework to the target.
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
automatically set for the platforms that are known to need it if at
least one of the languages supported by the :command:`project` command
is enabled.
If the :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global property is set If the :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global property is set
all search paths will be tested as normal, with ``64/`` appended, and all search paths will be tested as normal, with ``64/`` appended, and
with all matches of ``lib/`` replaced with ``lib64/``. This property is with all matches of ``lib/`` replaced with ``lib64/``. This property is

View File

@ -24,6 +24,7 @@ Properties of Global Scope
/prop_gbl/DISABLED_FEATURES /prop_gbl/DISABLED_FEATURES
/prop_gbl/ENABLED_FEATURES /prop_gbl/ENABLED_FEATURES
/prop_gbl/ENABLED_LANGUAGES /prop_gbl/ENABLED_LANGUAGES
/prop_gbl/FIND_LIBRARY_USE_LIB32_PATHS
/prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS /prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS
/prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING /prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING
/prop_gbl/GLOBAL_DEPENDS_DEBUG_MODE /prop_gbl/GLOBAL_DEPENDS_DEBUG_MODE

View File

@ -0,0 +1,10 @@
FIND_LIBRARY_USE_LIB32_PATHS
----------------------------
Whether the :command:`find_library` command should automatically search
``lib32`` directories.
``FIND_LIBRARY_USE_LIB32_PATHS`` is a boolean specifying whether the
:command:`find_library` command should automatically search the ``lib32``
variant of directories called ``lib`` in the search path when building 32-bit
binaries.

View File

@ -0,0 +1,7 @@
find-lib32
----------
* The :command:`find_library` and :command:`find_package` commands learned
to search in ``lib32/`` directories when the build targets a 32-bit
architecture. See the :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` global
property.

View File

@ -316,9 +316,13 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
endif() endif()
else() else()
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
list(APPEND _lib_dirs "lib32/pkgconfig")
endif()
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64) if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND _lib_dirs "lib64/pkgconfig") list(APPEND _lib_dirs "lib64/pkgconfig")
endif() endif()
endif() endif()

View File

@ -50,8 +50,9 @@ set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_
include(Platform/UnixPaths) include(Platform/UnixPaths)
# Debian has lib64 paths only for compatibility so they should not be # Debian has lib32 and lib64 paths only for compatibility so they should not be
# searched. # searched.
if(NOT CMAKE_CROSSCOMPILING AND EXISTS "/etc/debian_version") if(NOT CMAKE_CROSSCOMPILING AND EXISTS "/etc/debian_version")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
endif() endif()

View File

@ -18,6 +18,7 @@ endif()
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1)
# OpenBSD has no multilib # OpenBSD has no multilib
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
# OpenBSD policy requires that shared libraries be installed without # OpenBSD policy requires that shared libraries be installed without

View File

@ -93,5 +93,6 @@ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
/usr/include /usr/include
) )
# Enable use of lib64 search path variants by default. # Enable use of lib32 and lib64 search path variants by default.
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)

View File

@ -40,11 +40,10 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn,
return true; return true;
} }
if (const char* abi_name = if (this->Makefile->GetState()->GetGlobalPropertyAsBool(
this->Makefile->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { "FIND_LIBRARY_USE_LIB32_PATHS")) {
std::string abi = abi_name; // add special 32 bit paths if this is a 32 bit compile.
if (abi.find("ELF N32") != abi.npos) { if (this->Makefile->PlatformIs32Bit()) {
// Convert lib to lib32.
this->AddArchitecturePaths("32"); this->AddArchitecturePaths("32");
} }
} }

View File

@ -43,6 +43,7 @@ cmFindPackageCommand::cmFindPackageCommand()
this->UseConfigFiles = true; this->UseConfigFiles = true;
this->UseFindModules = true; this->UseFindModules = true;
this->DebugMode = false; this->DebugMode = false;
this->UseLib32Paths = false;
this->UseLib64Paths = false; this->UseLib64Paths = false;
this->PolicyScope = true; this->PolicyScope = true;
this->VersionMajor = 0; this->VersionMajor = 0;
@ -110,6 +111,13 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
this->LibraryArchitecture = arch; this->LibraryArchitecture = arch;
} }
// Lookup whether lib32 paths should be used.
if (this->Makefile->PlatformIs32Bit() &&
this->Makefile->GetState()->GetGlobalPropertyAsBool(
"FIND_LIBRARY_USE_LIB32_PATHS")) {
this->UseLib32Paths = true;
}
// Lookup whether lib64 paths should be used. // Lookup whether lib64 paths should be used.
if (this->Makefile->PlatformIs64Bit() && if (this->Makefile->PlatformIs64Bit() &&
this->Makefile->GetState()->GetGlobalPropertyAsBool( this->Makefile->GetState()->GetGlobalPropertyAsBool(
@ -1907,6 +1915,9 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
if (!this->LibraryArchitecture.empty()) { if (!this->LibraryArchitecture.empty()) {
common.push_back("lib/" + this->LibraryArchitecture); common.push_back("lib/" + this->LibraryArchitecture);
} }
if (this->UseLib32Paths) {
common.push_back("lib32");
}
if (this->UseLib64Paths) { if (this->UseLib64Paths) {
common.push_back("lib64"); common.push_back("lib64");
} }

View File

@ -148,6 +148,7 @@ private:
bool NoUserRegistry; bool NoUserRegistry;
bool NoSystemRegistry; bool NoSystemRegistry;
bool DebugMode; bool DebugMode;
bool UseLib32Paths;
bool UseLib64Paths; bool UseLib64Paths;
bool PolicyScope; bool PolicyScope;
std::string LibraryArchitecture; std::string LibraryArchitecture;

View File

@ -2076,6 +2076,14 @@ bool cmMakefile::IsSet(const std::string& name) const
return true; return true;
} }
bool cmMakefile::PlatformIs32Bit() const
{
if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {
return atoi(sizeof_dptr) == 4;
}
return false;
}
bool cmMakefile::PlatformIs64Bit() const bool cmMakefile::PlatformIs64Bit() const
{ {
if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) { if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {

View File

@ -437,6 +437,9 @@ public:
bool IsOn(const std::string& name) const; bool IsOn(const std::string& name) const;
bool IsSet(const std::string& name) const; bool IsSet(const std::string& name) const;
/** Return whether the target platform is 32-bit. */
bool PlatformIs32Bit() const;
/** Return whether the target platform is 64-bit. */ /** Return whether the target platform is 64-bit. */
bool PlatformIs64Bit() const; bool PlatformIs64Bit() const;

View File

@ -33,16 +33,23 @@ endmacro()
set(CMAKE_FIND_LIBRARY_PREFIXES "lib") set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
set(CMAKE_SIZEOF_VOID_P 4) set(CMAKE_SIZEOF_VOID_P 4)
foreach(lib foreach(lib
lib/32/libtest5.a
lib/A/lib/libtest1.a lib/A/lib/libtest1.a
lib/A/lib32/libtest3.a
lib/A/libtest1.a lib/A/libtest1.a
lib/libtest1.a lib/libtest1.a
lib/libtest2.a lib/libtest2.a
lib/libtest3.a lib/libtest3.a
lib/libtest3.a lib/libtest3.a
lib32/A/lib/libtest2.a
lib32/A/lib32/libtest4.a
lib32/A/libtest4.a
lib32/libtest4.a
) )
test_find_library_subst(${lib}) test_find_library_subst(${lib})
endforeach() endforeach()

View File

@ -1,4 +1,4 @@
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS # Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS
enable_language(C) enable_language(C)
# Prepare environment and variables # Prepare environment and variables
@ -29,10 +29,15 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
else() else()
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64) if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
else()
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
endif() endif()
else() else()

View File

@ -1,4 +1,4 @@
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS # Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS
enable_language(C) enable_language(C)
# Prepare environment and variables # Prepare environment and variables
@ -29,10 +29,15 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
else() else()
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property # not debian, check the FIND_LIBRARY_USE_LIB64_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64) if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
else()
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
endif() endif()
else() else()

View File

@ -1,6 +1,3 @@
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
enable_language(C)
# Prepare environment and variables # Prepare environment and variables
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE) set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")

View File

@ -1,4 +1,4 @@
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS # Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS
enable_language(C) enable_language(C)
# Prepare environment and variables # Prepare environment and variables
@ -29,10 +29,15 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
else() else()
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS propertie
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64) if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
else()
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
endif() endif()
else() else()

View File

@ -1,4 +1,4 @@
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS # Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS
enable_language(C) enable_language(C)
# Prepare environment and variables # Prepare environment and variables
@ -29,10 +29,15 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
endif() endif()
else() else()
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64) if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
else()
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
endif() endif()
endif() endif()
else() else()

View File

@ -1,4 +1,4 @@
# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS # Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS
enable_language(C) enable_language(C)
# Prepare environment and variables # Prepare environment and variables
@ -29,10 +29,15 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
else() else()
# not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property # not debian, check the FIND_LIBRARY_USE_LIB64_PATHS and FIND_LIBRARY_USE_LIB32_PATHS properties
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64) if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
else()
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif() endif()
endif() endif()
else() else()