From 45304493176e7160917081561bd209ed10527443 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 26 Jan 2022 15:20:32 +1100 Subject: CMake: resolve issues using pre-compiled & system libraries for Unix When LIBDIR existed, searching for system libraries would always first search 'LIBDIR'. This meant "WITH_SYSTEM_*" would still prefer LIBDIR versions of libraries if they exist. The presence of LIBDIR also ignored the setting for WITH_STATIC_LIBS which is now restored to the cached value once pre-compiled libraries have been handled. --- build_files/cmake/platform/platform_unix.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'build_files') diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 5778699ee49..a3b8b17ec19 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -48,6 +48,9 @@ if(NOT DEFINED LIBDIR) unset(LIBDIR_CENTOS7_ABI) endif() +# Support restoring this value once pre-compiled libraries have been handled. +set(WITH_STATIC_LIBS_INIT ${WITH_STATIC_LIBS}) + if(EXISTS ${LIBDIR}) message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") @@ -541,6 +544,15 @@ add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE # # Keep last, so indirectly linked libraries don't override our own pre-compiled libs. +if(EXISTS ${LIBDIR}) + # Clear the prefix path as it causes the `LIBDIR` to override system locations. + unset(CMAKE_PREFIX_PATH) + + # Since the pre-compiled `LIBDIR` directories have been handled, don't prefer static libraries. + set(WITH_STATIC_LIBS ${WITH_STATIC_LIBS_INIT}) +endif() + + if(WITH_LZO AND WITH_SYSTEM_LZO) find_package_wrapper(LZO) if(NOT LZO_FOUND) -- cgit v1.2.3