89 lines
3.2 KiB
CMake
89 lines
3.2 KiB
CMake
SET(PROJECT_TARGET vcpe_main)
|
|
|
|
IF (VCPE_AGENT)
|
|
SET(PROJECT_TARGET_AGENT vcpe_agent)
|
|
ENDIF ()
|
|
|
|
PROJECT(${PROJECT_TARGET})
|
|
|
|
|
|
|
|
PKG_SEARCH_MODULE(LIBCURL QUIET libcurl)
|
|
PKG_SEARCH_MODULE(LIBSSL QUIET libssl)
|
|
PKG_SEARCH_MODULE(LIBCRYPTO QUIET libcrypto)
|
|
PKG_SEARCH_MODULE(LIBZMQ QUIET libzmq)
|
|
|
|
IF ((NOT LIBZMQ_FOUND) OR (NOT LIBCRYPTO_FOUND) OR (NOT LIBSSL_FOUND) OR (NOT LIBCURL_FOUND))
|
|
LINUX_INSTALL_SYSTEM_PACKAGE()
|
|
ENDIF ()
|
|
|
|
LIST(APPEND COMMON_LIBS "${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}")
|
|
LIST(APPEND COMMON_LIBS "${LIBZMQ_LDFLAGS}")
|
|
LIST(APPEND COMMON_LIBS "-lm -lpthread")
|
|
|
|
ADD_DEFINITIONS(${COMMON_DEFINE})
|
|
|
|
INCLUDE_DIRECTORIES(include ./ ./include ./libs/include ./lwip/src/include ./lwip/src/arch_linux/include
|
|
./httpserver/include ${COMMON_INCLUDE})
|
|
|
|
SET(CMAKE_C_STANDARD 99)
|
|
|
|
FILE(GLOB VCPE_HEADS include/*.h include/uthash/*.h include/s2j/*.h
|
|
./httpserver/include/*.h ./httpserver/src/haywire/*.h ./httpserver/src/haywire/configuration/*.h)
|
|
|
|
IF (USED_LWIP)
|
|
AUX_SOURCE_DIRECTORY(pppoe VCPE_SRC)
|
|
AUX_SOURCE_DIRECTORY(user VCPE_SRC)
|
|
ENDIF ()
|
|
|
|
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)
|
|
ENDIF ()
|
|
|
|
IF (USED_OPENDHCPD)
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} opendhcpd)
|
|
ENDIF ()
|
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} common)
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} ${COMMON_LIBS})
|
|
TARGET_INCLUDE_DIRECTORIES(${PROJECT_TARGET} PUBLIC ${PROJECT_BINARY_DIR}/../)
|
|
|
|
IF (VCPE_AGENT)
|
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET_AGENT} common ${COMMON_LIBS})
|
|
ENDIF ()
|
|
|
|
# 自动复制配置文件到运行路径
|
|
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET}
|
|
POST_BUILD
|
|
COMMENT "!!!!!! Notice: Automatic upgreade configuration files after build project."
|
|
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/zlog.conf" "${CMAKE_CURRENT_BINARY_DIR}/config/"
|
|
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/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 DESTINATION ./)
|
|
INSTALL(DIRECTORY DESTINATION ./log)
|
|
|
|
SET(CPACK_GENERATOR "TGZ")
|
|
IF ("${VERSION_GIT_HASH_SHORT}" STREQUAL "")
|
|
STRING(REGEX REPLACE "[_:-]" "" VER_STR "${VERSION_GIT_TAG}")
|
|
SET(CPACK_PACKAGE_FILE_NAME "vCPE-${VCPE_VERSION}-linux-amd64_${VER_STR}")
|
|
ELSE ()
|
|
SET(CPACK_PACKAGE_FILE_NAME "vCPE-${VCPE_VERSION}-linux-amd64_${VERSION_GIT_HASH_SHORT}")
|
|
ENDIF ()
|
|
|
|
INCLUDE(CPack) |