-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
131 lines (116 loc) · 5.09 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
# Copyright (c) 2020-2024 The Open-Transactions developers
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.26.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/modules")
project(otcommon)
include(otcommon-modules)
include(CMakePackageConfigHelpers)
option(
OTCOMMON_INSTALL_LICENSE
"Packing option to control whether or not license file is installed"
ON
)
option(
OTCOMMON_INSTALL_FORMAT
"Packing option to control whether or not formatting files are installed"
ON
)
otcommon_set_version_from_git()
set(OTCOMMON_MODULES_DIR "cmake")
if(NOT DEFINED OTCOMMON_CMAKE_INSTALL_PATH )
set(OTCOMMON_CMAKE_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/${OTCOMMON_MODULES_DIR}")
endif()
if(NOT DEFINED OTCOMMON_LICENSE_FILE_NAME )
set(OTCOMMON_LICENSE_FILE_NAME "LICENSE")
endif()
if(OTCOMMON_INSTALL_LICENSE)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_documentation
RENAME "${OTCOMMON_LICENSE_FILE_NAME}"
)
endif()
set(PACKAGE_INIT_STRING "@PACKAGE_INIT@")
set(MODULES_DIR_STRING "@PACKAGE_MODULES_DIR@")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake.in"
@ONLY
)
configure_package_config_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_BINARY_DIR}/${OTCOMMON_MODULES_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${OTCOMMON_CMAKE_INSTALL_PATH}
PATH_VARS OTCOMMON_MODULES_DIR
NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${OTCOMMON_MODULES_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${${PROJECT_NAME}_VERSION_STRING}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
install(
FILES
"${CMAKE_BINARY_DIR}/${OTCOMMON_MODULES_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_BINARY_DIR}/${OTCOMMON_MODULES_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${OTCOMMON_CMAKE_INSTALL_PATH}
COMPONENT ${PROJECT_NAME}_cmake_modules
)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/find-modules/Findlmdb.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/find-modules/Findunofficial-secp256k1.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/find-modules/Findunofficial-sodium.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/find-modules/Findunofficial-zeromq.cmake"
DESTINATION "${OTCOMMON_CMAKE_INSTALL_PATH}/find-modules"
COMPONENT ${PROJECT_NAME}_find_modules
)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-apply-defines.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-configure-target-c.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-configure-target-cxx.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-configure-target-external.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-configure-target.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-define-job-pools.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-define-signed-overflow.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-detect-compiler.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-detect-msvc-standard-library-from-vcpkg-triplet.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-find-system-libraries.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-generate-cmake-files.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-hide-symbols.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-make-iwyu-target.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-modules.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-pch-pic-workaround.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-print-build-details.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-print-target-compiler-flags.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-require-out-of-source-build.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-set-build-type.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-set-osx-deployment-target.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-set-project-language-standard.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-set-rpath.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-set-version-from-git.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/otcommon-update-submodules.cmake"
DESTINATION "${OTCOMMON_CMAKE_INSTALL_PATH}/modules"
COMPONENT ${PROJECT_NAME}_modules
)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/templates/project.pc.in"
"${CMAKE_CURRENT_SOURCE_DIR}/templates/uninstall.cmake.in"
DESTINATION "${OTCOMMON_CMAKE_INSTALL_PATH}/templates"
COMPONENT ${PROJECT_NAME}_templates
)
if(OTCOMMON_INSTALL_FORMAT)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/format/clang-format"
"${CMAKE_CURRENT_SOURCE_DIR}/format/cmake-format.py"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/format"
COMPONENT ${PROJECT_NAME}_format
)
endif()