forked from jmacd/xdelta
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
94 lines (78 loc) · 3.21 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
cmake_minimum_required(VERSION 3.0.0)
project(xdelta3 VERSION 3.1.0)
include(CheckTypeSize)
check_type_size(size_t XD3_SIZEOF_SIZE_T)
check_type_size("unsigned long long" XD3_SIZEOF_UNSIGNED_LONG_LONG)
set(XD3_SOURCES xdelta3/xdelta3.c)
set(XD3_TARGET_LIBS "")
option( XD3_BUILD_AS_EXE
"Set to ON to build xdelta3 as an executable rather than a library."
OFF)
option( XD3_ENABLE_SECONDARY_COMPRESSION
"Compiles builtin in support for secondary compression (DJW and FGK). \
To also include lzma as secondary compression, you should enable it with the corresponding option"
OFF)
option( XD3_ENABLE_LZMA
"Includes lzma as secondary compression. \
For this to work, libzma must be available to find_package when building
This option has no effect if secondary compression is not enabled."
OFF)
option( XD3_ENABLE_ENCODER
"Enable also the encoding code, and not only the decoder."
OFF)
option( XD3_ENABLE_VCDIFF_TOOLS
"Enable additional vcdiff code (e.g., get xdelta patch's header information"
OFF)
add_compile_definitions(SIZEOF_SIZE_T=${XD3_SIZEOF_SIZE_T})
add_compile_definitions(SIZEOF_UNSIGNED_LONG_LONG=${XD3_SIZEOF_UNSIGNED_LONG_LONG})
add_compile_definitions(XD3_USE_LARGEFILE64=1)
add_compile_definitions(XD3_MAIN=1) #enables main function
add_compile_definitions(EXTERNAL_COMPRESSION=0)
add_compile_definitions(XD3_USE_LARGESIZET=1)
if(WIN32)
add_compile_definitions(XD3_WIN32=1) #this forces using the win32 io library
add_compile_definitions(WIN32=1)
else()
add_compile_definitions(XD3_WIN32=0)
add_compile_definitions(WIN32=0)
# here we are defaulting to using the stdio io library. If posix is need,
# we must change the following compile definition to use XD3_POSIX
add_compile_definitions(XD3_STDIO=1)
endif()
if(XD3_BUILD_AS_EXE)
add_compile_definitions(NOT_MAIN=0)
else()
add_compile_definitions(NOT_MAIN=1) # changes the main function name to xd3_main_cmdline
set(XD3_SOURCES xdelta3_wrapper.cpp ${XD3_SOURCES})
endif()
if(XD3_ENABLE_ENCODER)
add_compile_definitions(XD3_ENCODER=1)
else()
add_compile_definitions(XD3_ENCODER=0)
endif()
if(XD3_ENABLE_VCDIFF_TOOLS)
add_compile_definitions(VCDIFF_TOOLS=1)
else()
add_compile_definitions(VCDIFF_TOOLS=0)
endif()
if(XD3_ENABLE_SECONDARY_COMPRESSION)
add_compile_definitions(SECONDARY_DJW=1) #(passing djwn chooses compression n with djw. Other second compressions do not seem to support level)
add_compile_definitions(SECONDARY_FGK=1)
if(XD3_ENABLE_LZMA)
#find_package(LibLZMA 5.2.1 REQUIRED CONFIG)
set(XD3_TARGET_LIBS liblzma ${XD3_TARGET_LIBS})
add_compile_definitions(SECONDARY_LZMA=1)
endif()
else()
add_compile_definitions(SECONDARY_DJW=0)
add_compile_definitions(SECONDARY_FGK=0)
add_compile_definitions(SECONDARY_LZMA=0)
endif()
if(XD3_BUILD_AS_EXE)
add_executable(${PROJECT_NAME} "${XD3_SOURCES}")
else()
add_library(${PROJECT_NAME} "${XD3_SOURCES}")
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endif()
target_link_libraries(${PROJECT_NAME} ${XD3_TARGET_LIBS})