-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
235 lines (204 loc) · 8.49 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
cmake_minimum_required(VERSION 3.15)
project(odr LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(ODR_TEST "enable tests" OFF)
option(ODR_CLI "enable command line interface" ON)
option(ODR_CLANG_TIDY "Run clang-tidy static analysis" OFF)
option(WITH_PDF2HTMLEX "Build with pdf2htmlEX" ON)
option(WITH_WVWARE "Build with wvWare" ON)
# TODO defining global compiler flags seems to be bad practice with conan
# TODO consider using conan profiles
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using clang or gcc
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
# debugging
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
# benchmarking
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif ()
find_package(pugixml REQUIRED)
find_package(miniz REQUIRED)
find_package(cryptopp REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(vincentlaucsb-csv-parser REQUIRED)
find_package(uchardet REQUIRED)
find_package(utf8cpp REQUIRED)
configure_file("src/odr/internal/project_info.cpp.in" "src/odr/internal/project_info.cpp")
configure_file("src/odr/internal/project_info.hpp.in" "src/odr/internal/project_info.hpp")
set(PRE_CONFIGURE_FILE "src/odr/internal/git_info.cpp.in")
set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/src/odr/internal/git_info.cpp")
if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
include("cmake/git_watcher.cmake")
else ()
if (NOT DEFINED GIT_HEAD_SHA1)
set(GIT_HEAD_SHA1 "unknown")
endif ()
if (NOT DEFINED GIT_IS_DIRTY)
set(GIT_IS_DIRTY "false")
endif ()
configure_file("${PRE_CONFIGURE_FILE}" "${POST_CONFIGURE_FILE}" @ONLY)
endif ()
set(ODR_SOURCE_FILES
"src/odr/archive.cpp"
"src/odr/document.cpp"
"src/odr/document_element.cpp"
"src/odr/document_path.cpp"
"src/odr/exceptions.cpp"
"src/odr/file.cpp"
"src/odr/filesystem.cpp"
"src/odr/html.cpp"
"src/odr/html_service.cpp"
"src/odr/open_document_reader.cpp"
"src/odr/quantity.cpp"
"src/odr/style.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/src/odr/internal/git_info.cpp"
"src/odr/internal/magic.cpp"
"src/odr/internal/open_strategy.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/src/odr/internal/project_info.cpp"
"src/odr/internal/resource.cpp"
"src/odr/internal/resource_data.cpp"
"src/odr/internal/cfb/cfb_archive.cpp"
"src/odr/internal/cfb/cfb_file.cpp"
"src/odr/internal/cfb/cfb_impl.cpp"
"src/odr/internal/cfb/cfb_util.cpp"
"src/odr/internal/common/document.cpp"
"src/odr/internal/common/document_element.cpp"
"src/odr/internal/common/file.cpp"
"src/odr/internal/common/filesystem.cpp"
"src/odr/internal/common/image_file.cpp"
"src/odr/internal/common/path.cpp"
"src/odr/internal/common/random.cpp"
"src/odr/internal/common/style.cpp"
"src/odr/internal/common/table_cursor.cpp"
"src/odr/internal/common/table_position.cpp"
"src/odr/internal/common/table_range.cpp"
"src/odr/internal/common/temporary_file.cpp"
"src/odr/internal/crypto/crypto_util.cpp"
"src/odr/internal/csv/csv_file.cpp"
"src/odr/internal/csv/csv_util.cpp"
"src/odr/internal/html/common.cpp"
"src/odr/internal/html/document.cpp"
"src/odr/internal/html/document_style.cpp"
"src/odr/internal/html/document_element.cpp"
"src/odr/internal/html/filesystem.cpp"
"src/odr/internal/html/html_writer.cpp"
"src/odr/internal/html/image_file.cpp"
"src/odr/internal/html/pdf_file.cpp"
"src/odr/internal/html/text_file.cpp"
"src/odr/internal/json/json_file.cpp"
"src/odr/internal/json/json_util.cpp"
"src/odr/internal/odf/odf_crypto.cpp"
"src/odr/internal/odf/odf_document.cpp"
"src/odr/internal/odf/odf_element.cpp"
"src/odr/internal/odf/odf_file.cpp"
"src/odr/internal/odf/odf_manifest.cpp"
"src/odr/internal/odf/odf_meta.cpp"
"src/odr/internal/odf/odf_parser.cpp"
"src/odr/internal/odf/odf_spreadsheet.cpp"
"src/odr/internal/odf/odf_style.cpp"
"src/odr/internal/oldms/oldms_file.cpp"
"src/odr/internal/ooxml/presentation/ooxml_presentation_document.cpp"
"src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp"
"src/odr/internal/ooxml/presentation/ooxml_presentation_parser.cpp"
"src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.cpp"
"src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp"
"src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_parser.cpp"
"src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_style.cpp"
"src/odr/internal/ooxml/text/ooxml_text_document.cpp"
"src/odr/internal/ooxml/text/ooxml_text_element.cpp"
"src/odr/internal/ooxml/text/ooxml_text_parser.cpp"
"src/odr/internal/ooxml/text/ooxml_text_style.cpp"
"src/odr/internal/ooxml/ooxml_crypto.cpp"
"src/odr/internal/ooxml/ooxml_file.cpp"
"src/odr/internal/ooxml/ooxml_meta.cpp"
"src/odr/internal/ooxml/ooxml_util.cpp"
"src/odr/internal/pdf/pdf_cmap.cpp"
"src/odr/internal/pdf/pdf_cmap_parser.cpp"
"src/odr/internal/pdf/pdf_document.cpp"
"src/odr/internal/pdf/pdf_document_element.cpp"
"src/odr/internal/pdf/pdf_document_parser.cpp"
"src/odr/internal/pdf/pdf_file.cpp"
"src/odr/internal/pdf/pdf_file_object.cpp"
"src/odr/internal/pdf/pdf_file_parser.cpp"
"src/odr/internal/pdf/pdf_graphics_operator.cpp"
"src/odr/internal/pdf/pdf_graphics_operator_parser.cpp"
"src/odr/internal/pdf/pdf_graphics_state.cpp"
"src/odr/internal/pdf/pdf_object.cpp"
"src/odr/internal/pdf/pdf_object_parser.cpp"
"src/odr/internal/svm/svm_file.cpp"
"src/odr/internal/svm/svm_format.cpp"
"src/odr/internal/svm/svm_to_svg.cpp"
"src/odr/internal/text/text_file.cpp"
"src/odr/internal/text/text_util.cpp"
"src/odr/internal/util/byte_util.cpp"
"src/odr/internal/util/file_util.cpp"
"src/odr/internal/util/hash_util.cpp"
"src/odr/internal/util/odr_meta_util.cpp"
"src/odr/internal/util/stream_util.cpp"
"src/odr/internal/util/string_util.cpp"
"src/odr/internal/util/xml_util.cpp"
"src/odr/internal/zip/zip_archive.cpp"
"src/odr/internal/zip/zip_exceptions.cpp"
"src/odr/internal/zip/zip_file.cpp"
"src/odr/internal/zip/zip_util.cpp"
)
add_library(odr ${ODR_SOURCE_FILES})
set_target_properties(odr PROPERTIES OUTPUT_NAME odr)
target_include_directories(odr
PUBLIC
src
${CMAKE_CURRENT_BINARY_DIR}/src
)
target_link_libraries(odr
PRIVATE
pugixml::pugixml
miniz::miniz
cryptopp::cryptopp
nlohmann_json::nlohmann_json
vincentlaucsb-csv-parser::vincentlaucsb-csv-parser
uchardet::uchardet
utf8::cpp
)
if(WITH_PDF2HTMLEX)
target_sources(odr PRIVATE "src/odr/internal/html/pdf2htmlEX_wrapper.cpp")
find_package(pdf2htmlEX REQUIRED)
target_link_libraries(odr PRIVATE pdf2htmlex::pdf2htmlex)
endif(WITH_PDF2HTMLEX)
if(WITH_WVWARE)
target_sources(odr PRIVATE "src/odr/internal/html/wvWare_wrapper.cpp")
find_package(wvware REQUIRED)
target_link_libraries(odr PRIVATE wvware::wvware)
endif(WITH_WVWARE)
if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
add_dependencies(odr check_git)
endif ()
if (ODR_CLI)
add_subdirectory("cli")
endif ()
if (ODR_TEST)
add_subdirectory("test")
endif ()
if (ODR_CLANG_TIDY)
add_subdirectory("static_analysis/clang-tidy")
endif ()
install(
DIRECTORY src/ ${CMAKE_CURRENT_BINARY_DIR}/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp"
)
install(
TARGETS odr meta translate back_translate
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)