Skip to content

Commit e890559

Browse files
authored
feature: support jsoncpp static library (#2528)
1 parent c9db379 commit e890559

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,19 @@ if(TARGET std::filesystem)
187187
endif()
188188
endif()
189189

190-
191190
# jsoncpp
192-
find_package(Jsoncpp REQUIRED)
193-
target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib)
191+
find_package(jsoncpp QUIET CONFIG)
192+
if (jsoncpp_FOUND)
193+
message(STATUS "jsoncpp found by config")
194+
if (USE_STATIC_LIBS_ONLY)
195+
target_link_libraries(${PROJECT_NAME} PUBLIC jsoncpp_static)
196+
else()
197+
target_link_libraries(${PROJECT_NAME} PUBLIC jsoncpp_lib)
198+
endif()
199+
else()
200+
find_package(Jsoncpp REQUIRED MODULE)
201+
target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib)
202+
endif()
194203
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS})
195204

196205
# yamlcpp

cmake/templates/DrogonConfig.cmake.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
include(CMakeFindDependencyMacro)
1313
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
1414

15-
find_dependency(Jsoncpp REQUIRED)
15+
find_package(jsoncpp QUIET CONFIG)
16+
if(NOT jsoncpp_FOUND)
17+
find_dependency(Jsoncpp MODULE REQUIRED)
18+
endif()
19+
1620
find_dependency(Trantor REQUIRED)
1721
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" AND NOT WIN32)
1822
find_dependency(UUID REQUIRED)

0 commit comments

Comments
 (0)