summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
author童宗振 <[email protected]>2024-01-17 02:44:24 +0000
committer陆秋文 <[email protected]>2024-01-17 02:44:24 +0000
commite0433fc974a91a2ec7a6939325a47a74b01f450e (patch)
treec530a6d0147f4cb733211558becb60988ca409d9 /CMakeLists.txt
parent4b061783cf6771a47b39fd34443c81cd0ea7fe14 (diff)
refactor ci
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt68
1 files changed, 32 insertions, 36 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9897e77..712890f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,22 +9,28 @@ endif()
project(marsio)
+# option
+option(ENABLE_WARNING_AS_ERROR "Enable all optional warnings which are desirable for normal code" TRUE)
+option(ENABLE_SANITIZE_ADDRESS "Enable AddressSanitizer" FALSE)
+option(ENABLE_SANITIZE_THREAD "Enable ThreadSanitizer" FALSE)
+option(ENABLE_VNODE_CHECK_THREAD_SAFE "Enable concurrent write thread-safe check for VNODE." FALSE)
+option(ENABLE_PTF_TEST "Enable ptf test." FALSE)
+
+# envirment
message("CMake version: ${CMAKE_VERSION}")
message(STATUS "C Compiler Version: ${CMAKE_C_COMPILER_VERSION}")
message(STATUS "CXX Compiler Version: ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "C Standard: ${CMAKE_C_STANDARD}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
-
+# machine
set(COREI7 "corei7")
set(ICELAKE_SERVER "icelake-server")
set(ZNVER1 "znver1")
set(SUPPORTED_MACHINES ${COREI7} ${ICELAKE_SERVER} ${ZNVER1})
-
if(NOT MACHINE)
set(MACHINE "corei7")
endif()
-
list(FIND SUPPORTED_MACHINES ${MACHINE} INDEX)
if(${INDEX} GREATER -1)
message(STATUS "current MACHINE is ${MACHINE}.")
@@ -32,23 +38,7 @@ else()
message(FATAL_ERROR "${MACHINE} is not in the support machines list.")
endif()
-# Include Modules
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
-
-find_package(PCAP REQUIRED)
-link_directories(${PCAP_LIBRARY_DIR})
-include_directories(${PCAP_INCLUDE_DIR})
-
-# version
-include(Version)
-
-# EXTRA Flags
-# GNU99 and C++11 Support
-option(ENABLE_WARNING_AS_ERROR "Enable all optional warnings which are desirable for normal code" TRUE)
-option(ENABLE_SANITIZE_ADDRESS "Enable AddressSanitizer" FALSE)
-option(ENABLE_SANITIZE_THREAD "Enable ThreadSanitizer" FALSE)
-option(ENABLE_VNODE_CHECK_THREAD_SAFE "Enable concurrent write thread-safe check for VNODE." FALSE)
-
+# FLAGS and define
set(CMAKE_C_FLAGS "-std=gnu99 -m64 -march=${MACHINE} -fPIC -Wall -Wno-format-truncation")
set(CMAKE_CXX_FLAGS "-std=gnu++11 -m64 -march=${MACHINE} -fPIC -Wall -Wno-format-truncation")
@@ -82,22 +72,21 @@ if(ENABLE_FUZZING_TEST)
set(OTHER_FLAGS "-fPIC -m64 -march=${MACHINE}")
set(CMAKE_C_FLAGS "${FSANITIZE_FUZZER_FLAGS} ${COVERAGE_FLAGS} ${OTHER_FLAGS}")
set(CMAKE_CXX_FLAGS "${FSANITIZE_FUZZER_FLAGS} ${COVERAGE_FLAGS} ${OTHER_FLAGS}")
- add_subdirectory(fuzzing)
+endif()
+
+if(ENABLE_PTF_TEST OR ENABLE_FUZZING_TEST)
+ enable_testing()
endif()
if(ENABLE_VNODE_CHECK_THREAD_SAFE)
add_definitions(-DVNODE_CHECK_THREAD_SAFE)
endif()
-# Default Install Destination Directory
-set(CMAKE_INSTALL_PREFIX /opt/tsg/mrzcpd)
add_definitions(-D_GNU_SOURCE -D__STDC_LIMIT_MACROS)
add_definitions(-DALLOW_EXPERIMENTAL_API=1)
-include_directories(include/external)
-include_directories(include/internal)
-
# Install Dirs
+set(CMAKE_INSTALL_PREFIX /opt/tsg/mrzcpd)
set(MR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(MR_INSTALL_LIBDIR ${MACHINE}/lib)
set(MR_INSTALL_BINDIR ${MACHINE}/bin)
@@ -125,6 +114,17 @@ endif()
exec_program(pkg-config ARGS systemd --variable=systemdsystemunitdir OUTPUT_VARIABLE MR_INSTALL_SYSUNITDIR)
+# compile
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+include(Version)
+
+include_directories(include/external)
+include_directories(include/internal)
+
+find_package(PCAP REQUIRED)
+link_directories(${PCAP_LIBRARY_DIR})
+include_directories(${PCAP_INCLUDE_DIR})
+
add_subdirectory(${CMAKE_SOURCE_DIR}/support)
add_subdirectory(${CMAKE_SOURCE_DIR}/include)
add_subdirectory(${CMAKE_SOURCE_DIR}/infra)
@@ -135,18 +135,14 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/pag)
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)
add_subdirectory(${CMAKE_SOURCE_DIR}/tools)
add_subdirectory(${CMAKE_SOURCE_DIR}/conf)
-#add_subdirectory(${CMAKE_SOURCE_DIR}/test)
+add_subdirectory(${CMAKE_SOURCE_DIR}/test)
-if(BUILD_TESTS)
- enable_testing()
- add_subdirectory(test)
-endif()
-
-add_custom_target("install-program" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Program -P cmake_install.cmake)
-add_custom_target("install-profile" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Profile -P cmake_install.cmake)
+# add_custom_target("install-program" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Program -P cmake_install.cmake)
+# add_custom_target("install-profile" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Profile -P cmake_install.cmake)
message(STATUS "Packet I/O Middleware based on DPDK(Marsio), Version: ${MARSIO_VERSION}")
-# packed
-include(Package)
+# package
include(InstallDPDK)
+include(Package)
+