This issue is a result of a Codex global repository scan.
When ENABLE_RAPIDJSON is on, the top-level CMake first calls find_package(RapidJSON). Even if that succeeds, it then sets RapidJSON_INCLUDE_PATH from ${rapidjson_SOURCE_DIR}/include, which is only defined for the FetchContent fallback. A package found from an installed RapidJSON config can therefore be ignored and leave the include path empty or incorrect.
Top-level CMake:
|
# enable json support |
|
if(ENABLE_RAPIDJSON) |
|
find_package(RapidJSON) |
|
if(NOT RapidJSON_FOUND) |
|
message( |
|
WARNING |
|
"Rapidjson is not found, trying downloading from github, or you can install Rapidjson first and reinstall abacus." |
|
) |
|
include(FetchContent) |
|
FetchContent_Declare( |
|
rapidjson |
|
URL https://codeload.github.com/Tencent/rapidjson/tar.gz/24b5e7a |
|
) |
|
set(RAPIDJSON_BUILD_TESTS |
|
OFF |
|
CACHE INTERNAL "") |
|
set(RAPIDJSON_BUILD_EXAMPLES |
|
OFF |
|
CACHE INTERNAL "") |
|
FetchContent_MakeAvailable(rapidjson) |
|
endif() |
|
set(RapidJSON_INCLUDE_PATH "${rapidjson_SOURCE_DIR}/include") |
|
add_compile_definitions(__RAPIDJSON) |
|
add_definitions(-DRAPIDJSON_HAS_CXX11_NOEXCEPT=0) |
|
include_directories(${RapidJSON_INCLUDE_PATH}) |
The toolchain-generated config also writes a literal placeholder instead of the installed include directory:
|
mkdir -p "${pkg_install_dir}" |
|
cp -r $dirname/* "${pkg_install_dir}/" |
|
# for rapidjson found in cmake |
|
cat << EOF > "${pkg_install_dir}/RapidJSONConfig.cmake" |
|
get_filename_component(RAPIDJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) |
|
set(RAPIDJSON_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@") |
|
message(STATUS "RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}") |
|
EOF |
Relevant code:
find_package(RapidJSON)
if(NOT RapidJSON_FOUND)
FetchContent_Declare(rapidjson ...)
FetchContent_MakeAvailable(rapidjson)
endif()
set(RapidJSON_INCLUDE_PATH "${rapidjson_SOURCE_DIR}/include")
include_directories(${RapidJSON_INCLUDE_PATH})
Suggested fix:
When RapidJSON_FOUND is true, use the include variable or imported target exported by the package. Only use ${rapidjson_SOURCE_DIR}/include after the FetchContent fallback. Also generate a valid RapidJSONConfig.cmake in the toolchain with the real install include path.
This issue is a result of a Codex global repository scan.
When
ENABLE_RAPIDJSONis on, the top-level CMake first callsfind_package(RapidJSON). Even if that succeeds, it then setsRapidJSON_INCLUDE_PATHfrom${rapidjson_SOURCE_DIR}/include, which is only defined for the FetchContent fallback. A package found from an installed RapidJSON config can therefore be ignored and leave the include path empty or incorrect.Top-level CMake:
abacus-develop/CMakeLists.txt
Lines 64 to 88 in 84ca04b
The toolchain-generated config also writes a literal placeholder instead of the installed include directory:
abacus-develop/toolchain/scripts/stage4/install_rapidjson.sh
Lines 72 to 79 in 84ca04b
Relevant code:
Suggested fix:
When
RapidJSON_FOUNDis true, use the include variable or imported target exported by the package. Only use${rapidjson_SOURCE_DIR}/includeafter the FetchContent fallback. Also generate a validRapidJSONConfig.cmakein the toolchain with the real install include path.