-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
54 lines (45 loc) · 1.7 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
cmake_minimum_required(VERSION 3.17)
if(NOT CMAKE_TOOLCHAIN_FILE)
if (NOT DEFINED "$ENV{VCPKG_ROOT}")
message(WARNING "VCPKG_ROOT env var not found, install vcpkg and set the env var")
endif()
set(vcpkg "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if (NOT EXISTS "${vcpkg}")
set(vcpkg "$ENV{HOME}/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()
if (EXISTS "${vcpkg}")
set(CMAKE_TOOLCHAIN_FILE "${vcpkg}"
CACHE FILEPATH "CMake toolchain file")
message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}")
else()
message(STATUS "vcpkg toolchain NOT found")
endif()
endif()
set(VCPKG_OVERLAY_PORTS "${CMAKE_SOURCE_DIR}/ports/overlay")
project(prometheus_disk_usage)
set(CMAKE_CXX_STANDARD 17)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include(CheckSymbolExists)
INCLUDE(CheckCXXSourceCompiles)
cmake_policy(SET CMP0067 NEW)
# the pre-built fmt dep was compiled with _FORTIFY_SOURCE
# and requires __snprintf_chk, normally provided by glibc.
# If compiling for musl-based linux, e.g., Alpine, this is
# not available.
# In that case, use header-only fmt and accept the slower
# compilation.
check_symbol_exists(__snprintf_chk "" HAVE_SNPRINTF_CHK)
if (NOT HAVE_SNPRINTF_CHK)
add_definitions(-DFMT_HEADER_ONLY)
endif ()
try_compile(IPO_FORTIFY_SOURCE_WORKING PROJECT musl_feature_test
SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/musl_feature_test/"
TARGET foo)
if (NOT IPO_FORTIFY_SOURCE_WORKING)
message(WARNING "-D_FORTIFY_SOURCE will cause link time failures due to ipo/lto and vsnprintf, disabling")
add_definitions(-U_FORTIFY_SOURCE)
endif()
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}")
add_subdirectory(src)
add_subdirectory(test)