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")