aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-02 13:31:14 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit1ffa0d60b0f253506a4e1e335f98c71bba3b866d (patch)
treed1a908d11900f43340bf3157972885545b7587b3 /CMakeLists.txt
parent0730f0379df326d8fd0ef71793ec90cf4a020119 (diff)
Testing static linking on linux
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt26
1 files changed, 24 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1070620..6b4c3ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,8 @@ project(sibs)
set(CMAKE_CXX_STANDARD 14)
+option(BUILD_STATIC "Build sibs statically on linux" OFF)
+
set(SOURCE_FILES
external/xxhash.c
backend/ninja/Ninja.cpp
@@ -35,9 +37,29 @@ add_executable(sibs ${SOURCE_FILES})
include_directories(${CURL_INCLUDE_DIR} ${LibArchive_INCLUDE_DIR} "depends/libninja/include")
if(WIN32)
- target_link_libraries(sibs ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} "${CMAKE_CURRENT_SOURCE_DIR}/msvc/git2.lib")
+ target_link_libraries(sibs ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} "${CMAKE_CURRENT_SOURCE_DIR}/static/windows/git2.lib")
target_compile_options(sibs PRIVATE /Wall)
else()
- target_link_libraries(sibs ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} -lgit2)
+ if(BUILD_STATIC AND UNIX AND NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+ target_link_libraries(sibs
+ -static
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libarchive.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libbz2.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libxml2.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/liblzma.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/liblz4.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libgit2.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libcurl.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libz.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libssh2.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libhttp_parser.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libssl.a"
+ "${CMAKE_CURRENT_SOURCE_DIR}/static/linux/libcrypto.a"
+ -pthread
+ -ldl
+ -lm)
+ else()
+ target_link_libraries(sibs ${CURL_LIBRARIES} ${LibArchive_LIBRARIES} -lgit2)
+ endif()
target_compile_options(sibs PRIVATE -Wall -Wextra -Werror=return-type -fdiagnostics-show-option -fexceptions)
endif()