[Bf-blender-cvs] [07d7028dd0d] master: CMake: various fixes for building Python module

Tyler Alden Gubala noreply at git.blender.org
Thu Sep 10 19:42:59 CEST 2020


Commit: 07d7028dd0d47d54d21c54ae5eaf872e60e1bc4b
Author: Tyler Alden Gubala
Date:   Thu Sep 10 14:54:21 2020 +0200
Branches: master
https://developer.blender.org/rB07d7028dd0d47d54d21c54ae5eaf872e60e1bc4b

CMake: various fixes for building Python module

* Don't link against Mesa OpenGL software emulation libraries from the
  lib folder, they are not intended to be used for building, only install.
* Don't use static OpenMP library by default, it's usually not built to
  work in shared libraries.
* Disable jemalloc on all platforms, the reason it fails is not specific
  to Linux.

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

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

M	build_files/cmake/config/bpy_module.cmake
M	build_files/cmake/platform/platform_unix.cmake

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

diff --git a/build_files/cmake/config/bpy_module.cmake b/build_files/cmake/config/bpy_module.cmake
index 18d19b32335..2c0da81a1ea 100644
--- a/build_files/cmake/config/bpy_module.cmake
+++ b/build_files/cmake/config/bpy_module.cmake
@@ -33,18 +33,9 @@ set(WITH_ALEMBIC             OFF CACHE BOOL "" FORCE)
 # Depends on Python install, do this to quiet warning.
 set(WITH_DRACO               OFF CACHE BOOL "" FORCE)
 
-# Note, if linking errors can be resolved, lines below can be removed.
-# Until then, disable configurations known to fail.
-
-if(UNIX AND NOT APPLE)
-  if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-    # jemalloc causes linking error on import, disable.
-    set(WITH_MEM_JEMALLOC    OFF CACHE BOOL "" FORCE)
-  endif()
-elseif(APPLE)
-  # OpenMP causes linking error on build, disable.
-  set(WITH_MEM_JEMALLOC        OFF CACHE BOOL "" FORCE)
-endif()
+# Jemalloc does not work with dlopen() of Python modules:
+# https://github.com/jemalloc/jemalloc/issues/1237
+set(WITH_MEM_JEMALLOC        OFF CACHE BOOL "" FORCE)
 
 if(WIN32)
   set(WITH_WINDOWS_BUNDLE_CRT  OFF CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 3a7875ca46c..b2105a58a0a 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -52,12 +52,19 @@ if(EXISTS ${LIBDIR})
   message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
 
   file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
+  # Ignore Mesa software OpenGL libraries, they are not intended to be
+  # linked against but to optionally override at runtime.
+  list(REMOVE_ITEM LIB_SUBDIRS ${LIBDIR}/mesa)
   # NOTE: Make sure "proper" compiled zlib comes first before the one
   # which is a part of OpenCollada. They have different ABI, and we
   # do need to use the official one.
   set(CMAKE_PREFIX_PATH ${LIBDIR}/zlib ${LIB_SUBDIRS})
   set(WITH_STATIC_LIBS ON)
-  set(WITH_OPENMP_STATIC ON)
+  # OpenMP usually can't be statically linked into shared libraries,
+  # due to not being compiled with position independent code.
+  if(NOT WITH_PYTHON_MODULE)
+    set(WITH_OPENMP_STATIC ON)
+  endif()
   set(Boost_NO_BOOST_CMAKE ON)
   set(BOOST_ROOT ${LIBDIR}/boost)
   set(BOOST_LIBRARYDIR ${LIBDIR}/boost/lib)



More information about the Bf-blender-cvs mailing list