drogonframework / drogonframework/drogon
Jsoncpp does not link to Drogon
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 15
Description
Using `FetchContent`, Drogon isn't building due to an issue finding Jsoncpp. This is a bug as Jsoncpp should be imported similar to Trantor, as a submodule. It seems to be required to add Jsoncpp yourself like described below.
By itself in CMakeLists.txt, Jsoncpp builds and runs fine:
```
FetchContent_Declare(
jsoncpp
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp
GIT_TAG 1.9.4
)
...
FetchContent_MakeAvailable(jsoncpp)
...
target_link_libraries(${PROJECT_NAME} PRIVATE jsoncpp_lib)
```
However Drogon does not seem to find it, specifically in `FindJsoncpp.cmake` with error:
```
CMake Error at .../cmake-3.30.4/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
Could NOT find Jsoncpp (missing: JSONCPP_INCLUDE_DIRS JSONCPP_LIBRARIES)
Call Stack (most recent call first):
.../cmake-3.30.4/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
build/_deps/drogon-src/cmake_modules/FindJsoncpp.cmake:36 (find_package_handle_standard_args)
build/_deps/drogon-src/CMakeLists.txt:189 (find_package)
```
The include directory can be manually fixed with `set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_BINARY_DIR}/_deps/jsoncpp-src/include")` however I cannot find a way to fix `find_library(JSONCPP_LIBRARIES ...)`. The `find_library` method is looking for a *.a or *.so file I believe which does not exist in any of the built Jsoncpp directories. Is there a way to download Jsoncpp using `FetchContent`? It seems the only solution I have found, which I haven't tested yet, is to manually download Jsoncpp.
**Desktop (please complete the following information):**
- OS: Ubuntu 18.04 (WSL2)
CMakeLists file:
```
cmake_minimum_required(VERSION 3.30.4)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(tst VERSION 0.1)
file(MAKE_DIRECTORY /build)
include(FetchContent)
include(FindPkgConfig)
FetchContent_Declare(
jsoncpp
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp
GIT_TAG 1.9.4
)
FetchContent_Declare(
drogon
GIT_REPOSITORY https://github.com/drogonframework/drogon.git
GIT_TAG v1.9.8
)
FetchContent_MakeAvailable(jsoncpp)
FetchContent_MakeAvailable(drogon)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE drogon jsoncpp_lib)
```
Contributor guide
Assessment
This issue has not been assessed yet.