-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (71 loc) · 2.79 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
# 3.24.1 is bundled in Visual Studio 2022 v17.4
# 3.24.1 is also bundled in CLion as of 2023
cmake_minimum_required(VERSION 3.24.1)
set(PROJECT_NAME "rudder-sdk-cpp")
file(STRINGS VERSION CURRENT_VERSION)
project(${PROJECT_NAME} VERSION ${CURRENT_VERSION} LANGUAGES CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
else()
# Check required c++ standard of parent project
if(CMAKE_CXX_STANDARD)
set(PARENT_CXX_STANDARD ${CMAKE_CXX_STANDARD})
message(STATUS "CXX standard of parent project: ${PARENT_CXX_STANDARD}")
endif()
endif()
if (PARENT_CXX_STANDARD)
# Don't set CMAKE_CXX_STANDARD if it is already set by parent project
if (PARENT_CXX_STANDARD LESS 17)
message(FATAL_ERROR "cpr ${cpr_VERSION} does not support ${PARENT_CXX_STANDARD}. Please use cpr <= 1.9.x")
endif()
else()
# Set standard version if not already set by potential parent project
set(CMAKE_CXX_STANDARD 17)
endif()
macro(rudder_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT})
if(DEFINED ENV{${OPTION_NAME}})
# Allow overriding the option through an environment variable
set(${OPTION_NAME} $ENV{${OPTION_NAME}})
endif()
if(${OPTION_NAME})
add_definitions(-D${OPTION_NAME})
endif()
message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}")
endmacro()
option(BUILD_SHARED_LIBS "Build libraries as shared libraries" ON)
message(STATUS "C++ Requests CMake Options")
message(STATUS "=======================================================")
rudder_option(RUDDER_INSERT_TIMESTAMP "Set to OFF to disable automatically insertion of timestamps." ON)
# Color our warnings and errors
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
# Fetch libcpr
include(FetchContent)
FetchContent_Declare(cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 0817715923c9705e68994eb52ef9df3f6845beba
) # The commit hash for 1.10.x. Replace with the latest from: https://github.com/libcpr/cpr/releases
FetchContent_MakeAvailable(cpr)
FetchContent_Declare(json
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
)
FetchContent_MakeAvailable(json)
add_subdirectory(rudder)
add_subdirectory(include)
target_link_libraries(
"${PROJECT_NAME}"
PUBLIC
nlohmann_json::nlohmann_json
)
target_link_libraries("${PROJECT_NAME}"
PRIVATE
cpr::cpr
)