Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When including rapidjson for LMDeploy, I encountered cmake errors #2271

Open
serser opened this issue Apr 1, 2024 · 4 comments
Open

When including rapidjson for LMDeploy, I encountered cmake errors #2271

serser opened this issue Apr 1, 2024 · 4 comments

Comments

@serser
Copy link

serser commented Apr 1, 2024

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

@Aeomanate
Copy link

Aeomanate commented Apr 11, 2024

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
Copy link

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
Copy link

Aeomanate commented Apr 11, 2024

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

@Vedingrot
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants