find_nlohmann_json.cmake 1.1 KB

123456789101112131415161718192021222324252627
  1. SET(NLOHMANN_JSON_PKG_DIR "" CACHE PATH "Path to nlohmann/json package directory")
  2. SET(NLOHMANN_JSON_INC_DIR "" CACHE PATH "Path to nlohmann/json include directory")
  3. SET(NLOHMANN_JSON_SRC_DIR "" CACHE PATH "Path to nlohmann/json source directory")
  4. IF (NOT NLOHMANN_JSON_PKG_DIR STREQUAL "")
  5. find_package(nlohmann_json CONFIG PATHS ${NLOHMANN_JSON_PKG_DIR})
  6. message(STATUS "Using nlohmann/json package from ${NLOHMANN_JSON_PKG_DIR}")
  7. ELSE()
  8. find_package(nlohmann_json CONFIG)
  9. ENDIF()
  10. IF (NOT nlohmann_json_FOUND)
  11. IF(NOT NLOHMANN_JSON_SRC_DIR STREQUAL "")
  12. set (nlohmann_json_FOUND TRUE)
  13. ADD_SUBDIRECTORY(${NLOHMANN_JSON_SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json)
  14. message(STATUS "Using nlohmann/json source from ${NLOHMANN_JSON_SRC_DIR}")
  15. ELSEIF(NOT NLOHMANN_JSON_INC_DIR STREQUAL "")
  16. set (nlohmann_json_FOUND TRUE)
  17. INCLUDE_DIRECTORIES(${NLOHMANN_JSON_INC_DIR})
  18. message(STATUS "Using nlohmann/json include from ${NLOHMANN_JSON_INC_DIR}")
  19. ENDIF()
  20. ENDIF()
  21. IF (NOT nlohmann_json_FOUND)
  22. message(FATAL_ERROR "nlohmann/json not found")
  23. ENDIF()