-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathCMakeLists.txt
124 lines (103 loc) · 3.67 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
cmake_minimum_required(VERSION 3.12)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()
file(STRINGS "include/hdr/hdr_histogram_version.h" HDR_VERSION_HEADER)
string(REGEX MATCH ".*#define HDR_HISTOGRAM_VERSION \"(.*)\".*" HDR_BLACK_HOLE ${HDR_VERSION_HEADER})
project(hdr_histogram
VERSION ${CMAKE_MATCH_1}
LANGUAGES C
DESCRIPTION "C port of the HdrHistogram"
HOMEPAGE_URL "http://hdrhistogram.github.io/HdrHistogram/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Follow all steps below in order to calculate new ABI version when updating the library
# NOTE: THIS IS UNRELATED to the actual project version
#
# 1. If the library source code has changed at all since the last update, then increment revision
# 2. If any interfaces have been added, removed, or changed since the last update, increment current and set revision to 0.
# 3. If any interfaces have been added since the last public release, then increment age.
# 4. If any interfaces have been removed since the last public release, then set age to 0.
set(HDR_SOVERSION_CURRENT 6)
set(HDR_SOVERSION_REVISION 1)
set(HDR_SOVERSION_AGE 3)
set(HDR_VERSION ${HDR_SOVERSION_CURRENT}.${HDR_SOVERSION_REVISION}.${HDR_SOVERSION_AGE})
set(HDR_SOVERSION ${HDR_SOVERSION_CURRENT})
option(HDR_LOG_REQUIRED "HDR Logging component required" ON)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(UNIX)
add_compile_options(
-Wall
-Wno-unknown-pragmas
-Wextra
-Wshadow
-Winit-self
-Wpedantic
$<$<COMPILE_LANGUAGE:C>:-Wmissing-prototypes>)
add_definitions(-D_GNU_SOURCE)
endif()
find_package(ZLIB)
find_package(Threads REQUIRED)
if (HDR_LOG_REQUIRED STREQUAL "DISABLED")
set(HDR_LOG_ENABLED "FALSE")
else()
set(HDR_LOG_ENABLED ${ZLIB_FOUND})
if (${HDR_LOG_REQUIRED} AND NOT HDR_LOG_ENABLED)
message(SEND_ERROR "HDR_LOG_REQUIRED=ON and unable to find zlib library")
endif()
endif()
add_subdirectory(include)
add_subdirectory(src)
option(HDR_HISTOGRAM_BUILD_PROGRAMS "Build tests and examples" ON)
if(HDR_HISTOGRAM_BUILD_PROGRAMS)
include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
add_subdirectory(examples)
endif()
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
configure_file(
config.cmake.in
${PROJECT_NAME}-config.cmake
@ONLY)
if(HDR_HISTOGRAM_INSTALL_SHARED OR HDR_HISTOGRAM_INSTALL_STATIC)
install(
EXPORT ${PROJECT_NAME}-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::)
endif()
install(
FILES
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
set(CPACK_GENERATOR "TGZ")
include(CPack)
include(JoinPaths)
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
if(${ZLIB_FOUND})
set(PC_REQUIRES_PRIVATE_ZLIB "zlib")
else()
set(PC_REQUIRES_PRIVATE_ZLIB "")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)