[Bf-blender-cvs] [35c707684be] master: CMake: Allow to use pre-compiled CentOS libraries

Sergey Sharybin noreply at git.blender.org
Thu Oct 10 10:45:52 CEST 2019


Commit: 35c707684befb2fe823ab1bfa002b34785c31841
Author: Sergey Sharybin
Date:   Wed Oct 9 17:14:00 2019 +0200
Branches: master
https://developer.blender.org/rB35c707684befb2fe823ab1bfa002b34785c31841

CMake: Allow to use pre-compiled CentOS libraries

The goal is to make it able to use pre-compiled CentOS libraries on a
more modern system. Main issue was that it's possible that the compiler
on a newer version is defaulting to different C++11 ABI.

This change makes it so that if there is NO native libraries in the
lib folder and there IS pre-compiled CentOS folder, it will be used and
compiler will be forced to old ABI.

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

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

M	CMakeLists.txt
M	build_files/cmake/platform/platform_unix.cmake

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b065756017c..43a0994e642 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -467,7 +467,6 @@ option(WITH_GTESTS "Enable GTest unit testing" OFF)
 option(WITH_OPENGL_RENDER_TESTS "Enable OpenGL render related unit testing (Experimental)" OFF)
 option(WITH_OPENGL_DRAW_TESTS "Enable OpenGL UI drawing related unit testing (Experimental)" OFF)
 
-
 # Documentation
 if(UNIX AND NOT APPLE)
   option(WITH_DOC_MANPAGE "Create a manual page (Unix manpage)" OFF)
@@ -584,6 +583,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Ninja")
   mark_as_advanced(WITH_NINJA_POOL_JOBS)
 endif()
 
+if(UNIX AND NOT APPLE)
+  option(WITH_CXX11_ABI "Use native C++11 ABI of compiler" ON)
+  mark_as_advanced(WITH_CXX11_ABI)
+endif()
+
 # avoid using again
 option_defaults_clear()
 
@@ -1641,6 +1645,12 @@ if(
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
 endif()
 
+if(UNIX AND NOT APPLE)
+  if(NOT WITH_CXX11_ABI)
+    set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
+  endif()
+endif()
+
 # Include warnings first, so its possible to disable them with user defined flags
 # eg: -Wno-uninitialized
 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 1b3f9cf3fad..e655234eb34 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -22,14 +22,30 @@
 
 # Detect precompiled library directory
 if(NOT DEFINED LIBDIR)
+  # Path to a locally compiled libraries.
   set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
   string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
-  set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
-else()
-  message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
+  set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
+
+  # Path to precompiled libraries with known CentOS 7 ABI.
+  set(LIBDIR_CENTOS7_ABI ${CMAKE_SOURCE_DIR}/../lib/linux_centos7_x86_64)
+
+  # Choose the best suitable libraries.
+  if(EXISTS ${LIBDIR_NATIVE_ABI})
+    set(LIBDIR ${LIBDIR_NATIVE_ABI})
+  elseif(EXISTS ${LIBDIR_CENTOS7_ABI})
+    set(LIBDIR ${LIBDIR_CENTOS7_ABI})
+    set(WITH_CXX11_ABI OFF)
+  endif()
+
+  # Avoid namespace pollustion.
+  unset(LIBDIR_NATIVE_ABI)
+  unset(LIBDIR_CENTOS7_ABI)
 endif()
 
 if(EXISTS ${LIBDIR})
+  message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
+
   file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
   # NOTE: Make sure "proper" compiled zlib comes first before the one
   # which is a part of OpenCollada. They have different ABI, and we



More information about the Bf-blender-cvs mailing list