From c13bb5d3cd47c9ad5cf2a7ca5c80dab0061db4f3 Mon Sep 17 00:00:00 2001 From: huangxin Date: Tue, 31 Jan 2023 16:55:29 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E4=BF=AE=E6=AD=A3=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E5=BC=80=E6=BA=90=E5=BA=93=E6=97=B6=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E5=A4=B4=E6=96=87=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 7 +++++++ depend/third_libs.cmake | 3 +++ srcs/CMakeLists.txt | 7 +------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26acf77..73253a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,13 @@ CONFIGURE_FILE(prj_config.h.in prj_config.h) MESSAGE("Git Tag: " ${VERSION_GIT_TAG}) +# 判断依赖库是否存在 +FIND_PACKAGE(PkgConfig) + +SET(COMMON_LIBS "") + +INCLUDE(./depend/third_libs.cmake) + IF (USED_USER_VNI) LIST(APPEND COMMON_DEFINE "-DUSER_VNI") MESSAGE("Select Option USED_USER_VNI") diff --git a/depend/third_libs.cmake b/depend/third_libs.cmake index 40cef7a..43f01ab 100644 --- a/depend/third_libs.cmake +++ b/depend/third_libs.cmake @@ -42,6 +42,7 @@ IF (NOT LIBUV_FOUND) FETCHCONTENT_POPULATE(libuv) ADD_SUBDIRECTORY(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR}) ENDIF () + INCLUDE_DIRECTORIES(${libuv_SOURCE_DIR}/include) LIST(APPEND COMMON_LIBS "uv_a") ELSE () MESSAGE(STATUS "libuv found ${LIBUV_VERSION} at ${LIBUV_LIBRARY_DIRS}") @@ -55,6 +56,7 @@ IF (NOT LIBCONFIG_FOUND) FETCHCONTENT_POPULATE(libconfig) ADD_SUBDIRECTORY(${libconfig_SOURCE_DIR} ${libconfig_BINARY_DIR}) ENDIF () + INCLUDE_DIRECTORIES(${libconfig_SOURCE_DIR}/lib) LIST(APPEND COMMON_LIBS "config") ELSE () MESSAGE(STATUS "libconfig found ${LIBCONFIG_VERSION} at ${LIBCONFIG_LIBRARY_DIRS}") @@ -68,6 +70,7 @@ IF (LIBZLOG STREQUAL "LIBZLOG-NOTFOUND") FETCHCONTENT_POPULATE(zlog) ADD_SUBDIRECTORY(${zlog_SOURCE_DIR} ${zlog_BINARY_DIR}) ENDIF () + INCLUDE_DIRECTORIES(${zlog_SOURCE_DIR}/src) LIST(APPEND COMMON_LIBS "zlog") ELSE () MESSAGE(STATUS "zlog found of ${LIBZLOG}") diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index 9ac99bb..ae82366 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -6,8 +6,7 @@ ENDIF () PROJECT(${PROJECT_TARGET}) -# 判断依赖库是否存在 -FIND_PACKAGE(PkgConfig) + PKG_SEARCH_MODULE(LIBCURL QUIET libcurl) PKG_SEARCH_MODULE(LIBSSL QUIET libssl) @@ -18,10 +17,6 @@ IF ((NOT LIBZMQ_FOUND) OR (NOT LIBCRYPTO_FOUND) OR (NOT LIBSSL_FOUND) OR (NOT LI LINUX_INSTALL_SYSTEM_PACKAGE() ENDIF () -SET(COMMON_LIBS "") - -INCLUDE(../depend/third_libs.cmake) - LIST(APPEND COMMON_LIBS "${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}") LIST(APPEND COMMON_LIBS "${LIBZMQ_LDFLAGS}") LIST(APPEND COMMON_LIBS "-lm -lpthread")