/
CMakeLists.txt
91 lines (76 loc) · 2.06 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
add_library(core
src/check_names.cc
src/counter.cc
src/detail/builder.cc
src/detail/ckms_quantiles.cc
src/detail/time_window_quantiles.cc
src/detail/utils.cc
src/family.cc
src/gauge.cc
src/histogram.cc
src/registry.cc
src/serializer.cc
src/summary.cc
src/text_serializer.cc
)
add_library(${PROJECT_NAME}::core ALIAS core)
target_link_libraries(core
PRIVATE
Threads::Threads
$<$<AND:$<BOOL:UNIX>,$<NOT:$<BOOL:APPLE>>>:rt>
)
if(HAVE_CXX_LIBATOMIC)
# the exported library config must use libatomic unconditionally
# (the HAVE_CXX_LIBATOMIC variable should not leak into the target config)
target_link_libraries(core PUBLIC atomic)
endif()
target_include_directories(core
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
)
set_target_properties(core
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-core
DEFINE_SYMBOL PROMETHEUS_CPP_CORE_EXPORTS
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
)
generate_export_header(core
BASE_NAME ${PROJECT_NAME}-core
EXPORT_FILE_NAME include/prometheus/detail/core_export.h
)
install(
TARGETS core
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if(GENERATE_PKGCONFIG)
set(PKGCONFIG_LIBS)
set(PKGCONFIG_REQUIRES)
if(HAVE_CXX_LIBATOMIC)
string(APPEND PKGCONFIG_LIBS " -latomic")
endif()
configure_file(
${PROJECT_SOURCE_DIR}/cmake/prometheus-cpp-core.pc.in
${CMAKE_CURRENT_BINARY_DIR}/prometheus-cpp-core.pc
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/prometheus-cpp-core.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
if(benchmark_FOUND)
add_subdirectory(benchmarks)
endif()