|
1 | | -if("${nlohmann-json}" STREQUAL "") |
2 | | - set(nlohmann-json "v3.9.1") |
3 | | -endif() |
4 | | -include(ExternalProject) |
5 | | -ExternalProject_Add(nlohmann_json_download |
6 | | - GIT_REPOSITORY https://github.com/nlohmann/json.git |
7 | | - GIT_TAG |
8 | | - "${nlohmann-json}" |
9 | | - UPDATE_COMMAND "" |
10 | | - CMAKE_ARGS |
11 | | - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} |
12 | | - -DJSON_BuildTests=OFF |
13 | | - -DJSON_Install=ON |
14 | | - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} |
15 | | - TEST_AFTER_INSTALL |
16 | | - 0 |
17 | | - DOWNLOAD_NO_PROGRESS |
18 | | - 1 |
19 | | - LOG_CONFIGURE |
20 | | - 1 |
21 | | - LOG_BUILD |
22 | | - 1 |
23 | | - LOG_INSTALL |
24 | | - 1 |
25 | | -) |
26 | | - |
27 | | -ExternalProject_Get_Property(nlohmann_json_download INSTALL_DIR) |
28 | | -SET(NLOHMANN_JSON_INCLUDE_DIR ${INSTALL_DIR}/third_party/src/nlohmann_json_download/single_include) |
29 | | -add_library(nlohmann_json_ INTERFACE) |
30 | | -target_include_directories(nlohmann_json_ INTERFACE |
31 | | - "$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_DIR}>" |
32 | | - "$<INSTALL_INTERFACE:include>") |
33 | | -add_dependencies(nlohmann_json_ nlohmann_json_download) |
34 | | -add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json_) |
35 | | - |
36 | | -install( |
37 | | - TARGETS nlohmann_json_ |
38 | | - EXPORT "${PROJECT_NAME}-target" |
39 | | - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
40 | | - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
41 | | - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 1 | +if("${nlohmann-json}" STREQUAL "") |
| 2 | + set(nlohmann-json "v3.9.1") |
| 3 | +endif() |
| 4 | +include(ExternalProject) |
| 5 | +ExternalProject_Add(nlohmann_json_download |
| 6 | + PREFIX nlohmann_json |
| 7 | + GIT_REPOSITORY https://github.com/nlohmann/json.git |
| 8 | + GIT_TAG |
| 9 | + "${nlohmann-json}" |
| 10 | + GIT_SHALLOW 1 |
| 11 | + UPDATE_COMMAND "" |
| 12 | + CMAKE_ARGS |
| 13 | + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} |
| 14 | + -DJSON_BuildTests=OFF |
| 15 | + -DJSON_Install=ON |
| 16 | + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} |
| 17 | + TEST_AFTER_INSTALL |
| 18 | + 0 |
| 19 | + DOWNLOAD_NO_PROGRESS |
| 20 | + 1 |
| 21 | + LOG_CONFIGURE |
| 22 | + 1 |
| 23 | + LOG_BUILD |
| 24 | + 1 |
| 25 | + LOG_INSTALL |
| 26 | + 1 |
| 27 | +) |
| 28 | + |
| 29 | +ExternalProject_Get_Property(nlohmann_json_download INSTALL_DIR) |
| 30 | +SET(NLOHMANN_JSON_INCLUDE_DIR ${INSTALL_DIR}/nlohmann_json/src/nlohmann_json_download/single_include) |
| 31 | +add_library(nlohmann_json_ INTERFACE) |
| 32 | +target_include_directories(nlohmann_json_ INTERFACE |
| 33 | + "$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_DIR}>" |
| 34 | + "$<INSTALL_INTERFACE:include>") |
| 35 | +add_dependencies(nlohmann_json_ nlohmann_json_download) |
| 36 | +add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json_) |
| 37 | + |
| 38 | +install( |
| 39 | + TARGETS nlohmann_json_ |
| 40 | + EXPORT "${PROJECT_NAME}-target" |
| 41 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 42 | + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 43 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
0 commit comments