diff --git a/CMakeLists.txt b/CMakeLists.txt index a53f47c..875ca09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} - $<$>:${JSON_INCLUDE_DIR}> # 仅在非 macOS 系统添加 ) target_link_libraries(${PROJECT_NAME}_lib