forked from ton-blockchain/libRaptorQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_deps.cmake
86 lines (79 loc) · 3.12 KB
/
build_deps.cmake
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
#
# Copyright (c) 2016, Luca Fulchir<[email protected]>, All rights reserved.
#
# This file is part of "libRaptorQ".
#
# libRaptorQ is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3
# of the License, or (at your option) any later version.
#
# libRaptorQ is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# and a copy of the GNU Lesser General Public License
# along with libRaptorQ. If not, see <http://www.gnu.org/licenses/>.
if(RQ_BUILD_LZ4)
#
# target: LZ4 static library
#
set(RQ_LZ4_VERSION_MAJOR 1)
set(RQ_LZ4_VERSION_MINOR 5)
set(RQ_LZ4_VERSION_PATCH r128)
set(RQ_LZ4_VERSION_STRING " \"${RQ_LZ4_VERSION_MAJOR}.${RQ_LZ4_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ")
set(RQ_LZ4_LIBNAME rq_lz4_static)
set(RQ_LZ4_DIR ${PROJECT_SOURCE_DIR}/external/lz4/lib/)
set(RQ_LZ4_SRCS_LIB ${RQ_LZ4_DIR}lz4.c
${RQ_LZ4_DIR}lz4hc.c
${RQ_LZ4_DIR}lz4.h
${RQ_LZ4_DIR}lz4hc.h
${RQ_LZ4_DIR}lz4frame.c
${RQ_LZ4_DIR}lz4frame.h
${RQ_LZ4_DIR}xxhash.c)
add_library(${RQ_LZ4_LIBNAME} STATIC ${RQ_LZ4_SRCS_LIB})
include(CheckCCompilerFlag)
check_c_compiler_flag("-fPIC" RQ_LZ4_PIC)
if(RQ_LZ4_PIC)
target_compile_options(
${RQ_LZ4_LIBNAME} PRIVATE
"-fPIC"
)
endif()
check_c_compiler_flag("-std=c99" RQ_FLAG_C_99)
if(RQ_FLAG_C_99)
target_compile_options(
${RQ_LZ4_LIBNAME} PRIVATE
"-std=c99"
)
endif()
set_target_properties(${RQ_LZ4_LIBNAME} PROPERTIES
SOVERSION "${RQ_LZ4_VERSION_MAJOR}.${RQ_LZ4_VERSION_MINOR}")
#set_property(TARGET lz4_static PROPERTY LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
ADD_DEFINITIONS("-DLZ4_VERSION=\"${RQ_LZ4_VERSION_PATCH}\"")
INCLUDE_DIRECTORIES (${RQ_LZ4_DIR})
# NOTE: will be used like "-Wl..flag,flag,flag" . no spaces, and keep the comma
set(RQ_LZ4_EXCLUDE_SYM ",--exclude-libs lib${RQ_LZ4_LIBNAME}.a")
# set the dependency and build it all
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_custom_target(LZ4 DEPENDS ${RQ_LZ4_LIBNAME})
set(RQ_LZ4_DEP ${RQ_LZ4_LIBNAME})
else()
add_custom_command(
OUTPUT lz4_deterministic.run
COMMAND make_deterministic ${CMAKE_CURRENT_BINARY_DIR}/lib${RQ_LZ4_LIBNAME}.a
DEPENDS ${RQ_LZ4_LIBNAME} make_deterministic
COMMENT "Removing creation date from lz4 library..."
VERBATIM
)
add_custom_target(LZ4 DEPENDS lz4_deterministic.run)
set(RQ_LZ4_DEP ${RQ_LZ4_LIBNAME})
endif()
else()
add_custom_target(LZ4)
if (USE_LZ4 MATCHES "ON")
set(RQ_LZ4_DEP ${RQ_LZ4_LIB})
endif()
endif()