-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
163 lines (133 loc) · 4.19 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
CMAKE_MINIMUM_REQUIRED (VERSION 3.2)
PROJECT (sqlmdb C CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake.modules
)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
SET(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}")
# Find the QtWidgets library
find_package(Qt5Core CONFIG REQUIRED)
if ($ENV{BOOST_INCLUDEDIR})
set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
endif()
if ($ENV{BOOST_LIBRARYDIR})
set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
endif()
find_package(Boost 1.66 REQUIRED)
get_target_property(QtCore_location Qt5::Core LOCATION)
STRING(REPLACE ":" ";" default_includes "$ENV{C_INCLUDE_PATH}")
STRING(REPLACE ":" ";" default_libs "$ENV{LIBRARY_PATH}")
INCLUDE_DIRECTORIES(
inc
${Qt5Core_INCLUDE_DIRS}
${default_includes}
${Boost_INCLUDE_DIRS}
)
LINK_DIRECTORIES(
${default_libs}
${Boost_LIBRARY_DIRS}
)
foreach(DIR src)
MESSAGE(STATUS "processing ${DIR}")
file(GLOB_RECURSE TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${DIR}/*.cpp
${DIR}/*.h
${DIR}/*.hpp
${DIR}/*.c
${DIR}/*.cxx
${DIR}/*.cc
)
list(APPEND Common-files ${TMP})
list(APPEND FILES_TO_FORMAT ${TMP})
endforeach()
foreach(DIR inc)
MESSAGE(STATUS "processing ${DIR}")
file(GLOB_RECURSE TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${DIR}/*.cpp
${DIR}/*.h
${DIR}/*.hpp
${DIR}/*.c
${DIR}/*.cxx
${DIR}/*.cc
)
list(APPEND Common-headers ${TMP})
list(APPEND FILES_TO_FORMAT ${TMP})
endforeach()
ADD_LIBRARY(libsqlmdb ${Common-files} ${Common-headers})
SET(DEP_3rdParty Qt5::Core lmdb ${Boost_LIBRARIES})
IF (WIN32)
# https://github.com/google/benchmark/issues/634
LIST(APPEND DEP_3rdParty Shlwapi.lib)
ELSEIF()
LIST(APPEND DEP_3rdParty pthread)
ENDIF()
SET_TARGET_PROPERTIES(libsqlmdb PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(libsqlmdb ${DEP_3rdParty})
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
# set up a mapping so that the Release configuration for the Qt imported target is
# used in the COVERAGE CMake configuration.
set_target_properties(Qt5::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")
foreach(DIR bench)
MESSAGE(STATUS "processing ${DIR}")
file(GLOB_RECURSE TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${DIR}/*.cpp
${DIR}/*.h
${DIR}/*.hpp
${DIR}/*.c
${DIR}/*.cxx
${DIR}/*.cc
)
list(APPEND Bench-files ${TMP})
list(APPEND FILES_TO_FORMAT ${TMP})
endforeach()
ADD_EXECUTABLE(Bench ${Bench-files} ${Common-headers})
target_link_libraries(Bench ${DEP_3rdParty} benchmark libsqlmdb)
foreach(DIR tests)
MESSAGE(STATUS "processing ${DIR}")
file(GLOB_RECURSE TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${DIR}/*.cpp
${DIR}/*.h
${DIR}/*.hpp
${DIR}/*.c
${DIR}/*.cxx
${DIR}/*.cc
)
list(APPEND Test-files ${TMP})
list(APPEND FILES_TO_FORMAT ${TMP})
endforeach()
ADD_EXECUTABLE(Test ${Test-files} ${Common-headers})
target_link_libraries(Test ${DEP_3rdParty} gtest gmock libsqlmdb)
add_custom_target(
clang-format-project-files
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${FILES_TO_FORMAT}
COMMAND clang-format -i -style=file ${FILES_TO_FORMAT}
)
option(BUILD_DOC "Build documentation" ON)
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)