[Bf-blender-cvs] [45304493176] master: CMake: resolve issues using pre-compiled & system libraries for Unix

Campbell Barton noreply at git.blender.org
Wed Jan 26 06:07:23 CET 2022


Commit: 45304493176e7160917081561bd209ed10527443
Author: Campbell Barton
Date:   Wed Jan 26 15:20:32 2022 +1100
Branches: master
https://developer.blender.org/rB45304493176e7160917081561bd209ed10527443

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.

===================================================================

M	build_files/cmake/platform/platform_unix.cmake

===================================================================

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)



More information about the Bf-blender-cvs mailing list