From 1ffa0d60b0f253506a4e1e335f98c71bba3b866d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 2 Oct 2018 13:31:14 +0200 Subject: Testing static linking on linux --- CMakeLists.txt | 26 ++++++++++++++++++++++++-- backend/ninja/Ninja.cpp | 7 +++++-- msvc/git2.lib | Bin 180678 -> 0 bytes src/Conf.cpp | 3 --- static/linux/libarchive.a | Bin 0 -> 1621578 bytes static/linux/libbz2.a | Bin 0 -> 117762 bytes static/linux/libcrypto.a | Bin 0 -> 4374008 bytes static/linux/libcurl.a | Bin 0 -> 1378480 bytes static/linux/libgit2.a | Bin 0 -> 2481536 bytes static/linux/libhttp_parser.a | Bin 0 -> 46096 bytes static/linux/liblz4.a | Bin 0 -> 301294 bytes static/linux/liblzma.a | Bin 0 -> 409792 bytes static/linux/libssh2.a | Bin 0 -> 354480 bytes static/linux/libssl.a | Bin 0 -> 765298 bytes static/linux/libxml2.a | Bin 0 -> 2804996 bytes static/linux/libz.a | Bin 0 -> 154898 bytes static/windows/git2.lib | Bin 0 -> 180678 bytes 17 files changed, 29 insertions(+), 7 deletions(-) delete mode 100644 msvc/git2.lib create mode 100644 static/linux/libarchive.a create mode 100644 static/linux/libbz2.a create mode 100644 static/linux/libcrypto.a create mode 100644 static/linux/libcurl.a create mode 100644 static/linux/libgit2.a create mode 100644 static/linux/libhttp_parser.a create mode 100644 static/linux/liblz4.a create mode 100644 static/linux/liblzma.a create mode 100644 static/linux/libssh2.a create mode 100644 static/linux/libssl.a create mode 100644 static/linux/libxml2.a create mode 100644 static/linux/libz.a create mode 100644 static/windows/git2.lib 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() diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 9ec12d3..8b92af1 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -397,7 +397,8 @@ namespace backend ninja::NinjaArg::createRaw("-g3"), ninja::NinjaArg::createRaw("-D_FORTIFY_SOURCE=2"), ninja::NinjaArg::createRaw("-D_GLIBCXX_ASSERTIONS"), - ninja::NinjaArg::createRaw("-fasynchronous-unwind-tables") + ninja::NinjaArg::createRaw("-fasynchronous-unwind-tables"), + ninja::NinjaArg::createRaw("-D_DEBUG") }; } case OPT_LEV_RELEASE: @@ -419,7 +420,9 @@ namespace backend { return { ninja::NinjaArg::createRaw("/Od"), - ninja::NinjaArg::createRaw("/MTd") + ninja::NinjaArg::createRaw("/Zi"), + ninja::NinjaArg::createRaw("/MTd"), + ninja::NinjaArg::createRaw("/D_DEBUG") }; } case OPT_LEV_RELEASE: diff --git a/msvc/git2.lib b/msvc/git2.lib deleted file mode 100644 index 238331e..0000000 Binary files a/msvc/git2.lib and /dev/null differ diff --git a/src/Conf.cpp b/src/Conf.cpp index d981794..365cf38 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -487,9 +487,6 @@ namespace sibs else fprintf(stderr, "Warning: Project contains tests directory but we got an error while retrieving the full path to it\n"); } - - if(config.packaging && (!config.getDebugStaticLibs().empty() || !config.getReleaseStaticLibs().empty())) - return Result::Err("Project " + config.getPackageName() + " contains external static libraries, such projects are not supported when building a package"); } return parseResult; diff --git a/static/linux/libarchive.a b/static/linux/libarchive.a new file mode 100644 index 0000000..09f2986 Binary files /dev/null and b/static/linux/libarchive.a differ diff --git a/static/linux/libbz2.a b/static/linux/libbz2.a new file mode 100644 index 0000000..58652ca Binary files /dev/null and b/static/linux/libbz2.a differ diff --git a/static/linux/libcrypto.a b/static/linux/libcrypto.a new file mode 100644 index 0000000..518e29b Binary files /dev/null and b/static/linux/libcrypto.a differ diff --git a/static/linux/libcurl.a b/static/linux/libcurl.a new file mode 100644 index 0000000..8d208c1 Binary files /dev/null and b/static/linux/libcurl.a differ diff --git a/static/linux/libgit2.a b/static/linux/libgit2.a new file mode 100644 index 0000000..47f6c26 Binary files /dev/null and b/static/linux/libgit2.a differ diff --git a/static/linux/libhttp_parser.a b/static/linux/libhttp_parser.a new file mode 100644 index 0000000..f8db936 Binary files /dev/null and b/static/linux/libhttp_parser.a differ diff --git a/static/linux/liblz4.a b/static/linux/liblz4.a new file mode 100644 index 0000000..ab07dd9 Binary files /dev/null and b/static/linux/liblz4.a differ diff --git a/static/linux/liblzma.a b/static/linux/liblzma.a new file mode 100644 index 0000000..553ac4c Binary files /dev/null and b/static/linux/liblzma.a differ diff --git a/static/linux/libssh2.a b/static/linux/libssh2.a new file mode 100644 index 0000000..ed5e0c5 Binary files /dev/null and b/static/linux/libssh2.a differ diff --git a/static/linux/libssl.a b/static/linux/libssl.a new file mode 100644 index 0000000..6876ce9 Binary files /dev/null and b/static/linux/libssl.a differ diff --git a/static/linux/libxml2.a b/static/linux/libxml2.a new file mode 100644 index 0000000..c244b71 Binary files /dev/null and b/static/linux/libxml2.a differ diff --git a/static/linux/libz.a b/static/linux/libz.a new file mode 100644 index 0000000..fa2b2ab Binary files /dev/null and b/static/linux/libz.a differ diff --git a/static/windows/git2.lib b/static/windows/git2.lib new file mode 100644 index 0000000..238331e Binary files /dev/null and b/static/windows/git2.lib differ -- cgit v1.2.3