-
Notifications
You must be signed in to change notification settings - Fork 40
/
CMakeLists.txt
90 lines (73 loc) · 2.88 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
# Copyright The ViaDuck Project 2016 - 2021.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE or copy at
# http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.8)
project(mariadbclientpp LANGUAGES CXX)
include(GNUInstallDirs)
option(MARIADBPP_TEST "Build mariadbpp tests" OFF)
option(MARIADBPP_DOC "Build mariadbpp docs" OFF)
option(MARIADBPP_QUIET "Turn off error logging" OFF)
# add additional cmake modules
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/external/cmake-modules")
# dependencies
find_package(MariaDBClient REQUIRED)
find_package(Threads REQUIRED)
# find files
file(GLOB mariadbclientpp_PUBLIC_HEADERS include/mariadb++/*)
file(GLOB mariadbclientpp_PRIVATE_HEADERS src/*.hpp)
file(GLOB mariadbclientpp_SOURCES src/*.cpp)
# set up target
add_library(mariadbclientpp ${mariadbclientpp_SOURCES} ${mariadbclientpp_PUBLIC_HEADERS} ${mariadbclientpp_PRIVATE_HEADERS})
# target options
target_link_libraries(mariadbclientpp MariaDBClient::MariaDBClient Threads::Threads)
target_include_directories(
mariadbclientpp
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_compile_features(mariadbclientpp PUBLIC cxx_std_11)
target_compile_definitions(mariadbclientpp PUBLIC MARIADB_QUIET=$<BOOL:${MARIADBPP_QUIET}>)
if (MSVC)
target_compile_options(mariadbclientpp PRIVATE /W4)
else()
target_compile_options(mariadbclientpp PRIVATE -Wall -Wextra)
endif()
# install configuration
install(FILES ${mariadbclientpp_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mariadb++)
install(TARGETS mariadbclientpp
EXPORT mariadbclientpp_export
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
configure_file("cmake/mariadbclientpp-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/mariadbclientpp-config.cmake" @ONLY)
install(
EXPORT mariadbclientpp_export
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mariadbclientpp"
NAMESPACE "mariadbclientpp::"
# In this CMake config file no dependencies are considered. But since we
# do not use any `find_package` call here this approach is sufficient.
FILE mariadbclientpp-targets.cmake
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mariadbclientpp-config.cmake"
"${PROJECT_SOURCE_DIR}/external/cmake-modules/FindMariaDBClient.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mariadbclientpp")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MariaDB++")
SET(CPACK_PACKAGE_VENDOR "ViaDuck")
SET(CPACK_PACKAGE_VERSION "1.0.0")
SET(CPACK_GENERATOR "RPM;DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nobody")
INCLUDE(CPack)
# tests
if (MARIADBPP_TEST)
add_subdirectory(test)
endif()
if (MARIADBPP_DOC)
# doxygen
include(Doxygen)
if (DOXYGEN_FOUND)
setup_doxygen(mariadbpp_doc ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
endif()
endif()