-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
138 lines (124 loc) · 4.56 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
cmake_minimum_required(VERSION 3.16)
project(db-wrap
VERSION 0.2.0
LANGUAGES CXX)
# includes
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include("${PROJECT_SOURCE_DIR}/cmake/ProjectOptions.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/CompilerWarnings.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/CPM.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/FetchDepends.cmake")
# options
add_library(project_options INTERFACE)
target_compile_features(project_options INTERFACE cxx_std_20)
# library targets
add_library(db-wrap INTERFACE)
add_library(db-wrap::db-wrap ALIAS db-wrap)
target_include_directories(
db-wrap
INTERFACE
$<BUILD_INTERFACE:${DB_WRAP_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>
)
# enable warnings
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)
target_link_libraries(db-wrap INTERFACE project_warnings project_options libpqxx::pqxx Boost::pfr)
# unit tests
if (DB_WRAP_ENABLE_TESTING)
message(STATUS "DBWRAP: unit-tests enabled")
add_subdirectory(tests)
endif()
# examples
if (DB_WRAP_ENABLE_EXAMPLES)
message(STATUS "DBWRAP: examples enabled")
add_subdirectory(examples)
endif()
# docs gen
#find_package(Doxygen QUIET)
#if (DOXYGEN_FOUND)
# set(DOXYGEN_GENERATE_HTML YES)
# set(DOXYGEN_HTML_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/docs")
# set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
# set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
#
# # ref https://github.com/PacktPublishing/Modern-CMake-for-Cpp-2E/blob/main/examples/ch13/02-doxygen-nice/cmake/Doxygen.cmake
# FetchContent_Declare(doxygen-awesome-css
# GIT_REPOSITORY
# https://github.com/jothepro/doxygen-awesome-css.git
# GIT_TAG
# v2.3.1
# )
# FetchContent_MakeAvailable(doxygen-awesome-css)
# FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR)
#
# # Customize Doxygen settings for enhanced output
# set(DOXYGEN_GENERATE_TREEVIEW YES)
# set(DOXYGEN_DISABLE_INDEX NO)
# set(DOXYGEN_FULL_SIDEBAR NO)
# set(DOXYGEN_HTML_COLORSTYLE LIGHT)
#
# # Use Doxygen Awesome CSS for styling
# set(DOXYGEN_HTML_EXTRA_STYLESHEET "${AWESOME_CSS_DIR}/doxygen-awesome.css")
# set(DOXYGEN_HTML_EXTRA_FILES
# "${AWESOME_CSS_DIR}/doxygen-awesome-darkmode-toggle.js"
# "${AWESOME_CSS_DIR}/doxygen-awesome-fragment-copy-button.js"
# "${AWESOME_CSS_DIR}/doxygen-awesome-paragraph-link.js"
# "${AWESOME_CSS_DIR}/doxygen-awesome-interactive-toc.js"
# )
#
# # Strip the project source directory from include paths in the documentation
# set(DOXYGEN_STRIP_FROM_INC_PATH "${PROJECT_SOURCE_DIR}/include")
# set(DOXYGEN_EXAMPLE_PATTERNS *)
#
# execute_process(COMMAND doxygen -w html header.html footer.html style.css
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
# execute_process(COMMAND sed -i "/<\\/head>/r ${PROJECT_SOURCE_DIR}/cmake/extra_headers" header.html
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
# set(DOXYGEN_HTML_HEADER ${PROJECT_BINARY_DIR}/header.html)
#
# # Generate Doxygen documentation
# doxygen_add_docs(doxygen
# "${CMAKE_CURRENT_SOURCE_DIR}/README.md"
# "${CMAKE_CURRENT_SOURCE_DIR}/include" # Process headers in the include directory
# "${CMAKE_CURRENT_SOURCE_DIR}/docs"
# COMMENT "Generating Doxygen documentation"
# )
# file(GLOB DB_WRAP_EXAMPLE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/examples/examples_*.cpp")
# foreach(DB_WRAP_EXAMPLE_FILE ${DB_WRAP_EXAMPLE_FILES})
# get_filename_component(DB_WRAP_EXAMPLE_NAME ${DB_WRAP_EXAMPLE_FILE} NAME_WE)
# doxygen_add_example(doxygen ${DB_WRAP_EXAMPLE_FILE} "${DB_WRAP_EXAMPLE_NAME}")
# endforeach()
#else()
# message(WARNING "DBWRAP: Doxygen not found, documentation will not be generated.")
#endif()
# install targets
write_basic_package_version_file(
${DB_WRAP_CMAKE_PROJECT_CONFIG_FILE}
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
DIRECTORY ${DB_WRAP_INCLUDE_BUILD_DIR}
DESTINATION ${DB_WRAP_INCLUDE_INSTALL_DIR}
)
install(
FILES ${DB_WRAP_CMAKE_PROJECT_CONFIG_FILE} ${DB_WRAP_CMAKE_VERSION_CONFIG_FILE}
DESTINATION ${DB_WRAP_CONFIG_INSTALL_DIR}
)
#export(
# TARGETS ${DB_WRAP_TARGET_NAME}
# NAMESPACE ${PROJECT_NAME}::
# FILE ${DB_WRAP_CMAKE_PROJECT_TARGETS_FILE}
#)
#install(
# TARGETS ${DB_WRAP_TARGET_NAME}
# EXPORT ${DB_WRAP_TARGETS_EXPORT_NAME}
# INCLUDES DESTINATION ${DB_WRAP_INCLUDE_INSTALL_DIR}
#)
#install(
# EXPORT ${DB_WRAP_TARGETS_EXPORT_NAME}
# NAMESPACE ${PROJECT_NAME}::
# DESTINATION ${DB_WRAP_CONFIG_INSTALL_DIR}
#)