changeset 2456:cbb8deaacdf7

Fix static build on CentOS 6
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jan 2018 20:25:35 +0100
parents 6b3c0d5f65af
children 2a211c0fc7ca
files NEWS Resources/CMake/Compiler.cmake
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jan 03 16:56:52 2018 +0100
+++ b/NEWS	Wed Jan 03 20:25:35 2018 +0100
@@ -16,6 +16,7 @@
 * Upgrade to curl 7.57.0 for static and Windows builds
 * Support of Linux Standard Base
 * Static linking against libuuid (from e2fsprogs)
+* Fix static build on CentOS 6
 
 
 Version 1.3.1 (2017-11-29)
--- a/Resources/CMake/Compiler.cmake	Wed Jan 03 16:56:52 2018 +0100
+++ b/Resources/CMake/Compiler.cmake	Wed Jan 03 20:25:35 2018 +0100
@@ -195,6 +195,16 @@
 endif()
 
 
+if (CMAKE_COMPILER_IS_GNUCXX)
+  # "When creating a static library using binutils (ar) and there
+  # exist a duplicate object name (e.g. a/Foo.cpp.o, b/Foo.cpp.o), the
+  # resulting static library can end up having only one of the
+  # duplicate objects. [...] This bug only happens if there are many
+  # objects." https://cmake.org/Bug/view.php?id=14874
+  set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>")
+endif()
+
+
 if (STATIC_BUILD)
   add_definitions(-DORTHANC_STATIC=1)
 else()