vcpe/srcs/CMakeLists.txt

43 lines
1.6 KiB
CMake

SET(PROJECT_TARGET vcpe_main)
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)
SET(COMMON_LIBS ${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS})
SET(COMMON_LIBS ${COMMON_LIBS} "-ldl -lpthread -lzlog -lm -luv -lcjson -lzmq -luuid -lconfig -ljemalloc")
INCLUDE_DIRECTORIES(include ./ ./include ./libs/include ./lwip/src/include ./lwip/src/arch_linux/include ${COMMON_INCLUDE})
SET(CMAKE_C_STANDARD 99)
FILE(GLOB VCPE_HEADS include/*.h include/uthash/*.h include/s2j/*.h)
AUX_SOURCE_DIRECTORY(pppoe VCPE_SRC)
AUX_SOURCE_DIRECTORY(user VCPE_SRC)
ADD_EXECUTABLE(${PROJECT_TARGET} ${VCPE_SRC} ${VCPE_HEADS} vcpe_main.c)
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} common ${COMMON_LIBS})
# 自动复制配置文件到运行路径
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
make_directory "${CMAKE_CURRENT_BINARY_DIR}/config/"
COMMAND ${CMAKE_COMMAND} -E
make_directory "${CMAKE_CURRENT_BINARY_DIR}/log/"
COMMAND ${CMAKE_COMMAND} -E
copy_if_different "${PROJECT_SOURCE_DIR}/libs/config/agent.cfg" "${CMAKE_CURRENT_BINARY_DIR}/config/"
COMMAND ${CMAKE_COMMAND} -E
copy_if_different "${PROJECT_SOURCE_DIR}/libs/config/zlog.conf" "${CMAKE_CURRENT_BINARY_DIR}/config/"
COMMAND ${CMAKE_COMMAND} -E
copy_if_different "${PROJECT_SOURCE_DIR}/libs/config/banner.txt" "${CMAKE_CURRENT_BINARY_DIR}/config/")