From 0adceb10002ccbe0f7098ae81239df0c66a3484c Mon Sep 17 00:00:00 2001 From: huangxin Date: Tue, 27 Sep 2022 17:43:16 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20ZNJK-1000=20=E6=9B=B4=E6=96=B0CMake?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E8=84=9A=E6=9C=AC=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 5 ++++- srcs/CMakeLists.txt | 13 ++++++++----- srcs/libs/CMakeLists.txt | 27 +++++++++++++++------------ srcs/open_dhcp/CMakeLists.txt | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 126870f..5911606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,10 +32,13 @@ endif () if (USED_LWIP) MESSAGE("Select Option USED_LWIP") - ADD_SUBDIRECTORY(srcs/lwip) endif () if (USED_OPENDHCPD) MESSAGE("Select Option USED_OPENDHCPD") ADD_SUBDIRECTORY(srcs/open_dhcp) endif () + +if (USED_LWIP OR VCPE_AGENT) + ADD_SUBDIRECTORY(srcs/lwip) +endif () diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index 5921e57..8b80869 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -11,12 +11,15 @@ include(ExternalProject) # 判断依赖库是否存在 FIND_PACKAGE(PkgConfig) -PKG_SEARCH_MODULE(LIBCURL REQUIRED libcurl) -PKG_SEARCH_MODULE(LIBSSL REQUIRED libssl) -PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto) +if (USED_LWIP OR VCPE_AGENT) + 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") +endif () -SET(COMMON_LIBS ${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}) -SET(COMMON_LIBS ${COMMON_LIBS} "-ldl -lpthread -lzlog -lm -luv -lzmq -luuid -lconfig") +LIST(APPEND COMMON_LIBS "-lpthread") INCLUDE_DIRECTORIES(include ./ ./include ./libs/include ./lwip/src/include ./lwip/src/arch_linux/include ${COMMON_INCLUDE}) diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index aef0347..8f3eb0c 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -7,19 +7,22 @@ include(ExternalProject) INCLUDE_DIRECTORIES(include ./ ./include ../lwip/src/include ../lwip/src/arch_linux/include ../include ${COMMON_INCLUDE}) FILE(GLOB C_HEADS include/*.h include/uthash/*.h include/s2j/*.h) -AUX_SOURCE_DIRECTORY(args C_SRC) -AUX_SOURCE_DIRECTORY(init C_SRC) -AUX_SOURCE_DIRECTORY(misc C_SRC) -AUX_SOURCE_DIRECTORY(database C_SRC) -AUX_SOURCE_DIRECTORY(banner C_SRC) -AUX_SOURCE_DIRECTORY(configure C_SRC) -AUX_SOURCE_DIRECTORY(network C_SRC) -AUX_SOURCE_DIRECTORY(task C_SRC) -AUX_SOURCE_DIRECTORY(mq C_SRC) -AUX_SOURCE_DIRECTORY(cmdline C_SRC) -AUX_SOURCE_DIRECTORY(crypto C_SRC) AUX_SOURCE_DIRECTORY(json C_SRC) -AUX_SOURCE_DIRECTORY(hardware C_SRC) + +if (USED_LWIP OR VCPE_AGENT) + AUX_SOURCE_DIRECTORY(args C_SRC) + AUX_SOURCE_DIRECTORY(init C_SRC) + AUX_SOURCE_DIRECTORY(misc C_SRC) + AUX_SOURCE_DIRECTORY(database C_SRC) + AUX_SOURCE_DIRECTORY(banner C_SRC) + AUX_SOURCE_DIRECTORY(configure C_SRC) + AUX_SOURCE_DIRECTORY(network C_SRC) + AUX_SOURCE_DIRECTORY(task C_SRC) + AUX_SOURCE_DIRECTORY(mq C_SRC) + AUX_SOURCE_DIRECTORY(cmdline C_SRC) + AUX_SOURCE_DIRECTORY(crypto C_SRC) + AUX_SOURCE_DIRECTORY(hardware C_SRC) +endif () SET(CMAKE_C_STANDARD 99) diff --git a/srcs/open_dhcp/CMakeLists.txt b/srcs/open_dhcp/CMakeLists.txt index cf58a61..6b34cbc 100644 --- a/srcs/open_dhcp/CMakeLists.txt +++ b/srcs/open_dhcp/CMakeLists.txt @@ -6,7 +6,7 @@ INCLUDE_DIRECTORIES(../libs/include ./) FILE(GLOB DHCPD_HEADS ./*.h) -add_definitions(-Wno-format-overflow) +ADD_DEFINITIONS(-Wno-format-overflow) #ADD_EXECUTABLE(${PROJECT_TARGET} opendhcpd.cpp ${DHCPD_HEADS}) ADD_LIBRARY(${DHCPD_PROJECT_TARGET} opendhcpd.cpp ${DHCPD_HEADS})