forked from jtv/libpqxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (58 loc) · 1.53 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
cmake_minimum_required(VERSION 3.12)
file(READ VERSION VER_FILE_CONTENT)
string(STRIP ${VER_FILE_CONTENT} VER_FILE_CONTENT)
project(
libpqxx
VERSION ${VER_FILE_CONTENT}
LANGUAGES CXX
)
if(NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
option(BUILD_DOC "Build documentation" OFF)
if(NOT SKIP_BUILD_TEST)
option(BUILD_TEST "Build all test cases" ON)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(config)
add_subdirectory(src)
add_subdirectory(include)
if(BUILD_DOC)
add_subdirectory(doc)
endif()
if(BUILD_TEST)
add_subdirectory(test)
endif()
# installation
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/libpqxx-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES cmake/libpqxx-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/libpqxx-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libpqxx
)
install(
EXPORT libpqxx-targets
NAMESPACE libpqxx::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libpqxx
)
# Build tree export
export(
EXPORT libpqxx-targets
NAMESPACE libpqxx::
FILE ${CMAKE_CURRENT_BINARY_DIR}/libpqxx-targets.cmake
)
configure_file(
cmake/libpqxx-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/libpqxx-config.cmake
COPYONLY
)
# Package generation
set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
include(CPack)