From e49b862da082d8415eca733179d96e44405fe91e Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 1 Nov 2020 13:44:28 +0100 Subject: [PATCH] Adds support for linking std libraries statically. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3942f1a..a1110fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ add_compile_options(-Wall -Wextra -Werror) set(CMAKE_CXX_STANDARD 20) option(TESTS "Whether the test executable should be build as well." OFF) +option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_link_options(-fuse-ld=lld) @@ -20,6 +21,12 @@ endif () file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp") add_library(MalachScript SHARED ${SRC_FILES}) +set(LINKS) +if (STATICC) + set(LINKS ${LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread) +endif(STATICC) +target_link_libraries(MalachScript ${LINKS}) + if (TESTS) # Create Test executable file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")