CMake: build libmisc and libc4script statically

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<char, std::char_traits<char>, std::allocator<char> > 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 <romain.naour@gmail.com>
master
Romain Naour 2017-07-16 01:35:13 +02:00 committed by Julius Michaelis
parent 9fed69f3fa
commit 48c38c91dc
1 changed files with 3 additions and 3 deletions

View File

@ -991,7 +991,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
@ -1056,7 +1056,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
@ -1105,7 +1105,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