-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
188 lines (140 loc) · 4.2 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
cmake_minimum_required (VERSION 3.5)
if(NOT CLANG_TIDY)
find_package(Python3)
endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
if(POLICY CMP0026)
cmake_policy(SET CMP0026 NEW)
endif()
if(POLICY CMP0051)
cmake_policy(SET CMP0051 NEW)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
# Project name and version
project (imagec
VERSION 1.0.0
HOMEPAGE_URL https://imagec.org
LANGUAGES CXX C)
# Get the current date and time
string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M:%S")
if(NOT DEFINED TAG_NAME)
message(FATAL_ERROR "TAG_NAME variable not provided!")
endif()
if("${TAG_NAME}" STREQUAL "")
set(VERSION "devel-build")
else()
set(VERSION "${TAG_NAME}")
endif()
message("Tag name is ${TAG_NAME}")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/lib")
else ()
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
endif()
# Get the current user and host
execute_process(COMMAND whoami OUTPUT_VARIABLE BUILD_USER OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND hostname OUTPUT_VARIABLE BUILD_HOST OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
#SET(CMAKE_CXX_FLAGS "-g -O0")
SET(CMAKE_GENERATOR "Unix Makefiles")
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
find_package( OpenCV REQUIRED )
find_package( PugiXML )
find_package( JNI REQUIRED )
find_package( Java COMPONENTS REQUIRED)
find_package( protobuf CONFIG REQUIRED )
find_package( libxlsxwriter CONFIG REQUIRED)
find_package( nlohmann_json CONFIG REQUIRED)
find_package( DuckDB CONFIG REQUIRED)
find_package( Qt6 REQUIRED COMPONENTS Core Gui Widgets )
find_package( ONNX REQUIRED )
SET(DuckDB_USE_STATIC_LIBS TRUE)
set(LIBS
${OpenCV_LIBS}
pugixml::pugixml
Qt6::Widgets
Qt6::Core
libxlsxwriter::libxlsxwriter
duckdb::duckdb
nlohmann_json::nlohmann_json
onnx::onnx
)
set(RESOURCE_FILES
resources/qt_conf.qrc
resources/resource.qrc
resources/icons.qrc
)
qt_add_resources(RESOURCE_SOURCES ${RESOURCE_FILES})
include_directories("./src")
include_directories(${JNI_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB_RECURSE SOURCES
./src/*.cpp
./src/*.c
./src/*.cc
${RESOURCE_SOURCES}
)
# Exclude test files from source
list(FILTER SOURCES EXCLUDE REGEX ".*_test.cpp$")
add_executable(${PROJECT_NAME} ${SOURCES})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
CMAKE_AUTOMOC ON
)
target_sources(${PROJECT_NAME} PRIVATE ${RESOURCE_SOURCES})
target_compile_definitions(${PROJECT_NAME} PUBLIC BS_THREAD_POOL_ENABLE_PRIORITY DUCKDB_BUILD_LIBRARY )
set_target_properties( ${PROJECT_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
)
target_link_libraries(${PROJECT_NAME} ${LIBS})
configure_file(
"${PROJECT_SOURCE_DIR}/src/build_info.h.in"
"${PROJECT_SOURCE_DIR}/src/build_info.h"
)
###########################################################################################
# Unittest
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
file(GLOB_RECURSE TEST_SOURCES
./src/*.cpp
./src/*.cc
./src/*.c
./test/*.cpp
${RESOURCE_SOURCES}
)
# Exclude main file from source
list(FILTER TEST_SOURCES EXCLUDE REGEX "/main\\.cpp$")
add_executable(tests ${TEST_SOURCES})
set_property(TARGET tests PROPERTY CXX_STANDARD 20)
target_sources(tests PRIVATE ${RESOURCE_SOURCES})
set_target_properties( tests
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
CMAKE_AUTOMOC ON
)
find_package(Catch2 3 REQUIRED)
set(TESTING_LIBS
Catch2::Catch2
)
set_property(TARGET tests PROPERTY CXX_STANDARD 20)
target_link_libraries(tests ${LIBS} ${TESTING_LIBS})
target_compile_definitions(tests PUBLIC UNIT_TEST BS_THREAD_POOL_ENABLE_PRIORITY)