修改 CMakeLists.txt

This commit is contained in:
Tian jianyong 2024-12-20 14:09:06 +08:00
parent cba55fcbd9
commit 15054a3f0c

View File

@ -41,15 +41,11 @@ find_package(CURL REQUIRED)
if(APPLE)
# macOS 使 Homebrew nlohmann_json
find_package(nlohmann_json 3.11.3 REQUIRED)
set(JSON_TARGET nlohmann_json::nlohmann_json)
else()
# CentOS 使 json-devel
set(JSON_INCLUDE_DIR "/usr/include/json")
if(NOT EXISTS ${JSON_INCLUDE_DIR})
message(FATAL_ERROR "json-devel not found. Please install: yum install -y json-devel")
endif()
set(JSON_TARGET "")
# CentOS 使 nlohmann_json
find_package(nlohmann_json REQUIRED)
endif()
set(JSON_TARGET nlohmann_json::nlohmann_json)
#
set(LIB_SOURCES
@ -78,7 +74,6 @@ target_include_directories(${PROJECT_NAME}_lib
${CMAKE_CURRENT_SOURCE_DIR}/src
${Boost_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
$<$<NOT:$<PLATFORM_ID:Darwin>>:${JSON_INCLUDE_DIR}> # macOS
)
target_link_libraries(${PROJECT_NAME}_lib