Skip to content

Commit eaa66ea

Browse files
committed
Use FetchContent to fetch nlohmann_json
1 parent 2e3d3df commit eaa66ea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
1616
set(LIBSCRATCHCPP_COMPUTED_GOTO OFF CACHE BOOL "" FORCE)
1717
endif()
1818

19-
find_package(nlohmann_json 3.9.1 REQUIRED)
2019
find_package(utf8cpp REQUIRED)
2120

2221
add_library(scratchcpp SHARED)
@@ -66,6 +65,8 @@ target_sources(scratchcpp
6665
include/scratchcpp/imonitorhandler.h
6766
)
6867

68+
include(FetchContent)
69+
6970
add_library(zip SHARED
7071
${ZIP_SRC}/zip.c
7172
${ZIP_SRC}/zip.h
@@ -75,13 +76,15 @@ include_directories(thirdparty/zip/src)
7576

7677
include_directories(thirdparty/spimpl)
7778

79+
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
80+
FetchContent_MakeAvailable(json)
81+
7882
target_link_libraries(scratchcpp PRIVATE nlohmann_json::nlohmann_json)
7983
target_link_libraries(scratchcpp PRIVATE utf8cpp)
8084
target_link_libraries(scratchcpp PRIVATE zip)
8185
target_link_libraries(scratchcpp PRIVATE scratchcpp-audio)
8286

8387
if (LIBSCRATCHCPP_NETWORK_SUPPORT)
84-
include(FetchContent)
8588
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
8689
GIT_TAG 3b15fa82ea74739b574d705fea44959b58142eb8) # 1.10.5
8790
FetchContent_MakeAvailable(cpr)

0 commit comments

Comments
 (0)