comparison Resources/CMake/Compiler.cmake @ 2457:2a211c0fc7ca

note about ar
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Jan 2018 09:27:16 +0100
parents cbb8deaacdf7
children 292bd85d4532
comparison
equal deleted inserted replaced
2456:cbb8deaacdf7 2457:2a211c0fc7ca
198 if (CMAKE_COMPILER_IS_GNUCXX) 198 if (CMAKE_COMPILER_IS_GNUCXX)
199 # "When creating a static library using binutils (ar) and there 199 # "When creating a static library using binutils (ar) and there
200 # exist a duplicate object name (e.g. a/Foo.cpp.o, b/Foo.cpp.o), the 200 # exist a duplicate object name (e.g. a/Foo.cpp.o, b/Foo.cpp.o), the
201 # resulting static library can end up having only one of the 201 # resulting static library can end up having only one of the
202 # duplicate objects. [...] This bug only happens if there are many 202 # duplicate objects. [...] This bug only happens if there are many
203 # objects." https://cmake.org/Bug/view.php?id=14874 203 # objects." The trick consists in replacing the "r" argument
204 # ("replace") provided to "ar" (as used in CMake < 3.1) by the "q"
205 # argument ("quick append"). This is because of the fact that CMake
206 # will invoke "ar" several times with several batches of ".o"
207 # objects, and using "r" would overwrite symbols defined in
208 # preceding batches. https://cmake.org/Bug/view.php?id=14874
204 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") 209 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>")
205 endif() 210 endif()
206 211
207 212
208 if (STATIC_BUILD) 213 if (STATIC_BUILD)