diff --git a/.gitmodules b/.gitmodules index 5a24ee672..d36e57913 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "app/src/main/cpp/libarchive"] path = app/src/main/cpp/libarchive url = https://github.com/Ehviewer-Overhauled/libarchive -[submodule "app/src/main/cpp/liblzma"] - path = app/src/main/cpp/liblzma - url = https://github.com/Ehviewer-Overhauled/xz [submodule "app/src/main/cpp/nettle/nettle"] path = app/src/main/cpp/nettle/nettle url = https://github.com/Ehviewer-Overhauled/nettle diff --git a/app/src/main/cpp/0001-Don-t-build-other-binarys.patch b/app/src/main/cpp/0001-Don-t-build-other-binarys.patch new file mode 100644 index 000000000..2171ac89e --- /dev/null +++ b/app/src/main/cpp/0001-Don-t-build-other-binarys.patch @@ -0,0 +1,34 @@ +From fc9fb0ea245259e346ab46c334f03b557fe63b6b Mon Sep 17 00:00:00 2001 +From: tarsin +Date: Tue, 22 Nov 2022 12:37:12 +0800 +Subject: [PATCH] Don't build other binarys + +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 01c73cd..b461e68 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -592,7 +592,7 @@ check_symbol_exists(getopt_long getopt.h HAVE_GETOPT_LONG) + # xzdec + ############################################################################# + +-if(HAVE_GETOPT_LONG) ++if(0) + add_executable(xzdec + src/common/sysdefs.h + src/common/tuklib_common.h +@@ -630,7 +630,7 @@ endif() + # xz + ############################################################################# + +-if(NOT MSVC AND HAVE_GETOPT_LONG) ++if(0) + add_executable(xz + src/common/mythread.h + src/common/sysdefs.h +-- +2.39.2 + diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 365d6918d..969af477b 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -1,5 +1,6 @@ -project(ehviewer) -cmake_minimum_required(VERSION 3.4.1) +cmake_minimum_required(VERSION 3.14) +project(ehviewer C) +include(FetchContent) if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -fvisibility=hidden -fvisibility-inlines-hidden -funroll-loops -flto=thin \ @@ -15,6 +16,21 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") -mllvm -polly-invariant-load-hoisting") endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") +# Change the default path of fetch content to avoid downloading the same dependencies per architecture +get_filename_component(deps "../_deps" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") +set(FETCHCONTENT_BASE_DIR ${deps}) + +FetchContent_Declare(liblzma + GIT_REPOSITORY https://git.tukaani.org/xz.git + GIT_TAG v5.4.1 + PATCH_COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/0001-Don-t-build-other-binarys.patch || true + BINARY_DIR build + SUBBUILD_DIR subbuild + ) + +FetchContent_MakeAvailable(liblzma) +include_directories(${liblzma_SOURCE_DIR}/src/liblzma/api) + # Build GNUTLS libnettle add_subdirectory(nettle) @@ -29,11 +45,7 @@ set(HAVE_NETTLE_PBKDF2_H 1) set(HAVE_NETTLE_RIPEMD160_H 1) set(HAVE_NETTLE_SHA_H 1) -# Build liblzma -add_subdirectory(liblzma) - # Configure lzma support for libarchive -include_directories(liblzma/src/liblzma/api) SET(HAVE_LIBLZMA 1) SET(HAVE_LZMA_H 1) SET(HAVE_LZMA_STREAM_ENCODER_MT 1) @@ -41,7 +53,7 @@ SET(HAVE_LZMADEC_H 1) SET(HAVE_LIBLZMADEC 1) # Configure libarchive link's static lib -SET(LIBARCHIVE_CUSTOM_LIBS "liblzma" "nettle") +SET(LIBARCHIVE_CUSTOM_LIBS "nettle" "liblzma") # Build libarchive add_subdirectory(libarchive) diff --git a/app/src/main/cpp/liblzma b/app/src/main/cpp/liblzma deleted file mode 160000 index fc9fb0ea2..000000000 --- a/app/src/main/cpp/liblzma +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fc9fb0ea245259e346ab46c334f03b557fe63b6b