-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
70 lines (61 loc) · 2.96 KB
/
CMakeLists.txt
File metadata and controls
70 lines (61 loc) · 2.96 KB
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
# SiddiqSoft CMakeLists
# Copyright 2024 Abdulkareem Siddiq. All rights reserved.
# See LICENSE file
#
# When building from our CI server, the following options must be set
# BUILD_TESTS ON
# CI_BUILDID must be set to the gitversion
#
cmake_minimum_required(VERSION 3.25)
# _________________
# Version detection; must preceed the declaration of the actual project()
# Figures out the value ${CURRENT_PROJECT_VERSION} and therefore the ${PROJECT_VERSION}
# Brings in the CPM module into pack/CPM.make
include(pack/CMakeCommonHelpers.cmake)
# ______________________
# Project Metadata block
project(restcl
VERSION "${CURRENT_PROJECT_VERSION}"
LANGUAGES CXX
HOMEPAGE_URL "%%myurl%%"
DESCRIPTION "Focused REST client for modern C++")
# ____________________________________
# Options; define and declare defaults
option(${PROJECT_NAME}_BUILD_TESTS "${PROJECT_NAME} - Build tests. Uncheck for install only runs" OFF)
# ____________________________________
# Library Definition
add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)
# For std::stop_token and std::jthread on Clang 18 and Clang 19 we need to enable
# the experimental-library flag.
message(STATUS "Compiler for ${PROJECT_NAME} `${CMAKE_CXX_COMPILER_ID}`")
target_compile_options( ${PROJECT_NAME}
INTERFACE
$<$<CXX_COMPILER_ID:Clang>:-fexperimental-library> )
# ____________________________________
# Dependencies
CPMAddPackage("gh:nlohmann/json#v3.11.3")
target_link_libraries(${PROJECT_NAME} INTERFACE nlohmann_json::nlohmann_json)
CPMAddPackage("gh:SiddiqSoft/SplitUri#2.1.0")
target_link_libraries(${PROJECT_NAME} INTERFACE SplitUri::SplitUri)
CPMAddPackage("gh:SiddiqSoft/AzureCppUtils#2.0.1")
target_link_libraries(${PROJECT_NAME} INTERFACE AzureCppUtils::AzureCppUtils)
CPMAddPackage("gh:SiddiqSoft/acw32h#2.7.4")
target_link_libraries(${PROJECT_NAME} INTERFACE acw32h::acw32h)
CPMAddPackage("gh:SiddiqSoft/string2map#2.4.2")
target_link_libraries(${PROJECT_NAME} INTERFACE string2map::string2map)
CPMAddPackage("gh:SiddiqSoft/asynchrony#1.8.0")
target_link_libraries(${PROJECT_NAME} INTERFACE asynchrony::asynchrony)
# ____________________________________
# Testing
# Available only when building in our repo; controlled by the switch: ${PROJECT_NAME}_BUILD_TESTS = ON
if(${${PROJECT_NAME}_BUILD_TESTS} AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests" AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
message(STATUS "${PROJECT_NAME} - Asked to build tests.. ${PROJECT_NAME}_BUILD_TESTS = ${${PROJECT_NAME}_BUILD_TESTS}")
enable_testing()
add_subdirectory(tests)
endif()