From 923d355c9163837147ba793e4375e35431457d10 Mon Sep 17 00:00:00 2001 From: Romain Naour Date: Sun, 16 Jul 2017 01:35:13 +0200 Subject: [PATCH] CMake: build libmisc and libc4script statically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As reported by [1], some distributions use shared libraries as default preset in CMake. Without explicitely linking statically libmisc and libc4script, we have the following link issue: [...]/host/bin/x86_64-linux-g++ --sysroot=[...]sysroot -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -std=gnu++14 -Wall -Wextra -Wredundant-decls -Wendif-labels -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Winit-self -Wsign-promo -Wno-reorder -Wno-unused-parameter -Wnon-virtual-dtor -Woverloaded-virtual -DNDEBUG -rdynamic CMakeFiles/c4group.dir/src/c4group/C4GroupMain.cpp.o -o c4group -Wl,-rpath,[...]/build/openclonk-7.0: liblibmisc.so -lz -lpthread -lrt liblibmisc.so : référence indéfinie vers « C4LangStringTable::Translate(std::__cxx11::basic_string, std::allocator > const&) const » liblibmisc.so : référence indéfinie vers « C4LangStringTable::system_string_table » [1] https://github.com/openclonk/openclonk/pull/26 While at it, build libopenclonk statically since libopenclonk is not installed by the CMake build system. Signed-off-by: Romain Naour --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd297328..612ab46d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -990,7 +990,7 @@ include_directories(SYSTEM ############################################################################ add_definitions(-DHAVE_CONFIG_H) -add_library(libmisc +add_library(libmisc STATIC src/C4Include.cpp src/c4group/C4Group.cpp src/c4group/C4Group.h @@ -1055,7 +1055,7 @@ if(UNIX AND NOT APPLE) target_link_libraries(libmisc rt) endif() -add_library(libc4script +add_library(libc4script STATIC src/C4Include.cpp src/c4group/C4ComponentHost.cpp src/c4group/C4ComponentHost.h @@ -1104,7 +1104,7 @@ add_subdirectory(thirdparty/blake2) set_property(TARGET blake2 PROPERTY FOLDER "Third-party libraries") target_link_libraries(libc4script blake2 libmisc) -add_library(libopenclonk +add_library(libopenclonk STATIC src/c4group/C4Extra.cpp src/c4group/C4Extra.h src/control/C4PlayerInfoConflicts.cpp