-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
88 lines (67 loc) · 1.99 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
cmake_minimum_required(VERSION 3.16)
project(owm
LANGUAGES CXX
DESCRIPTION "OpenWeatherMap API client on C++"
HOMEPAGE_URL "https://github.com/LvalueReference/owm")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
message(STATUS "OWM: Build type - ${CMAKE_BUILD_TYPE}")
include(FetchContent)
message(STATUS "OWM: Installing libraries...")
FetchContent_Declare(
curl
GIT_REPOSITORY https://github.com/curl/curl
)
FetchContent_Declare(
curlpp
GIT_REPOSITORY https://github.com/jpbarrette/curlpp
)
FetchContent_Declare(
simdjson
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
)
FetchContent_Declare(
magic_enum
GIT_REPOSITORY https://github.com/Neargye/magic_enum
)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
)
set(OWM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(OWM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(OWM_BUILD_SHARED_LIBS TRUE)
set(CURL_LIBRARY libcurl)
set(CURL_INCLUDE_DIR ${CURL_SOURCE_DIR}/include)
FetchContent_MakeAvailable(curl curlpp simdjson magic_enum)
message(STATUS "OWM: Installing libraries... - done")
if (${OWM_BUILD_SHARED_LIBS} EQUAL TRUE)
set(OWM_BUILD_TYPE SHARED)
else()
set(OWM_BUILD_TYPE STATIC)
endif()
file(GLOB_RECURSE OWM_HEADERS ${OWM_INCLUDE_DIR}/*.hpp)
file(GLOB_RECURSE OWM_SOURCE ${OWM_SOURCE_DIR}/*.cpp)
add_subdirectory(examples)
include_directories(${OWM_INCLUDE_DIR})
add_library(owm ${OWM_BUILD_TYPE} ${OWM_HEADERS} ${OWM_SOURCE})
target_link_libraries(
owm PUBLIC
CURL::libcurl
simdjson::simdjson
magic_enum::magic_enum
curlpp
)
target_include_directories(
owm PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/owm>
$<INSTALL_INTERFACE:include/owm>
)
target_include_directories(
owm PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)