OCT 1. 增加系统依赖库检查功能
This commit is contained in:
parent
bf84f84596
commit
ffe78c9719
|
@ -1,4 +1,5 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
||||
INCLUDE(depend/system_libs.cmake)
|
||||
|
||||
SET(VCPE_VERSION "1.0.1")
|
||||
PROJECT(vCPE VERSION "${VCPE_VERSION}")
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
FUNCTION(LINUX_INSTALL_SYSTEM_PACKAGE)
|
||||
SET(OS_RELEASE_FILE "/etc/os-release")
|
||||
SET(OS_DISTRIB_NAME "")
|
||||
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND EXISTS ${OS_RELEASE_FILE})
|
||||
FILE(STRINGS ${OS_RELEASE_FILE} OS_RELEASE_NAME LIMIT_COUNT 1)
|
||||
STRING(FIND ${OS_RELEASE_NAME} "CentOS" SUB_OUT)
|
||||
IF (${SUB_OUT} MATCHES "6")
|
||||
SET(OS_DISTRIB_NAME "CentOS")
|
||||
ELSE ()
|
||||
STRING(FIND ${OS_RELEASE_NAME} "Ubuntu" SUB_OUT)
|
||||
|
||||
IF (${SUB_OUT} MATCHES "6")
|
||||
SET(OS_DISTRIB_NAME "Ubuntu")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
MESSAGE("Run this command to install system(${OS_DISTRIB_NAME}) dependencies libraries:")
|
||||
IF (${OS_DISTRIB_NAME} MATCHES "CentOS")
|
||||
MESSAGE(ERROR "$sudo yum -y install libcurl-devel czmq-devel openssl-devel uuid-devel")
|
||||
ELSEIF (${OS_DISTRIB_NAME} MATCHES "Ubuntu")
|
||||
MESSAGE(ERROR "$sudo -S apt -y install libcurl4-openssl-dev libczmq-dev libssl-dev uuid-dev")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDFUNCTION(LINUX_INSTALL_SYSTEM_PACKAGE)
|
|
@ -6,22 +6,26 @@ ENDIF ()
|
|||
|
||||
PROJECT(${PROJECT_TARGET})
|
||||
|
||||
INCLUDE(ExternalProject)
|
||||
|
||||
# 判断依赖库是否存在
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
|
||||
PKG_SEARCH_MODULE(LIBCURL REQUIRED libcurl)
|
||||
PKG_SEARCH_MODULE(LIBSSL REQUIRED libssl)
|
||||
PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto)
|
||||
PKG_SEARCH_MODULE(LIBCURL QUIET libcurl)
|
||||
PKG_SEARCH_MODULE(LIBSSL QUIET libssl)
|
||||
PKG_SEARCH_MODULE(LIBCRYPTO QUIET libcrypto)
|
||||
PKG_SEARCH_MODULE(LIBZMQ QUIET libzmq)
|
||||
FIND_LIBRARY(LIBUUID uuid QUIET)
|
||||
|
||||
IF ((NOT LIBZMQ_FOUND) OR (NOT LIBCRYPTO_FOUND) OR (NOT LIBSSL_FOUND) OR (NOT LIBCURL_FOUND)
|
||||
OR (${LIBUUID} MATCHES "LIBUUID-NOTFOUND"))
|
||||
LINUX_INSTALL_SYSTEM_PACKAGE()
|
||||
ENDIF ()
|
||||
|
||||
PKG_SEARCH_MODULE(LIBUV REQUIRED libuv)
|
||||
PKG_SEARCH_MODULE(LIBCONFIG REQUIRED libconfig)
|
||||
PKG_SEARCH_MODULE(LIBZMQ REQUIRED libzmq)
|
||||
FIND_LIBRARY(LIBZLOG zlog REQUIRED)
|
||||
FIND_LIBRARY(LIBUUID uuid REQUIRED)
|
||||
|
||||
LIST(APPEND COMMON_LIBS "${LIBUV_LDFLAGS} ${LIBCONFIG_LDFLAGS} ${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}")
|
||||
LIST(APPEND COMMON_LIBS "${LIBZMQ_LDFLAGS} ${LIBZLOG} ${LIBUUID}")
|
||||
LIST(APPEND COMMON_LIBS "${LIBUV_LDFLAGS} ${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}")
|
||||
LIST(APPEND COMMON_LIBS "${LIBCONFIG_LDFLAGS} ${LIBZMQ_LDFLAGS} ${LIBZLOG} ${LIBUUID}")
|
||||
LIST(APPEND COMMON_LIBS "-lm -lpthread")
|
||||
|
||||
ADD_DEFINITIONS(${COMMON_DEFINE})
|
||||
|
|
Loading…
Reference in New Issue