[Bf-blender-cvs] [30b3bf2b577] master: Build: ignore system paths when using precompiled libraries on Linux

Nathan Craddock noreply at git.blender.org
Wed Feb 26 18:13:47 CET 2020


Commit: 30b3bf2b5779b82bac146913b2066001ef9c7089
Author: Nathan Craddock
Date:   Thu Feb 20 22:09:14 2020 -0700
Branches: master
https://developer.blender.org/rB30b3bf2b5779b82bac146913b2066001ef9c7089

Build: ignore system paths when using precompiled libraries on Linux

Based on work by Nathan Craddock, with further changes to apply it to all
precompiled libraries.

Differential Revision: https://developer.blender.org/D6929

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

M	build_files/cmake/macros.cmake
M	build_files/cmake/platform/platform_unix.cmake

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

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 2ae641b9eb3..622fc42def8 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -1167,3 +1167,10 @@ macro(set_and_warn_dependency
     endif()
 endmacro()
 
+macro(without_system_libs_begin)
+  set(CMAKE_IGNORE_PATH "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES};${CMAKE_SYSTEM_INCLUDE_PATH};${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES};${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
+endmacro()
+
+macro(without_system_libs_end)
+  unset(CMAKE_IGNORE_PATH)
+endmacro()
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index ac570f17e47..3b40f7c329b 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -72,26 +72,21 @@ macro(find_package_wrapper)
   endif()
 endmacro()
 
+# ----------------------------------------------------------------------------
+# Precompiled Libraries
+#
+# These are libraries that may be precompiled. For this we disable searching in
+# the system directories so that we don't accidentally use them instead.
+
+if(EXISTS ${LIBDIR})
+  without_system_libs_begin()
+endif()
+
 find_package_wrapper(JPEG REQUIRED)
 find_package_wrapper(PNG REQUIRED)
 find_package_wrapper(ZLIB REQUIRED)
 find_package_wrapper(Freetype REQUIRED)
 
-if(WITH_LZO AND WITH_SYSTEM_LZO)
-  find_package_wrapper(LZO)
-  if(NOT LZO_FOUND)
-    message(FATAL_ERROR "Failed finding system LZO version!")
-  endif()
-endif()
-
-if(WITH_SYSTEM_EIGEN3)
-  find_package_wrapper(Eigen3)
-  if(NOT EIGEN3_FOUND)
-    message(FATAL_ERROR "Failed finding system Eigen3 version!")
-  endif()
-endif()
-# else values are set below for all platforms
-
 if(WITH_PYTHON)
   # No way to set py35, remove for now.
   # find_package(PythonLibs)
@@ -126,14 +121,6 @@ if(WITH_IMAGE_TIFF)
   endif()
 endif()
 
-# Audio IO
-if(WITH_SYSTEM_AUDASPACE)
-  find_package_wrapper(Audaspace)
-  if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND)
-    message(FATAL_ERROR "Audaspace external library not found!")
-  endif()
-endif()
-
 if(WITH_OPENAL)
   find_package_wrapper(OpenAL)
   if(NOT OPENAL_FOUND)
@@ -166,13 +153,6 @@ if(WITH_SDL)
   endif()
 endif()
 
-if(WITH_JACK)
-  find_package_wrapper(Jack)
-  if(NOT JACK_FOUND)
-    set(WITH_JACK OFF)
-  endif()
-endif()
-
 # Codecs
 if(WITH_CODEC_SNDFILE)
   find_package_wrapper(SndFile)
@@ -448,6 +428,13 @@ if(WITH_TBB)
   find_package_wrapper(TBB)
 endif()
 
+if(EXISTS ${LIBDIR})
+  without_system_libs_end()
+endif()
+
+# ----------------------------------------------------------------------------
+# Build and Link Flags
+
 # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
 if(HAIKU)
   list(APPEND PLATFORM_LINKLIBS -lnetwork)
@@ -480,6 +467,36 @@ 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(WITH_LZO AND WITH_SYSTEM_LZO)
+  find_package_wrapper(LZO)
+  if(NOT LZO_FOUND)
+    message(FATAL_ERROR "Failed finding system LZO version!")
+  endif()
+endif()
+
+if(WITH_SYSTEM_EIGEN3)
+  find_package_wrapper(Eigen3)
+  if(NOT EIGEN3_FOUND)
+    message(FATAL_ERROR "Failed finding system Eigen3 version!")
+  endif()
+endif()
+
+# Jack is intended to use the system library.
+if(WITH_JACK)
+  find_package_wrapper(Jack)
+  if(NOT JACK_FOUND)
+    set(WITH_JACK OFF)
+  endif()
+endif()
+
+# Audio IO
+if(WITH_SYSTEM_AUDASPACE)
+  find_package_wrapper(Audaspace)
+  if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND)
+    message(FATAL_ERROR "Audaspace external library not found!")
+  endif()
+endif()
+
 if(WITH_X11)
   find_package(X11 REQUIRED)



More information about the Bf-blender-cvs mailing list