Findnlohmann_json.cmake 1011 B

1234567891011121314151617181920212223242526272829303132333435
  1. find_package(PkgConfig QUIET)
  2. pkg_check_modules(PC_nlohmann_json QUIET nlohmann_json)
  3. find_path(nlohmann_json_INCLUDE_DIR
  4. NAMES json.hpp
  5. PATHS ${PC_nlohmann_json_INCLUDE_DIRS}
  6. PATH_SUFFIXES nlohmann
  7. )
  8. include(FindPackageHandleStandardArgs)
  9. find_package_handle_standard_args(nlohmann_json
  10. FOUND_VAR nlohmann_json_FOUND
  11. REQUIRED_VARS
  12. nlohmann_json_INCLUDE_DIR
  13. VERSION_VAR nlohmann_json_VERSION
  14. )
  15. if(nlohmann_json_FOUND)
  16. set(nlohmann_json_INCLUDE_DIRS ${nlohmann_json_INCLUDE_DIR})
  17. set(nlohmann_json_DEFINITIONS ${PC_nlohmann_json_CFLAGS_OTHER})
  18. endif()
  19. if(nlohmann_json_FOUND AND NOT TARGET nlohmann_json::nlohmann_json)
  20. add_library(nlohmann_json::nlohmann_json UNKNOWN IMPORTED)
  21. set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
  22. IMPORTED_LOCATION "${nlohmann_json_LIBRARY}"
  23. INTERFACE_COMPILE_OPTIONS "${PC_nlohmann_json_CFLAGS_OTHER}"
  24. INTERFACE_INCLUDE_DIRECTORIES "${nlohmann_json_INCLUDE_DIR}"
  25. )
  26. endif()
  27. mark_as_advanced(
  28. nlohmann_json_INCLUDE_DIR
  29. )