2022-05-10 06:43:27 +00:00
|
|
|
SET(PROJECT_TARGET vcpe_main)
|
2022-09-19 01:53:11 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (VCPE_AGENT)
|
2022-09-19 01:53:11 +00:00
|
|
|
SET(PROJECT_TARGET_AGENT vcpe_agent)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-05-10 06:43:27 +00:00
|
|
|
|
|
|
|
PROJECT(${PROJECT_TARGET})
|
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
INCLUDE(ExternalProject)
|
2022-05-10 06:43:27 +00:00
|
|
|
|
|
|
|
# 判断依赖库是否存在
|
|
|
|
FIND_PACKAGE(PkgConfig)
|
|
|
|
|
2022-10-28 08:46:55 +00:00
|
|
|
PKG_SEARCH_MODULE(LIBCURL REQUIRED libcurl)
|
|
|
|
PKG_SEARCH_MODULE(LIBSSL REQUIRED libssl)
|
|
|
|
PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto)
|
2022-12-07 08:01:07 +00:00
|
|
|
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 "-lm -lpthread")
|
2022-05-10 06:43:27 +00:00
|
|
|
|
2022-11-16 02:36:28 +00:00
|
|
|
ADD_DEFINITIONS(${COMMON_DEFINE})
|
|
|
|
|
2022-11-07 06:21:24 +00:00
|
|
|
INCLUDE_DIRECTORIES(include ./ ./include ./libs/include ./lwip/src/include ./lwip/src/arch_linux/include
|
2022-12-02 02:51:51 +00:00
|
|
|
./httpserver/include ${COMMON_INCLUDE})
|
2022-05-10 06:43:27 +00:00
|
|
|
|
|
|
|
SET(CMAKE_C_STANDARD 99)
|
|
|
|
|
2022-11-07 06:21:24 +00:00
|
|
|
FILE(GLOB VCPE_HEADS include/*.h include/uthash/*.h include/s2j/*.h
|
2022-12-02 02:51:51 +00:00
|
|
|
./httpserver/include/*.h ./httpserver/src/haywire/*.h ./httpserver/src/haywire/configuration/*.h)
|
2022-05-10 06:43:27 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_LWIP)
|
2022-09-19 01:53:11 +00:00
|
|
|
AUX_SOURCE_DIRECTORY(pppoe VCPE_SRC)
|
|
|
|
AUX_SOURCE_DIRECTORY(user VCPE_SRC)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-10-28 07:37:01 +00:00
|
|
|
|
2022-05-10 06:43:27 +00:00
|
|
|
ADD_EXECUTABLE(${PROJECT_TARGET} ${VCPE_SRC} ${VCPE_HEADS} vcpe_main.c)
|
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (VCPE_AGENT)
|
2022-09-19 01:53:11 +00:00
|
|
|
ADD_EXECUTABLE(${PROJECT_TARGET_AGENT} ${VCPE_HEADS} vcpe_agent.c)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-09-19 01:53:11 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_LWIP)
|
2022-09-19 01:53:11 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} lwip_linux)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-09-19 01:53:11 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_OPENDHCPDDNS)
|
2022-10-28 07:37:01 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} dualserverd)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-09-19 01:53:11 +00:00
|
|
|
|
2022-12-15 08:26:39 +00:00
|
|
|
IF (USED_OPENDHCPD)
|
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} opendhcpd)
|
2022-12-23 06:04:51 +00:00
|
|
|
ENDIF ()
|
2022-12-15 08:26:39 +00:00
|
|
|
|
2022-09-22 08:41:19 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} common)
|
2022-09-19 01:53:11 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} ${COMMON_LIBS})
|
2022-12-14 02:16:10 +00:00
|
|
|
TARGET_INCLUDE_DIRECTORIES(${PROJECT_TARGET} PUBLIC ${PROJECT_BINARY_DIR}/../)
|
2022-09-19 01:53:11 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (VCPE_AGENT)
|
2022-09-19 01:53:11 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET_AGENT} common ${COMMON_LIBS})
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-05-10 06:43:27 +00:00
|
|
|
|
|
|
|
# 自动复制配置文件到运行路径
|
|
|
|
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET}
|
2022-12-02 02:51:51 +00:00
|
|
|
POST_BUILD
|
2022-12-05 10:12:40 +00:00
|
|
|
COMMENT "!!!!!! Notice: Automatic upgreade configuration files after build project."
|
2022-12-23 06:04:51 +00:00
|
|
|
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/vcpe.cfg" "${CMAKE_CURRENT_BINARY_DIR}/config/"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/../config/zlog.conf" "${CMAKE_CURRENT_BINARY_DIR}/config/"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/../config/banner.txt" "${CMAKE_CURRENT_BINARY_DIR}/config/")
|
|
|
|
|
|
|
|
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install/")
|
|
|
|
install(FILES ../config/vcpe.cfg ../config/vcpe.service ../config/banner.txt ../config/zlog.conf
|
|
|
|
DESTINATION config)
|
|
|
|
INSTALL(TARGETS ${PROJECT_TARGET}
|
|
|
|
RUNTIME PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
RUNTIME DESTINATION bin)
|
|
|
|
|
|
|
|
SET(CPACK_GENERATOR "TGZ")
|
2022-12-23 07:08:30 +00:00
|
|
|
IF ("${VERSION_GIT_HASH_SHORT}" STREQUAL "")
|
|
|
|
SET(CPACK_PACKAGE_FILE_NAME "vCPE-${VCPE_VERSION}-linux-amd64_${VERSION_GIT_TAG}")
|
|
|
|
ELSE ()
|
|
|
|
SET(CPACK_PACKAGE_FILE_NAME "vCPE-${VCPE_VERSION}-linux-amd64_${VERSION_GIT_HASH_SHORT}")
|
|
|
|
ENDIF ()
|
|
|
|
|
2022-12-23 06:04:51 +00:00
|
|
|
INCLUDE(CPack)
|