vcpe/srcs/CMakeLists.txt

84 lines
2.5 KiB
CMake
Raw Normal View History

2022-05-10 06:43:27 +00:00
SET(PROJECT_TARGET vcpe_main)
if (VCPE_AGENT)
SET(PROJECT_TARGET_AGENT vcpe_agent)
endif ()
2022-05-10 06:43:27 +00:00
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)
LIST(APPEND COMMON_LIBS "${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}")
LIST(APPEND COMMON_LIBS "-ldl -lpthread -lzlog -lm -luv -lzmq -luuid -lconfig")
2022-05-10 06:43:27 +00:00
LIST(APPEND COMMON_LIBS "-lpthread")
2022-05-10 06:43:27 +00:00
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)
if (USED_LWIP)
AUX_SOURCE_DIRECTORY(pppoe VCPE_SRC)
AUX_SOURCE_DIRECTORY(user VCPE_SRC)
endif ()
if (USED_LWIP)
ADD_DEFINITIONS(-DLWIP_ON)
endif ()
if (USED_OPENDHCPD)
ADD_DEFINITIONS(-DOPENDHCPD_ON)
endif ()
2022-05-10 06:43:27 +00:00
if (USED_OPENDHCPDDNS)
ADD_DEFINITIONS(-DOPENDHCPDDNS_ON)
endif ()
2022-05-10 06:43:27 +00:00
ADD_EXECUTABLE(${PROJECT_TARGET} ${VCPE_SRC} ${VCPE_HEADS} vcpe_main.c)
if (VCPE_AGENT)
ADD_EXECUTABLE(${PROJECT_TARGET_AGENT} ${VCPE_HEADS} vcpe_agent.c)
endif ()
if (USED_LWIP)
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} lwip_linux)
endif ()
if (USED_OPENDHCPDDNS)
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} dualserverd)
else ()
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} opendhcpd)
endif ()
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} common)
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} ${COMMON_LIBS})
if (VCPE_AGENT)
TARGET_LINK_LIBRARIES(${PROJECT_TARGET_AGENT} common ${COMMON_LIBS})
endif ()
2022-05-10 06:43:27 +00:00
# 自动复制配置文件到运行路径
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}/../config/opendhcp.ini" "${CMAKE_CURRENT_BINARY_DIR}/config/"
COMMAND ${CMAKE_COMMAND} -E
copy_if_different "${PROJECT_SOURCE_DIR}/../config/agent.cfg" "${CMAKE_CURRENT_BINARY_DIR}/config/"
2022-05-10 06:43:27 +00:00
COMMAND ${CMAKE_COMMAND} -E
copy_if_different "${PROJECT_SOURCE_DIR}/../config/zlog.conf" "${CMAKE_CURRENT_BINARY_DIR}/config/"
2022-05-10 06:43:27 +00:00
COMMAND ${CMAKE_COMMAND} -E
copy_if_different "${PROJECT_SOURCE_DIR}/../config/banner.txt" "${CMAKE_CURRENT_BINARY_DIR}/config/")