forked from AimRT/AimRT
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGetJsonCpp.cmake
64 lines (54 loc) · 1.27 KB
/
GetJsonCpp.cmake
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
# Copyright (c) 2023, AgiBot Inc.
# All rights reserved.
include(FetchContent)
message(STATUS "get jsoncpp ...")
set(jsoncpp_DOWNLOAD_URL
"https://github.com/open-source-parsers/jsoncpp/archive/1.9.5.tar.gz"
CACHE STRING "")
if(jsoncpp_LOCAL_SOURCE)
FetchContent_Declare(
jsoncpp
SOURCE_DIR ${jsoncpp_LOCAL_SOURCE}
OVERRIDE_FIND_PACKAGE)
else()
FetchContent_Declare(
jsoncpp
URL ${jsoncpp_DOWNLOAD_URL}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
endif()
FetchContent_GetProperties(jsoncpp)
if(NOT jsoncpp_POPULATED)
set(JSONCPP_WITH_TESTS
OFF
CACHE BOOL "")
set(JSONCPP_WITH_POST_BUILD_UNITTEST
OFF
CACHE BOOL "")
set(BUILD_OBJECT_LIBS
OFF
CACHE BOOL "")
if(BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS
ON
CACHE BOOL "")
set(BUILD_STATIC_LIBS
OFF
CACHE BOOL "")
else()
set(BUILD_SHARED_LIBS
OFF
CACHE BOOL "")
set(BUILD_STATIC_LIBS
ON
CACHE BOOL "")
endif()
FetchContent_MakeAvailable(jsoncpp)
if(TARGET jsoncpp_static)
add_library(jsoncpp::jsoncpp ALIAS jsoncpp_static)
elseif(TARGET jsoncpp_lib)
add_library(jsoncpp::jsoncpp ALIAS jsoncpp_lib)
endif()
endif()
# import targets:
# jsoncpp::jsoncpp