| 1 | # ArduinoJson - https://arduinojson.org |
| 2 | # Copyright © 2014-2026, Benoit BLANCHON |
| 3 | # MIT License |
| 4 | |
| 5 | # I have no idea what this is about, I simply followed the instructions from: |
| 6 | # https://dominikberner.ch/cmake-interface-lib/ |
| 7 | |
| 8 | add_library(ArduinoJson INTERFACE) |
| 9 | |
| 10 | include(GNUInstallDirs) |
| 11 | |
| 12 | # Adding the install interface generator expression makes sure that the include |
| 13 | # files are installed to the proper location (provided by GNUInstallDirs) |
| 14 | target_include_directories(ArduinoJson |
| 15 | INTERFACE |
| 16 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> |
| 17 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
| 18 | ) |
| 19 | |
| 20 | target_compile_definitions(ArduinoJson |
| 21 | INTERFACE |
| 22 | ARDUINOJSON_DEBUG=$<CONFIG:Debug> |
| 23 | ) |
| 24 | |
| 25 | # locations are provided by GNUInstallDirs |
| 26 | install( |
| 27 | TARGETS |
| 28 | ArduinoJson |
| 29 | EXPORT |
| 30 | ArduinoJson_Targets |
| 31 | ARCHIVE DESTINATION |
| 32 | ${CMAKE_INSTALL_LIBDIR} |
| 33 | LIBRARY DESTINATION |
| 34 | ${CMAKE_INSTALL_LIBDIR} |
| 35 | RUNTIME DESTINATION |
| 36 | ${CMAKE_INSTALL_BINDIR} |
| 37 | ) |
| 38 | |
| 39 | include(CMakePackageConfigHelpers) |
| 40 | |
| 41 | if(${CMAKE_VERSION} VERSION_GREATER "3.14.0") |
| 42 | set(ARCH_INDEPENDENT "ARCH_INDEPENDENT") |
| 43 | endif() |
| 44 | |
| 45 | write_basic_package_version_file( |
| 46 | "${PROJECT_BINARY_DIR}/ArduinoJsonConfigVersion.cmake" |
| 47 | VERSION |
| 48 | ${PROJECT_VERSION} |
| 49 | COMPATIBILITY |
| 50 | SameMajorVersion |
| 51 | ${ARCH_INDEPENDENT} |
| 52 | ) |
| 53 | |
| 54 | configure_package_config_file( |
| 55 | "${PROJECT_SOURCE_DIR}/extras/ArduinoJsonConfig.cmake.in" |
| 56 | "${PROJECT_BINARY_DIR}/ArduinoJsonConfig.cmake" |
| 57 | INSTALL_DESTINATION |
| 58 | ${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake |
| 59 | ) |
| 60 | |
| 61 | install( |
| 62 | EXPORT |
| 63 | ArduinoJson_Targets |
| 64 | FILE |
| 65 | ArduinoJsonTargets.cmake |
| 66 | DESTINATION |
| 67 | ${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake |
| 68 | ) |
| 69 | |
| 70 | install( |
| 71 | FILES |
| 72 | "${PROJECT_BINARY_DIR}/ArduinoJsonConfig.cmake" |
| 73 | "${PROJECT_BINARY_DIR}/ArduinoJsonConfigVersion.cmake" |
| 74 | DESTINATION |
| 75 | "${CMAKE_INSTALL_DATAROOTDIR}/ArduinoJson/cmake" |
| 76 | ) |
| 77 | |
| 78 | install( |
| 79 | FILES |
| 80 | ArduinoJson.h |
| 81 | ArduinoJson.hpp |
| 82 | DESTINATION |
| 83 | include |
| 84 | ) |
| 85 | |
| 86 | install( |
| 87 | DIRECTORY |
| 88 | "${CMAKE_CURRENT_SOURCE_DIR}/ArduinoJson" |
| 89 | DESTINATION |
| 90 | include |
| 91 | ) |