@@ -63,6 +63,7 @@ set(ARROW_THIRDPARTY_DEPENDENCIES
6363 GTest
6464 LLVM
6565 Lz4
66+ nlohmann_json
6667 opentelemetry-cpp
6768 ORC
6869 re2
@@ -162,6 +163,8 @@ macro(build_dependency DEPENDENCY_NAME)
162163 build_gtest ()
163164 elseif ("${DEPENDENCY_NAME} " STREQUAL "Lz4" )
164165 build_lz4 ()
166+ elseif ("${DEPENDENCY_NAME} " STREQUAL "nlohmann_json" )
167+ build_nlohmann_json ()
165168 elseif ("${DEPENDENCY_NAME} " STREQUAL "opentelemetry-cpp" )
166169 build_opentelemetry ()
167170 elseif ("${DEPENDENCY_NAME} " STREQUAL "ORC" )
@@ -276,6 +279,7 @@ if(PARQUET_REQUIRE_ENCRYPTION)
276279endif ()
277280
278281if (ARROW_WITH_OPENTELEMETRY)
282+ set (ARROW_WITH_NLOHMANN_JSON ON )
279283 set (ARROW_WITH_PROTOBUF ON )
280284endif ()
281285
@@ -304,6 +308,7 @@ endif()
304308
305309if (ARROW_GCS)
306310 set (ARROW_WITH_GOOGLE_CLOUD_CPP ON )
311+ set (ARROW_WITH_NLOHMANN_JSON ON )
307312endif ()
308313
309314if (ARROW_JSON)
@@ -3772,36 +3777,41 @@ macro(build_crc32c_once)
37723777 endif ()
37733778endmacro ()
37743779
3775- macro (build_nlohmann_json_once )
3776- if (NOT TARGET nlohmann_json_ep)
3777- message (STATUS "Building nlohmann-json from source" )
3778- # "Build" nlohmann-json
3779- set (NLOHMANN_JSON_PREFIX "${CMAKE_CURRENT_BINARY_DIR } /nlohmann_json_ep-install" )
3780- set (NLOHMANN_JSON_INCLUDE_DIR "${NLOHMANN_JSON_PREFIX} /include" )
3781- set (NLOHMANN_JSON_CMAKE_ARGS
3782- ${EP_COMMON_CMAKE_ARGS} "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
3783- -DBUILD_TESTING=OFF -DJSON_BuildTests=OFF )
3780+ macro (build_nlohmann_json )
3781+ message (STATUS "Building nlohmann-json from source" )
3782+ # "Build" nlohmann-json
3783+ set (NLOHMANN_JSON_PREFIX "${CMAKE_CURRENT_BINARY_DIR } /nlohmann_json_ep-install" )
3784+ set (NLOHMANN_JSON_INCLUDE_DIR "${NLOHMANN_JSON_PREFIX} /include" )
3785+ set (NLOHMANN_JSON_CMAKE_ARGS
3786+ ${EP_COMMON_CMAKE_ARGS} "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" -DBUILD_TESTING=OFF
3787+ -DJSON_BuildTests=OFF )
37843788
3785- set (NLOHMANN_JSON_BUILD_BYPRODUCTS ${NLOHMANN_JSON_PREFIX} /include/nlohmann/json.hpp)
3789+ set (NLOHMANN_JSON_BUILD_BYPRODUCTS ${NLOHMANN_JSON_PREFIX} /include/nlohmann/json.hpp)
37863790
3787- externalproject_add (nlohmann_json_ep
3788- ${EP_LOG_OPTIONS}
3789- INSTALL_DIR ${NLOHMANN_JSON_PREFIX}
3790- URL ${NLOHMANN_JSON_SOURCE_URL}
3791- URL_HASH "SHA256=${ARROW_NLOHMANN_JSON_BUILD_SHA256_CHECKSUM} "
3792- CMAKE_ARGS ${NLOHMANN_JSON_CMAKE_ARGS}
3793- BUILD_BYPRODUCTS ${NLOHMANN_JSON_BUILD_BYPRODUCTS} )
3791+ externalproject_add (nlohmann_json_ep
3792+ ${EP_LOG_OPTIONS}
3793+ INSTALL_DIR ${NLOHMANN_JSON_PREFIX}
3794+ URL ${NLOHMANN_JSON_SOURCE_URL}
3795+ URL_HASH "SHA256=${ARROW_NLOHMANN_JSON_BUILD_SHA256_CHECKSUM} "
3796+ CMAKE_ARGS ${NLOHMANN_JSON_CMAKE_ARGS}
3797+ BUILD_BYPRODUCTS ${NLOHMANN_JSON_BUILD_BYPRODUCTS} )
37943798
3795- # Work around https://gitlab.kitware.com/cmake/cmake/issues/15052
3796- file (MAKE_DIRECTORY ${NLOHMANN_JSON_INCLUDE_DIR} )
3799+ # Work around https://gitlab.kitware.com/cmake/cmake/issues/15052
3800+ file (MAKE_DIRECTORY ${NLOHMANN_JSON_INCLUDE_DIR} )
37973801
3798- add_library (nlohmann_json::nlohmann_json INTERFACE IMPORTED )
3799- set_target_properties (nlohmann_json::nlohmann_json
3800- PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
3801- "${NLOHMANN_JSON_INCLUDE_DIR} " )
3802- add_dependencies (nlohmann_json::nlohmann_json nlohmann_json_ep )
3803- endif ()
3802+ add_library (nlohmann_json::nlohmann_json INTERFACE IMPORTED )
3803+ set_target_properties (nlohmann_json::nlohmann_json
3804+ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
3805+ "${NLOHMANN_JSON_INCLUDE_DIR} " )
3806+ add_dependencies (nlohmann_json::nlohmann_json nlohmann_json_ep )
38043807endmacro ()
3808+ if (ARROW_WITH_NLOHMANN_JSON)
3809+ resolve_dependency (nlohmann_json )
3810+ get_target_property (nlohmann_json_INCLUDE_DIR nlohmann_json::nlohmann_json
3811+ INTERFACE_INCLUDE_DIRECTORIES )
3812+ include_directories (SYSTEM ${nlohmann_json_INCLUDE_DIR} )
3813+ message (STATUS "Found nlohmann_json headers: ${nlohmann_json_INCLUDE_DIR} " )
3814+ endif ()
38053815
38063816macro (build_google_cloud_cpp_storage )
38073817 message (STATUS "Building google-cloud-cpp from source" )
@@ -3810,7 +3820,6 @@ macro(build_google_cloud_cpp_storage)
38103820 # List of dependencies taken from https://github.com/googleapis/google-cloud-cpp/blob/master/doc/packaging.md
38113821 build_absl_once ()
38123822 build_crc32c_once ()
3813- build_nlohmann_json_once ()
38143823
38153824 # Curl is required on all platforms, but building it internally might also trip over S3's copy.
38163825 # For now, force its inclusion from the underlying system or fail.
@@ -3850,7 +3859,7 @@ macro(build_google_cloud_cpp_storage)
38503859
38513860 add_dependencies (google_cloud_cpp_dependencies absl_ep )
38523861 add_dependencies (google_cloud_cpp_dependencies crc32c_ep )
3853- add_dependencies (google_cloud_cpp_dependencies nlohmann_json_ep )
3862+ add_dependencies (google_cloud_cpp_dependencies nlohmann_json::nlohmann_json )
38543863
38553864 set (GOOGLE_CLOUD_CPP_STATIC_LIBRARY_STORAGE
38563865 "${GOOGLE_CLOUD_CPP_INSTALL_PREFIX} /lib/${CMAKE_STATIC_LIBRARY_PREFIX } google_cloud_cpp_storage${CMAKE_STATIC_LIBRARY_SUFFIX } "
@@ -4043,9 +4052,6 @@ endif()
40434052macro (build_opentelemetry )
40444053 message (STATUS "Building OpenTelemetry from source" )
40454054
4046- build_nlohmann_json_once ()
4047- find_curl ()
4048-
40494055 set (OPENTELEMETRY_PREFIX "${CMAKE_CURRENT_BINARY_DIR } /opentelemetry_ep-install" )
40504056 set (OPENTELEMETRY_INCLUDE_DIR "${OPENTELEMETRY_PREFIX} /include" )
40514057 set (OPENTELEMETRY_STATIC_LIB
@@ -4153,8 +4159,8 @@ macro(build_opentelemetry)
41534159 INSTALL_COMMAND ""
41544160 EXCLUDE_FROM_ALL OFF )
41554161
4156- add_dependencies (opentelemetry_dependencies nlohmann_json_ep opentelemetry_proto_ep
4157- ${ARROW_PROTOBUF_LIBPROTOBUF} )
4162+ add_dependencies (opentelemetry_dependencies nlohmann_json::nlohmann_json
4163+ opentelemetry_proto_ep ${ARROW_PROTOBUF_LIBPROTOBUF} )
41584164
41594165 set (OPENTELEMETRY_PREFIX_PATH_LIST_SEP_CHAR "|" )
41604166 # JOIN is CMake >=3.12 only
@@ -4245,6 +4251,9 @@ macro(build_opentelemetry)
42454251endmacro ()
42464252
42474253if (ARROW_WITH_OPENTELEMETRY)
4254+ # cURL is required whether we build from source or use an existing installation
4255+ # (OTel's cmake files do not call find_curl for you)
4256+ find_curl ()
42484257 set (opentelemetry-cpp_SOURCE "AUTO" )
42494258 resolve_dependency (opentelemetry-cpp )
42504259 get_target_property (OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::api
0 commit comments