[Bf-blender-cvs] [fedef4c13aa] master: Fix cycles_test link error on macOS due to boost python in new 3.5 libraries

Brecht Van Lommel noreply at git.blender.org
Wed Dec 7 21:32:10 CET 2022


Commit: fedef4c13aa10bead6a6106d8d9d0b8e5b1562f8
Author: Brecht Van Lommel
Date:   Wed Dec 7 20:38:28 2022 +0100
Branches: master
https://developer.blender.org/rBfedef4c13aa10bead6a6106d8d9d0b8e5b1562f8

Fix cycles_test link error on macOS due to boost python in new 3.5 libraries

The executable would get boost python linking in when not needed, and even when
linking to Python libraries there were still unresolved symbols. Instead split
off boost python libraries and link them only where needed.

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

M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	source/blender/io/usd/CMakeLists.txt

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

diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 81545612176..7a39e6ffda3 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -260,7 +260,12 @@ if(WITH_BOOST)
   endif()
   find_package(Boost COMPONENTS ${_boost_FIND_COMPONENTS})
 
+  # Boost Python is separate to avoid linking Python into tests that don't need it.
   set(BOOST_LIBRARIES ${Boost_LIBRARIES})
+  if(WITH_USD AND USD_PYTHON_SUPPORT)
+    set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY})
+    list(REMOVE_ITEM BOOST_LIBRARIES ${BOOST_PYTHON_LIBRARIES})
+  endif()
   set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
   set(BOOST_DEFINITIONS)
 
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 260fa2e58b2..bcc90cef7c2 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -407,8 +407,13 @@ if(WITH_BOOST)
     mark_as_advanced(Boost_INCLUDE_DIR)  # why doesn't boost do this?
   endif()
 
-  set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
+  # Boost Python is separate to avoid linking Python into tests that don't need it.
   set(BOOST_LIBRARIES ${Boost_LIBRARIES})
+  if(WITH_USD AND USD_PYTHON_SUPPORT)
+    set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY})
+    list(REMOVE_ITEM BOOST_LIBRARIES ${BOOST_PYTHON_LIBRARIES})
+  endif()
+  set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
   set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
   set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
 
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 7d2cb08f67b..f58b9bd4676 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -575,7 +575,7 @@ if(WITH_BOOST)
     )
     if (EXISTS ${BOOST_34_TRIGGER_FILE})
       if(WITH_USD)
-        set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
+        set(BOOST_PYTHON_LIBRARIES
           debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python310-${BOOST_DEBUG_POSTFIX}.lib
           optimized ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python310-${BOOST_POSTFIX}.lib
         )
diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt
index 745a1c69dce..ebd292782c0 100644
--- a/source/blender/io/usd/CMakeLists.txt
+++ b/source/blender/io/usd/CMakeLists.txt
@@ -123,6 +123,7 @@ set(LIB
 
 list(APPEND LIB
   ${BOOST_LIBRARIES}
+  ${BOOST_PYTHON_LIBRARIES}
   ${PYTHON_LIBRARIES}
 )



More information about the Bf-blender-cvs mailing list