rapidjson icon indicating copy to clipboard operation
rapidjson copied to clipboard

When including rapidjson for LMDeploy, I encountered cmake errors

Open serser opened this issue 10 months ago • 4 comments

I was following https://lmdeploy.readthedocs.io/en/latest/build.html for LMDeploy compilation. As the following install doesn't help

sudo yum install rapidjson-devel

I pick up with source installation, but it shows a CMake Error:

CMake Error at ~/proj/rapidjson/RapidJSONConfig.cmake:3 (include):
  include could not find requested file:

   ~/proj/rapidjson/RapidJSON-targets.cmake
Call Stack (most recent call first):
  build/_deps/repo-common-src/CMakeLists.txt:43 (find_package)


CMake Error at ~/proj/rapidjson/RapidJSONConfig.cmake:17 (get_target_property):
  get_target_property() called with non-existent target "RapidJSON".

To disable the errors, I comment out these lines,

#include ("${CMAKE_CURRENT_LIST_DIR}/RapidJSON-targets.cmake")
#get_target_property(RapidJSON_INCLUDE_DIR RapidJSON INTERFACE_INCLUDE_DIRECTORIES)

What shall be the suggested way to resolve the problem and why is it reporting an error?

BR

serser avatar Apr 01 '24 11:04 serser

The same issue. I built it via cmake .. on ../build/ path, then when I tried to find_package(RapidJSON) as in the guide on the main page I got

CMake Error at SpaceShipBP/lib/third-party/RapidJson/build/RapidJSONConfig.cmake:3 (include):
  include could not find requested file:

    D:/Archive/Projects/Large/SpaceShipBP/SpaceShipBP/lib/third-party/RapidJson/build/RapidJSON-targets.cmake
Call Stack (most recent call first):
  CMakeLists.txt:27 (find_package)


CMake Error at SpaceShipBP/lib/third-party/RapidJson/build/RapidJSONConfig.cmake:17 (get_target_property):
  get_target_property() called with non-existent target "RapidJSON".
Call Stack (most recent call first):
  CMakeLists.txt:27 (find_package)

I found that file RapidJSON-targets.cmake placed into build\CMakeFiles\Export\ee408f6834aa02d43e68aa01ab403628 but I don't know how to copy it from there to the ${CMAKE_CURRENT_LIST_DIR} aka "D:\Archive\Projects\Large\SpaceShipBP\SpaceShipBP\lib\third-party\RapidJson\build\RapidJSONConfig.cmake"

The commenting resolved the error as @serser prompted and the cmake config & generating were done, but maybe it is not the right solution.

Edit: Although cmake doesn't throw errors after the changes above, I cannot include any *.h file from RapidJSON as the same preprocessor doesn't see any rapidjson name.

Aeomanate avatar Apr 11 '24 19:04 Aeomanate

I also tried this approach that is working with SFML:

include(FetchContent)
FetchContent_Declare(RapidJSON
        GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
        GIT_TAG v1.1.0)
FetchContent_MakeAvailable(RapidJSON)

target_link_libraries(${PROJECT_NAME} PUBLIC RapidJSON)

install(TARGETS ${PROJECT_NAME})

There aren't any errors but I still can't use #include <rapidjson/...> in the code.

Aeomanate avatar Apr 11 '24 20:04 Aeomanate

Finally, I resolved the problem with auto usage RapidJSON by this article https://www.jibbow.com/posts/rapidjson-cmake/

Aeomanate avatar Apr 11 '24 22:04 Aeomanate

When I try to build valhalla with external rapidjson it supposes that rapidjson has INTERFACE_INCLUDE_DIRECTORIES but it doesn't have:

  if (RapidJSON_FOUND)
    get_target_property(rapidjson_include_dir rapidjson INTERFACE_INCLUDE_DIRECTORIES)

Maybe this interface should be implemented since several projects assume it.

Vedingrot avatar Jun 07 '24 18:06 Vedingrot