forked from AXiX-official/ABRecompressor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
74 lines (60 loc) · 2.39 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
cmake_minimum_required(VERSION 3.14)
set(MODULE_NAME ABRecompressor)
project(${MODULE_NAME})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(C_FLAGS "${C_FLAGS} -O2 -fvisibility=hidden")
set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,-exclude-libs,ALL -Wl,--gc-sections -Wl,--strip-all")
include_directories(include)
include(ExternalProject)
find_package(lz4)
if(NOT LZ4_FOUND)
message("Will attempt to fetch and build lz4")
message("===================================")
ExternalProject_Add(
lz4
PREFIX "${CMAKE_BINARY_DIR}/lz4"
GIT_REPOSITORY https://github.com/lz4/lz4.git
GIT_TAG v1.9.4
UPDATE_COMMAND ""
PATCH_COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/patches/lz4_CMakeLists.txt <SOURCE_DIR>/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/build/cmake/lz4Config.cmake.in <SOURCE_DIR>/lz4Config.cmake.in
INSTALL_COMMAND ""
)
ExternalProject_Get_Property( lz4 SOURCE_DIR BINARY_DIR )
set( LZ4_INCLUDE_DIR "${SOURCE_DIR}/lib" )
set( LZ4_STATIC_LIB "${BINARY_DIR}/liblz4.a" )
else()
message("Found lz4 library: ${LZ4_LIBRARIES}")
message("====================================")
endif()
find_package(LibLZMA)
if(NOT LIBLZMA_FOUND)
message("Will attempt to fetch and build liblzma")
message("=======================================")
ExternalProject_Add(
lzma
PREFIX "${CMAKE_BINARY_DIR}/lzma"
GIT_REPOSITORY https://github.com/tukaani-project/xz
GIT_TAG v5.6.2
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(lzma SOURCE_DIR BINARY_DIR)
set(LZMA_INCLUDE_DIR "${SOURCE_DIR}/src/liblzma/api")
set(LZMA_STATIC_LIB "${BINARY_DIR}/liblzma.a")
else()
message("Found liblzma library: ${LIBLZMA_LIBRARIES}")
message("===========================================")
endif()
add_library(${MODULE_NAME} STATIC
src/ABRecompressor.cpp
src/BlocksAndDirectoryInfo.cpp
src/BundleFile.cpp
src/Compression.cpp
src/Header.cpp)
target_include_directories(${MODULE_NAME} PRIVATE ${LZ4_INCLUDE_DIR} ${LZMA_INCLUDE_DIR})
add_dependencies(${MODULE_NAME} lz4 lzma)
target_compile_definitions(${MODULE_NAME} PRIVATE ABRECOMPRESSOR_EXPORTS)
target_link_libraries(ABRecompressor ${LZ4_STATIC_LIB} ${LZMA_STATIC_LIB})