GetNLJSON.cmake 1022 B

1234567891011121314151617181920212223
  1. cmake_minimum_required ( VERSION 3.17 FATAL_ERROR )
  2. set ( NLJSON_GITHUB "http://github.com/nlohmann/json/archive/refs/tags/v3.12.0.tar.gz" )
  3. set ( NLJSON_BUNDLE "${LIBS_BUNDLE}/nljson-v3.12.0.tar.gz" )
  4. set ( NLJSON_SRC_MD5 "c2528c3e04faccaaee44f1f8f3d30d99" )
  5. include ( update_bundle )
  6. # determine destination folder where we expect pre-built nljson
  7. find_package ( nlohmann_json QUIET CONFIG )
  8. return_if_target_found ( nlohmann_json::nlohmann_json "found ready (no need to build)" )
  9. # not found. Populate and prepare sources
  10. select_nearest_url ( NLJSON_PLACE nlohmann_json ${NLJSON_BUNDLE} ${NLJSON_GITHUB} )
  11. fetch_and_check ( nlohmann_json ${NLJSON_PLACE} ${NLJSON_SRC_MD5} NLJSON_SRC )
  12. # build external project
  13. get_build ( NLJSON_BUILD nlohmann_json )
  14. external_build ( nlohmann_json NLJSON_SRC NLJSON_BUILD JSON_BuildTests=0 JSON_MultipleHeaders=1 JSON_GlobalUDLs=0 )
  15. # now it should find
  16. find_package ( nlohmann_json REQUIRED CONFIG )
  17. return_if_target_found ( nlohmann_json::nlohmann_json "was built and saved" )