2022-09-21 07:55:05 +00:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
2023-02-16 10:44:01 +00:00
|
|
|
INCLUDE(CMakeDependentOption)
|
|
|
|
|
2023-02-27 06:10:36 +00:00
|
|
|
OPTION(VCPE_AGENT "Enable vCPE agent test application" OFF)
|
2023-03-13 09:03:02 +00:00
|
|
|
OPTION(VCPE_PPPOE "Enable vCPE work befof PPPoE mode" OFF)
|
2023-02-27 06:10:36 +00:00
|
|
|
OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF)
|
|
|
|
OPTION(USED_OPENDHCPDDNS "DHCP And DNS server for vCPE" OFF)
|
|
|
|
OPTION(USED_USER_VNI "Support pass user vni id from console command line" OFF)
|
|
|
|
OPTION(USED_JSON_VALIDATE "Support json protocol field validate" OFF)
|
|
|
|
OPTION(BUILD_TESTING "Enable tests" OFF)
|
2023-03-14 02:00:11 +00:00
|
|
|
# 数据库开关
|
|
|
|
OPTION(USED_REDIS "Add redis database support for vCPE" OFF)
|
|
|
|
OPTION(USED_MYSQL "Add mysql database support for vCPE" OFF)
|
|
|
|
OPTION(USED_SQLITE "Add sqlite3 database support for vCPE" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(USED_HTTP_SVR "Build-in http(s) server support" ON "USED_OPENDHCPD OR USED_OPENDHCPDDNS" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(USED_LWIP "PPPoE of LWIP support for vCPE" ON "VCPE_PPPOE" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(USED_ZMQ "ZeroMQ support for vCPE" ON "VCPE_PPPOE" OFF)
|
2023-02-27 06:10:36 +00:00
|
|
|
|
2023-02-02 02:58:49 +00:00
|
|
|
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/depend)
|
|
|
|
IF (BUILD_TESTING)
|
|
|
|
INCLUDE(doctest_framework)
|
|
|
|
ENDIF ()
|
|
|
|
INCLUDE(system_libs)
|
2022-05-10 02:59:51 +00:00
|
|
|
|
2023-01-11 09:53:51 +00:00
|
|
|
SET(VCPE_VERSION "1.0.1")
|
2022-12-23 06:04:51 +00:00
|
|
|
PROJECT(vCPE VERSION "${VCPE_VERSION}")
|
2022-11-28 09:57:57 +00:00
|
|
|
|
2022-09-19 01:53:11 +00:00
|
|
|
SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig")
|
2022-05-10 02:59:51 +00:00
|
|
|
SET(URI_HOME "${CMAKE_SOURCE_DIR}/libs")
|
|
|
|
|
2022-12-23 06:04:51 +00:00
|
|
|
SET(VERSION_GIT_TAG "")
|
|
|
|
SET(VERSION_GIT_HASH "")
|
|
|
|
SET(VERSION_GIT_HASH_SHORT "")
|
|
|
|
SET(VERSION_GIT_BRANCH "")
|
|
|
|
|
|
|
|
FIND_PACKAGE(Git QUIET)
|
|
|
|
IF (GIT_FOUND)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
|
|
|
OUTPUT_VARIABLE VERSION_GIT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD
|
|
|
|
OUTPUT_VARIABLE VERSION_GIT_HASH_SHORT
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
|
|
|
|
OUTPUT_VARIABLE VERSION_GIT_BRANCH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty=-dev
|
2022-12-23 07:08:30 +00:00
|
|
|
OUTPUT_VARIABLE VERSION_GIT_TAG
|
2022-12-23 06:04:51 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
ENDIF ()
|
2022-05-10 02:59:51 +00:00
|
|
|
|
2022-12-23 07:08:30 +00:00
|
|
|
IF ("${VERSION_GIT_TAG}" STREQUAL "")
|
2022-05-10 02:59:51 +00:00
|
|
|
STRING(TIMESTAMP COMPILE_TIME %Y-%m-%d_%H:%M:%S)
|
2022-12-23 06:04:51 +00:00
|
|
|
SET(VERSION_GIT_TAG ${COMPILE_TIME})
|
2022-12-02 02:51:51 +00:00
|
|
|
ELSE ()
|
2022-12-23 07:08:30 +00:00
|
|
|
SET(VERSION_GIT_TAG ${VERSION_GIT_TAG})
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-06-10 09:03:27 +00:00
|
|
|
|
2022-12-23 06:04:51 +00:00
|
|
|
CONFIGURE_FILE(prj_config.h.in prj_config.h)
|
|
|
|
|
2022-12-23 07:08:30 +00:00
|
|
|
MESSAGE("Git Tag: " ${VERSION_GIT_TAG})
|
2022-05-10 02:59:51 +00:00
|
|
|
|
2023-01-31 08:55:29 +00:00
|
|
|
# 判断依赖库是否存在
|
|
|
|
FIND_PACKAGE(PkgConfig)
|
|
|
|
|
|
|
|
SET(COMMON_LIBS "")
|
|
|
|
|
|
|
|
INCLUDE(./depend/third_libs.cmake)
|
|
|
|
|
2023-02-27 06:10:36 +00:00
|
|
|
IF (USED_JSON_VALIDATE)
|
|
|
|
LIST(APPEND COMMON_DEFINE "-DJSON_SCHEMA_ON")
|
2023-03-13 09:03:02 +00:00
|
|
|
ENDIF ()
|
2023-02-27 06:10:36 +00:00
|
|
|
|
2023-01-13 08:44:43 +00:00
|
|
|
IF (USED_USER_VNI)
|
2023-02-16 11:31:19 +00:00
|
|
|
LIST(APPEND COMMON_DEFINE "-DUSERVNI_ON")
|
2023-01-13 08:44:43 +00:00
|
|
|
MESSAGE("Select Option USED_USER_VNI")
|
|
|
|
ENDIF ()
|
|
|
|
|
2023-02-16 10:44:01 +00:00
|
|
|
IF (USED_HTTP_SVR)
|
|
|
|
LIST(APPEND COMMON_DEFINE "-DHTTPSERVER_ON")
|
|
|
|
MESSAGE("Select Option USED_HTTP_SVR")
|
|
|
|
ENDIF ()
|
|
|
|
|
2023-03-13 09:03:02 +00:00
|
|
|
IF (USED_ZMQ)
|
|
|
|
LIST(APPEND COMMON_DEFINE "-DZEROMQ_ON")
|
|
|
|
MESSAGE("Select Option USED_ZMQ")
|
|
|
|
ENDIF ()
|
|
|
|
|
|
|
|
IF (VCPE_PPPOE)
|
|
|
|
LIST(APPEND COMMON_DEFINE "-DPPPOE_ON")
|
|
|
|
MESSAGE("Select Option VCPE_PPPOE")
|
|
|
|
ENDIF ()
|
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_LWIP)
|
2022-11-16 02:36:28 +00:00
|
|
|
LIST(APPEND COMMON_DEFINE "-DLWIP_ON")
|
2023-01-13 08:44:43 +00:00
|
|
|
MESSAGE("Select Option USED_LWIP")
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-11-16 02:36:28 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_OPENDHCPD)
|
2022-11-16 02:36:28 +00:00
|
|
|
LIST(APPEND COMMON_DEFINE "-DOPENDHCPD_ON")
|
2023-01-13 08:44:43 +00:00
|
|
|
MESSAGE("Select Option USED_OPENDHCPD")
|
2023-01-28 02:20:27 +00:00
|
|
|
ADD_SUBDIRECTORY(srcs/opendhcp183)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-11-16 02:36:28 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_OPENDHCPDDNS)
|
2022-11-16 02:36:28 +00:00
|
|
|
LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON")
|
2023-01-13 08:44:43 +00:00
|
|
|
MESSAGE("Select Option USED_OPENDHCPDDNS")
|
|
|
|
ADD_SUBDIRECTORY(srcs/dual_server)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-11-16 02:36:28 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (VCPE_AGENT)
|
2022-09-19 01:53:11 +00:00
|
|
|
MESSAGE("Select Option VCPE_AGENT")
|
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_SQLITE)
|
2022-11-28 09:57:57 +00:00
|
|
|
MESSAGE("Select Option USED_SQLITE")
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-11-28 09:57:57 +00:00
|
|
|
|
2022-12-02 02:51:51 +00:00
|
|
|
IF (USED_LWIP OR VCPE_AGENT)
|
2022-09-27 09:43:16 +00:00
|
|
|
ADD_SUBDIRECTORY(srcs/lwip)
|
2022-12-02 02:51:51 +00:00
|
|
|
ENDIF ()
|
2022-11-07 06:21:24 +00:00
|
|
|
|
2022-11-28 09:57:57 +00:00
|
|
|
ADD_SUBDIRECTORY(srcs)
|
|
|
|
ADD_SUBDIRECTORY(srcs/libs)
|
2023-02-01 02:10:49 +00:00
|
|
|
|
|
|
|
IF (BUILD_TESTING)
|
2023-02-02 02:58:49 +00:00
|
|
|
ADD_SUBDIRECTORY(unit_test)
|
2023-02-01 02:10:49 +00:00
|
|
|
ENDIF ()
|