forked from dbry/lzw-ab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
146 lines (113 loc) · 3.8 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required (VERSION 3.13)
project ("lzws" "C")
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message (FATAL_ERROR "In-source builds are not allowed")
endif ()
set (CMAKE_PROJECT_DESCRIPTION "LZW streaming compressor/decompressor")
set (CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/andrew-aladev/lzws")
set (LZWS_VERSION "1.5.7")
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set (
CMAKE_INSTALL_LIBDIR "lib"
CACHE PATH "output directory for libraries"
)
endif ()
if (NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
set (
CMAKE_INSTALL_INCLUDEDIR "include"
CACHE PATH "output directory for include files"
)
endif ()
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
set (
CMAKE_INSTALL_BINDIR "bin"
CACHE PATH "output directory for binaries"
)
endif ()
if (NOT DEFINED CMAKE_INSTALL_MANDIR)
set (
CMAKE_INSTALL_MANDIR "share/man"
CACHE PATH "Output directory for man files"
)
endif ()
# Common output directory is required for OS without rpath support.
set (CMAKE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/result")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY})
if (NOT DEFINED LZWS_TARGET)
set (LZWS_TARGET ${PROJECT_NAME})
endif ()
string (TOUPPER ${LZWS_TARGET} LZWS_TARGET_UPPERCASE)
set (
LZWS_COMPRESSOR_DICTIONARY "sparse-array"
CACHE STRING "dictionary implementation"
)
set (
LZWS_BIGNUM_LIBRARY ""
CACHE STRING "bignum library"
)
option (LZWS_SHARED "build shared binaries" ON)
option (LZWS_STATIC "build static binaries" OFF)
option (LZWS_CLI "build cli" ON)
option (LZWS_TESTS "build tests" ON)
option (LZWS_EXAMPLES "build examples" OFF)
option (LZWS_MAN "build man" OFF)
option (LZWS_COVERAGE "enable coverage" OFF)
set (LZWS_ARGTABLE3_FALLBACK "github-archive" CACHE STRING "argtable3 fallback")
if (NOT LZWS_COMPRESSOR_DICTIONARY)
message (FATAL_ERROR "Please select dictionary implementation.")
endif ()
if (NOT LZWS_SHARED AND NOT LZWS_STATIC)
message (FATAL_ERROR "Please enable building of shared or static binaries.")
endif ()
set (
CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake/checks"
"${PROJECT_SOURCE_DIR}/cmake/fetches"
"${PROJECT_SOURCE_DIR}/cmake/finds"
"${PROJECT_SOURCE_DIR}/cmake/functions"
"${PROJECT_SOURCE_DIR}/cmake/generators"
)
include (GetVerboseFlags)
cmake_get_verbose_flags ()
include (GetBuildFlags)
cmake_get_build_flags ()
if (LZWS_COVERAGE)
include (GetCoverageFlags)
cmake_get_coverage_flags ()
endif ()
include (CheckC11AndAbove)
cmake_check_c11_and_above (REQUIRED)
include (GetExportMode)
cmake_get_export_mode (REQUIRED)
include (CheckIPO)
cmake_check_ipo ()
include (CheckBignumLibrary)
cmake_check_bignum_library ("${LZWS_BIGNUM_LIBRARY}")
# Bignum library selection may be updated.
set (LZWS_BIGNUM_LIBRARY ${CMAKE_BIGNUM_LIBRARY})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_VERBOSE_C_FLAGS} ${CMAKE_PIPE_C_FLAGS} ${CMAKE_C11_AND_ABOVE_C_FLAGS}")
if (LZWS_COVERAGE)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_COVERAGE_C_FLAGS}")
endif ()
set (CMAKE_SHARED_LIBRARY_LD_FLAGS ${CMAKE_EXPORT_SHARED_LIBRARY_LD_FLAGS})
set (CMAKE_EXECUTABLE_LD_FLAGS ${CMAKE_EXPORT_EXECUTABLE_LD_FLAGS})
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE "Debug")
endif ()
if (LZWS_SHARED AND NOT CMAKE_BIGNUM_LIBRARY_SHARED_PATH)
message (FATAL_ERROR "Bignum shared library is not available.")
endif ()
if (LZWS_STATIC AND NOT CMAKE_BIGNUM_LIBRARY_STATIC_PATH)
message (FATAL_ERROR "Bignum static library is not available.")
endif ()
if (LZWS_TESTS)
enable_testing ()
endif ()
add_subdirectory ("src")
if (LZWS_MAN)
add_subdirectory ("man")
endif ()
include (CPackConfig.cmake)
include (CPack)