OCT 1. 更新CMake配置文件
This commit is contained in:
parent
d1673236fb
commit
2c149cdb91
|
@ -12,60 +12,59 @@ OPTION(USED_REDIS "Add redis database support for vCPE" OFF)
|
||||||
OPTION(USED_MYSQL "Add mysql 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)
|
OPTION(USED_SQLITE "Add sqlite3 database support for vCPE" OFF)
|
||||||
|
|
||||||
|
|
||||||
SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig")
|
SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig")
|
||||||
SET(URI_HOME "${CMAKE_SOURCE_DIR}/libs")
|
SET(URI_HOME "${CMAKE_SOURCE_DIR}/libs")
|
||||||
|
|
||||||
EXECUTE_PROCESS(COMMAND git describe --tags --always --dirty=-dev
|
EXECUTE_PROCESS(COMMAND git describe --tags --always --dirty=-dev
|
||||||
OUTPUT_VARIABLE GIT_TAG)
|
OUTPUT_VARIABLE GIT_TAG)
|
||||||
|
|
||||||
if ("${GIT_TAG}" STREQUAL "")
|
IF ("${GIT_TAG}" STREQUAL "")
|
||||||
STRING(TIMESTAMP COMPILE_TIME %Y-%m-%d_%H:%M:%S)
|
STRING(TIMESTAMP COMPILE_TIME %Y-%m-%d_%H:%M:%S)
|
||||||
SET(GIT_VERSION ${COMPILE_TIME})
|
SET(GIT_VERSION ${COMPILE_TIME})
|
||||||
else ()
|
ELSE ()
|
||||||
STRING(REGEX REPLACE "\n$" "" GIT_TAG ${GIT_TAG})
|
STRING(REGEX REPLACE "\n$" "" GIT_TAG ${GIT_TAG})
|
||||||
SET(GIT_VERSION ${GIT_TAG})
|
SET(GIT_VERSION ${GIT_TAG})
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
MESSAGE("Version: " ${GIT_VERSION})
|
MESSAGE("Version: " ${GIT_VERSION})
|
||||||
|
|
||||||
if (USED_LWIP)
|
IF (USED_LWIP)
|
||||||
LIST(APPEND COMMON_DEFINE "-DLWIP_ON")
|
LIST(APPEND COMMON_DEFINE "-DLWIP_ON")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_OPENDHCPD)
|
IF (USED_OPENDHCPD)
|
||||||
LIST(APPEND COMMON_DEFINE "-DOPENDHCPD_ON")
|
LIST(APPEND COMMON_DEFINE "-DOPENDHCPD_ON")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_OPENDHCPDDNS)
|
IF (USED_OPENDHCPDDNS)
|
||||||
LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON")
|
LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (VCPE_AGENT)
|
IF (VCPE_AGENT)
|
||||||
MESSAGE("Select Option VCPE_AGENT")
|
MESSAGE("Select Option VCPE_AGENT")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_LWIP)
|
IF (USED_LWIP)
|
||||||
MESSAGE("Select Option USED_LWIP")
|
MESSAGE("Select Option USED_LWIP")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_SQLITE)
|
IF (USED_SQLITE)
|
||||||
MESSAGE("Select Option USED_SQLITE")
|
MESSAGE("Select Option USED_SQLITE")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_OPENDHCPD)
|
IF (USED_OPENDHCPD)
|
||||||
MESSAGE("Select Option USED_OPENDHCPD")
|
MESSAGE("Select Option USED_OPENDHCPD")
|
||||||
ADD_SUBDIRECTORY(srcs/open_dhcp)
|
ADD_SUBDIRECTORY(srcs/open_dhcp)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_OPENDHCPDDNS)
|
IF (USED_OPENDHCPDDNS)
|
||||||
MESSAGE("Select Option USED_OPENDHCPDDNS")
|
MESSAGE("Select Option USED_OPENDHCPDDNS")
|
||||||
ADD_SUBDIRECTORY(srcs/dual_server)
|
ADD_SUBDIRECTORY(srcs/dual_server)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_LWIP OR VCPE_AGENT)
|
IF (USED_LWIP OR VCPE_AGENT)
|
||||||
ADD_SUBDIRECTORY(srcs/lwip)
|
ADD_SUBDIRECTORY(srcs/lwip)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(srcs)
|
ADD_SUBDIRECTORY(srcs)
|
||||||
ADD_SUBDIRECTORY(srcs/libs)
|
ADD_SUBDIRECTORY(srcs/libs)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
SET(PROJECT_TARGET vcpe_main)
|
SET(PROJECT_TARGET vcpe_main)
|
||||||
|
|
||||||
if (VCPE_AGENT)
|
IF (VCPE_AGENT)
|
||||||
SET(PROJECT_TARGET_AGENT vcpe_agent)
|
SET(PROJECT_TARGET_AGENT vcpe_agent)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
PROJECT(${PROJECT_TARGET})
|
PROJECT(${PROJECT_TARGET})
|
||||||
|
|
||||||
include(ExternalProject)
|
INCLUDE(ExternalProject)
|
||||||
|
|
||||||
# 判断依赖库是否存在
|
# 判断依赖库是否存在
|
||||||
FIND_PACKAGE(PkgConfig)
|
FIND_PACKAGE(PkgConfig)
|
||||||
|
@ -29,35 +29,33 @@ SET(CMAKE_C_STANDARD 99)
|
||||||
FILE(GLOB VCPE_HEADS include/*.h include/uthash/*.h include/s2j/*.h
|
FILE(GLOB VCPE_HEADS include/*.h include/uthash/*.h include/s2j/*.h
|
||||||
./httpserver/include/*.h ./httpserver/src/haywire/*.h ./httpserver/src/haywire/configuration/*.h)
|
./httpserver/include/*.h ./httpserver/src/haywire/*.h ./httpserver/src/haywire/configuration/*.h)
|
||||||
|
|
||||||
if (USED_LWIP)
|
IF (USED_LWIP)
|
||||||
AUX_SOURCE_DIRECTORY(pppoe VCPE_SRC)
|
AUX_SOURCE_DIRECTORY(pppoe VCPE_SRC)
|
||||||
AUX_SOURCE_DIRECTORY(user VCPE_SRC)
|
AUX_SOURCE_DIRECTORY(user VCPE_SRC)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
|
|
||||||
ADD_EXECUTABLE(${PROJECT_TARGET} ${VCPE_SRC} ${VCPE_HEADS} vcpe_main.c)
|
ADD_EXECUTABLE(${PROJECT_TARGET} ${VCPE_SRC} ${VCPE_HEADS} vcpe_main.c)
|
||||||
|
|
||||||
if (VCPE_AGENT)
|
IF (VCPE_AGENT)
|
||||||
ADD_EXECUTABLE(${PROJECT_TARGET_AGENT} ${VCPE_HEADS} vcpe_agent.c)
|
ADD_EXECUTABLE(${PROJECT_TARGET_AGENT} ${VCPE_HEADS} vcpe_agent.c)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_LWIP)
|
IF (USED_LWIP)
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} lwip_linux)
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} lwip_linux)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_OPENDHCPDDNS)
|
IF (USED_OPENDHCPDDNS)
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} dualserverd)
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} dualserverd)
|
||||||
else ()
|
ELSE ()
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} opendhcpd)
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} opendhcpd)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} common)
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} common)
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} ${COMMON_LIBS})
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET} ${COMMON_LIBS})
|
||||||
|
|
||||||
|
IF (VCPE_AGENT)
|
||||||
if (VCPE_AGENT)
|
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_TARGET_AGENT} common ${COMMON_LIBS})
|
TARGET_LINK_LIBRARIES(${PROJECT_TARGET_AGENT} common ${COMMON_LIBS})
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
# 自动复制配置文件到运行路径
|
# 自动复制配置文件到运行路径
|
||||||
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET}
|
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET}
|
||||||
|
|
|
@ -3,26 +3,26 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# Haywire
|
# Haywire
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
project(haywire C)
|
PROJECT(haywire C)
|
||||||
#set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
#set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
||||||
|
|
||||||
add_definitions(-std=gnu99)
|
ADD_DEFINITIONS(-std=gnu99)
|
||||||
#add_definitions(-mavx)
|
#add_definitions(-mavx)
|
||||||
add_definitions(-msse4.1)
|
ADD_DEFINITIONS(-msse4.1)
|
||||||
add_definitions(-pedantic)
|
ADD_DEFINITIONS(-pedantic)
|
||||||
add_definitions(-O3)
|
ADD_DEFINITIONS(-O3)
|
||||||
add_definitions(-Wall)
|
ADD_DEFINITIONS(-Wall)
|
||||||
add_definitions(-Wextra)
|
ADD_DEFINITIONS(-Wextra)
|
||||||
add_definitions(-Wcast-align)
|
ADD_DEFINITIONS(-Wcast-align)
|
||||||
add_definitions(-w)
|
ADD_DEFINITIONS(-w)
|
||||||
|
|
||||||
if (UNIX)
|
IF (UNIX)
|
||||||
add_definitions(-DUNIX)
|
ADD_DEFINITIONS(-DUNIX)
|
||||||
endif (UNIX)
|
ENDIF (UNIX)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(./include ./src ../libs/include)
|
INCLUDE_DIRECTORIES(./include ./src ../libs/include)
|
||||||
|
|
||||||
file(GLOB_RECURSE HW_HEADS
|
FILE(GLOB_RECURSE HW_HEADS
|
||||||
./src/haywire/*.h
|
./src/haywire/*.h
|
||||||
./src/haywire/configuration/*.h)
|
./src/haywire/configuration/*.h)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ INCLUDE_DIRECTORIES(. ./include)
|
||||||
|
|
||||||
#find_package(Threads REQUIRED)
|
#find_package(Threads REQUIRED)
|
||||||
|
|
||||||
add_library(haywire STATIC ${HW_SRC} ${HW_HEADS})
|
ADD_LIBRARY(haywire STATIC ${HW_SRC} ${HW_HEADS})
|
||||||
target_link_libraries(haywire -luv -pthread)
|
TARGET_LINK_LIBRARIES(haywire -luv -pthread)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@ SET(LIB_PROJECT_TARGET common)
|
||||||
|
|
||||||
PROJECT(${LIB_PROJECT_TARGET})
|
PROJECT(${LIB_PROJECT_TARGET})
|
||||||
|
|
||||||
include(ExternalProject)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(include
|
INCLUDE_DIRECTORIES(include
|
||||||
./ ./include ../lwip/src/include ../lwip/src/arch_linux/include ../include
|
./ ./include ../lwip/src/include ../lwip/src/arch_linux/include ../include
|
||||||
../httpserver/include ../httpserver/src/haywire ../httpserver/src/haywire/configuration)
|
../httpserver/include ../httpserver/src/haywire ../httpserver/src/haywire/configuration)
|
||||||
|
@ -23,23 +21,23 @@ AUX_SOURCE_DIRECTORY(cmdline C_SRC)
|
||||||
AUX_SOURCE_DIRECTORY(crypto C_SRC)
|
AUX_SOURCE_DIRECTORY(crypto C_SRC)
|
||||||
AUX_SOURCE_DIRECTORY(hardware C_SRC)
|
AUX_SOURCE_DIRECTORY(hardware C_SRC)
|
||||||
|
|
||||||
if (USED_REDIS)
|
IF (USED_REDIS)
|
||||||
ADD_DEFINITIONS(-DUSED_REDIS)
|
ADD_DEFINITIONS(-DUSED_REDIS)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_SQLITE)
|
IF (USED_SQLITE)
|
||||||
ADD_DEFINITIONS(-DUSED_SQLITE)
|
ADD_DEFINITIONS(-DUSED_SQLITE)
|
||||||
AUX_SOURCE_DIRECTORY(database/sqlite3 C_SRC)
|
AUX_SOURCE_DIRECTORY(database/sqlite3 C_SRC)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
if (USED_MYSQL)
|
IF (USED_MYSQL)
|
||||||
ADD_DEFINITIONS(-DUSED_MYSQL)
|
ADD_DEFINITIONS(-DUSED_MYSQL)
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
SET(CMAKE_C_STANDARD 99)
|
SET(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(misc/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto")
|
SET_SOURCE_FILES_PROPERTIES(misc/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto")
|
||||||
if (USED_SQLITE)
|
IF (USED_SQLITE)
|
||||||
SET_SOURCE_FILES_PROPERTIES(database/sqlite3/sqlite3.c PROPERTIES
|
SET_SOURCE_FILES_PROPERTIES(database/sqlite3/sqlite3.c PROPERTIES
|
||||||
COMPILE_FLAGS "-DSQLITE_HAS_CODEC \
|
COMPILE_FLAGS "-DSQLITE_HAS_CODEC \
|
||||||
-DSQLCIPHER_CRYPTO_OPENSSL -DSQLITE_OS_UNIX=1 \
|
-DSQLCIPHER_CRYPTO_OPENSSL -DSQLITE_OS_UNIX=1 \
|
||||||
|
@ -47,11 +45,10 @@ if (USED_SQLITE)
|
||||||
-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
|
-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
|
||||||
-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
|
-DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
|
||||||
-DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2")
|
-DSQLITE_HAVE_ZLIB=1 -DSQLITE_TEMP_STORE=2")
|
||||||
endif ()
|
ENDIF ()
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE})
|
ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE})
|
||||||
|
|
||||||
|
|
||||||
LINK_LIBRARIES(${COMMON_LIBS})
|
LINK_LIBRARIES(${COMMON_LIBS})
|
||||||
ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS})
|
ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue