|
1 | 1 |
|
2 | 2 | function(add_nlohmann_json) |
3 | | - set(JSON_BuildTests OFF) |
4 | | - set(JSON_Install OFF) |
| 3 | + if (PHASAR_USE_CONAN) |
| 4 | + find_package(nlohmann_json REQUIRED) |
| 5 | + else() |
| 6 | + set(JSON_BuildTests OFF) |
| 7 | + set(JSON_Install OFF) |
5 | 8 |
|
6 | | - if (PHASAR_IN_TREE) |
7 | | - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json) |
8 | | - endif() |
| 9 | + if (PHASAR_IN_TREE) |
| 10 | + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json) |
| 11 | + endif() |
| 12 | + |
| 13 | + add_subdirectory(external/json EXCLUDE_FROM_ALL) |
| 14 | + set_property(TARGET nlohmann_json APPEND PROPERTY |
| 15 | + INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include> |
| 16 | + ) |
9 | 17 |
|
10 | | - add_subdirectory(external/json EXCLUDE_FROM_ALL) |
11 | | - set_property(TARGET nlohmann_json APPEND PROPERTY |
12 | | - INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include> |
13 | | - ) |
14 | | - |
15 | | - install(TARGETS nlohmann_json |
16 | | - EXPORT ${PHASAR_DEPS_EXPORT_SET} |
17 | | - LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
18 | | - ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
19 | | - RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin |
20 | | - ) |
21 | | - install(DIRECTORY external/json/include/ |
22 | | - DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include |
23 | | - ) |
| 18 | + install(TARGETS nlohmann_json |
| 19 | + EXPORT ${PHASAR_DEPS_EXPORT_SET} |
| 20 | + LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
| 21 | + ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
| 22 | + RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin |
| 23 | + ) |
| 24 | + install(DIRECTORY external/json/include/ |
| 25 | + DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include |
| 26 | + ) |
| 27 | + endif() |
24 | 28 | endfunction() |
25 | 29 |
|
26 | 30 | function(add_json_schema_validator) |
27 | | - # We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here |
28 | | - # The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator |
29 | | - # is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as |
30 | | - # in the installed state the nlohmann_json_schema_validator needs the nlohmann_json package which needs |
31 | | - # to be installed. |
32 | | - # The following workaround may collapse or become unnecessary once the issue is |
33 | | - # changed or fixed in nlohmann_json_schema_validator. |
34 | | - if (PHASAR_IN_TREE) |
35 | | - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator) |
36 | | - endif() |
| 31 | + if (PHASAR_USE_CONAN) |
| 32 | + find_package(nlohmann_json_schema_validator REQUIRED) |
| 33 | + else() |
| 34 | + # We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here |
| 35 | + # The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator |
| 36 | + # is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as |
| 37 | + # in the installed state the nlohmann_json_schema_validator needs the nlohmann_json package which needs |
| 38 | + # to be installed. |
| 39 | + # The following workaround may collapse or become unnecessary once the issue is |
| 40 | + # changed or fixed in nlohmann_json_schema_validator. |
| 41 | + if (PHASAR_IN_TREE) |
| 42 | + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator) |
| 43 | + endif() |
37 | 44 |
|
38 | | - set(JSON_VALIDATOR_INSTALL OFF) |
| 45 | + set(JSON_VALIDATOR_INSTALL OFF) |
39 | 46 |
|
40 | | - set(BUILD_SHARED_LIBS_SAVE ${BUILD_SHARED_LIBS}) |
41 | | - set(BUILD_SHARED_LIBS OFF) |
| 47 | + set(BUILD_SHARED_LIBS_SAVE ${BUILD_SHARED_LIBS}) |
| 48 | + set(BUILD_SHARED_LIBS OFF) |
42 | 49 |
|
43 | | - add_subdirectory(external/json-schema-validator EXCLUDE_FROM_ALL) |
| 50 | + add_subdirectory(external/json-schema-validator EXCLUDE_FROM_ALL) |
44 | 51 |
|
45 | | - set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVE}) |
| 52 | + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVE}) |
46 | 53 |
|
47 | | - set_property(TARGET nlohmann_json_schema_validator APPEND PROPERTY |
48 | | - INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include> |
49 | | - ) |
| 54 | + set_property(TARGET nlohmann_json_schema_validator APPEND PROPERTY |
| 55 | + INTERFACE_INCLUDE_DIRECTORIES $<INSTALL_INTERFACE:${PHASAR_DEPS_INSTALL_DESTINATION}/include> |
| 56 | + ) |
50 | 57 |
|
51 | | - install(TARGETS nlohmann_json_schema_validator |
52 | | - EXPORT ${PHASAR_DEPS_EXPORT_SET} |
53 | | - LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
54 | | - ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
55 | | - RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin |
56 | | - ) |
57 | | - install(FILES external/json-schema-validator/src/nlohmann/json-schema.hpp |
58 | | - DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann |
59 | | - ) |
| 58 | + install(TARGETS nlohmann_json_schema_validator |
| 59 | + EXPORT ${PHASAR_DEPS_EXPORT_SET} |
| 60 | + LIBRARY DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
| 61 | + ARCHIVE DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/lib |
| 62 | + RUNTIME DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/bin |
| 63 | + ) |
| 64 | + install(FILES external/json-schema-validator/src/nlohmann/json-schema.hpp |
| 65 | + DESTINATION ${PHASAR_DEPS_INSTALL_DESTINATION}/include/nlohmann |
| 66 | + ) |
| 67 | + endif() |
60 | 68 | endfunction() |
0 commit comments