kou commented on a change in pull request #11963:
URL: https://github.com/apache/arrow/pull/11963#discussion_r822089248
##########
File path: cpp/cmake_modules/ThirdpartyToolchain.cmake
##########
@@ -3749,36 +3754,42 @@ macro(build_crc32c_once)
endif()
endmacro()
-macro(build_nlohmann_json_once)
- if(NOT TARGET nlohmann_json_ep)
- message(STATUS "Building nlohmann-json from source")
- # "Build" nlohmann-json
- set(NLOHMANN_JSON_PREFIX
"${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json_ep-install")
- set(NLOHMANN_JSON_INCLUDE_DIR "${NLOHMANN_JSON_PREFIX}/include")
- set(NLOHMANN_JSON_CMAKE_ARGS
- ${EP_COMMON_CMAKE_ARGS} "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
- -DBUILD_TESTING=OFF -DJSON_BuildTests=OFF)
+macro(build_nlohmann_json)
+ message(STATUS "Building nlohmann-json from source")
+ # "Build" nlohmann-json
+ set(NLOHMANN_JSON_PREFIX
"${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json_ep-install")
+ set(NLOHMANN_JSON_INCLUDE_DIR "${NLOHMANN_JSON_PREFIX}/include")
+ set(NLOHMANN_JSON_CMAKE_ARGS
+ ${EP_COMMON_CMAKE_ARGS} "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
-DBUILD_TESTING=OFF
+ -DJSON_BuildTests=OFF)
- set(NLOHMANN_JSON_BUILD_BYPRODUCTS
${NLOHMANN_JSON_PREFIX}/include/nlohmann/json.hpp)
+ set(NLOHMANN_JSON_BUILD_BYPRODUCTS
${NLOHMANN_JSON_PREFIX}/include/nlohmann/json.hpp)
- externalproject_add(nlohmann_json_ep
- ${EP_LOG_OPTIONS}
- INSTALL_DIR ${NLOHMANN_JSON_PREFIX}
- URL ${NLOHMANN_JSON_SOURCE_URL}
- URL_HASH
"SHA256=${ARROW_NLOHMANN_JSON_BUILD_SHA256_CHECKSUM}"
- CMAKE_ARGS ${NLOHMANN_JSON_CMAKE_ARGS}
- BUILD_BYPRODUCTS ${NLOHMANN_JSON_BUILD_BYPRODUCTS})
+ externalproject_add(nlohmann_json_ep
+ ${EP_LOG_OPTIONS}
+ INSTALL_DIR ${NLOHMANN_JSON_PREFIX}
+ URL ${NLOHMANN_JSON_SOURCE_URL}
+ URL_HASH
"SHA256=${ARROW_NLOHMANN_JSON_BUILD_SHA256_CHECKSUM}"
+ CMAKE_ARGS ${NLOHMANN_JSON_CMAKE_ARGS}
+ BUILD_BYPRODUCTS ${NLOHMANN_JSON_BUILD_BYPRODUCTS})
- # Work around https://gitlab.kitware.com/cmake/cmake/issues/15052
- file(MAKE_DIRECTORY ${NLOHMANN_JSON_INCLUDE_DIR})
+ # Work around https://gitlab.kitware.com/cmake/cmake/issues/15052
+ file(MAKE_DIRECTORY ${NLOHMANN_JSON_INCLUDE_DIR})
- add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
- set_target_properties(nlohmann_json::nlohmann_json
- PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
- "${NLOHMANN_JSON_INCLUDE_DIR}")
- add_dependencies(nlohmann_json::nlohmann_json nlohmann_json_ep)
- endif()
+ add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
+ set_target_properties(nlohmann_json::nlohmann_json
+ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${NLOHMANN_JSON_INCLUDE_DIR}")
+ add_dependencies(nlohmann_json::nlohmann_json nlohmann_json_ep)
endmacro()
+if(ARROW_WITH_NLOHMANN_JSON)
+ set(nlohmann_json_SOURCE "AUTO")
Review comment:
I think that it's a problem of our CI configuration not the CMake code.
Some of our CI jobs uses `-DARROW_DEPENDENCY_SOURCE=SYSTEM` explicitly to
use system libraries. For example:
https://github.com/apache/arrow/runs/5465413563?check_suite_focus=true#step:6:1843
```text
cmake ... -DARROW_DEPENDENCY_SOURCE=SYSTEM ...
```
In the CI jobs, we must install `nlohmann-json` explicitly. e.g.:
* MSYS2: https://packages.msys2.org/base/mingw-w64-nlohmann-json
* Debian: https://packages.debian.org/search?keywords=nlohmann-json
* Ubuntu: https://packages.ubuntu.com/search?keywords=nlohmann-json
Here is a sample change for MSYS2:
```diff
diff --git a/ci/scripts/msys2_setup.sh b/ci/scripts/msys2_setup.sh
index 01cd5fa9ee..be6a947c6f 100755
--- a/ci/scripts/msys2_setup.sh
+++ b/ci/scripts/msys2_setup.sh
@@ -41,6 +41,7 @@ case "${target}" in
packages+=(${MINGW_PACKAGE_PREFIX}-make)
packages+=(${MINGW_PACKAGE_PREFIX}-mlir)
packages+=(${MINGW_PACKAGE_PREFIX}-ninja)
+ packages+=(${MINGW_PACKAGE_PREFIX}-nlohmann-json)
packages+=(${MINGW_PACKAGE_PREFIX}-polly)
packages+=(${MINGW_PACKAGE_PREFIX}-protobuf)
packages+=(${MINGW_PACKAGE_PREFIX}-python3-numpy)
```
If there isn't `nlohmann-json` package in the system, we need to specify
`-Dnlohmann_json_SOURCE=BUNDLED` explicitly for the CI jobs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]