1
0
mirror of https://github.com/rtbrick/bngblaster.git synced 2024-05-06 15:54:57 +00:00
rtbrick-bngblaster/CMakeLists.txt

89 lines
2.8 KiB
CMake
Raw Normal View History

2021-02-04 21:56:56 +01:00
# BNG Blaster
#
# For Debug Build Try below command
2021-02-04 21:56:56 +01:00
#cmake -DCMAKE_BUILD_TYPE=Debug .
2021-05-26 19:39:12 +02:00
cmake_minimum_required (VERSION 3.10)
2021-02-05 16:00:09 +01:00
project(bngblaster LANGUAGES C VERSION 0.0.0)
option(BNGBLASTER_TESTS "Build unit tests (requires cmocka)" OFF)
option(BNGBLASTER_NETMAP "Build with netmap support" OFF)
2021-02-04 21:56:56 +01:00
2021-05-26 19:39:12 +02:00
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
2021-02-04 21:56:56 +01:00
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Debug Build")
set(CMAKE_BUILD_TYPE Debug)
add_definitions(-DBBL_DEBUG)
else()
message("Release Build")
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
endif()
2021-02-04 21:56:56 +01:00
# libdict will be statically linked
2021-02-04 21:56:56 +01:00
find_library(libdict NAMES libdict.a REQUIRED)
2022-02-23 18:13:12 +01:00
set(CURSES_NEED_NCURSES TRUE)
include(FindCurses)
target_link_libraries(bngblaster ${CURSES_LIBRARIES} crypto jansson ${libdict} m)
set(PLATFORM_SPECIFIC_LIBS "-lpthread")
string(APPEND CMAKE_C_FLAGS "-pthread")
# add LwIP
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/lwip)
set(LWIP_DEFINITIONS LWIP_DEBUG=1)
set(LWIP_DEFINITIONS LWIP_TCPIP_CORE_LOCKING=1)
set(LWIP_DEFINITIONS LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS=1)
include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake)
set(LWIP_INCLUDE_DIRS
"src/lwip"
"${LWIP_DIR}/src/include"
"${LWIP_DIR}/contrib/"
"${LWIP_DIR}/contrib/ports/unix/port/include"
)
include(${LWIP_DIR}/src/Filelists.cmake)
include(${LWIP_DIR}/contrib/Filelists.cmake)
include(${LWIP_DIR}/contrib/ports/unix/Filelists.cmake)
target_include_directories(bngblaster PRIVATE ${LWIP_INCLUDE_DIRS})
target_compile_definitions(bngblaster PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_link_libraries(bngblaster ${LWIP_SANITIZER_LIBS} lwipcore lwipcontribportunix)
# add experimental netmap support
if(BNGBLASTER_NETMAP)
add_definitions(-DBNGBLASTER_NETMAP)
target_link_libraries(bngblaster netmap)
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
target_compile_options(bngblaster PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
endif()
target_compile_options(bngblaster PRIVATE -Werror -Wall -Wextra -m64 -mtune=generic)
set_property(TARGET bngblaster PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
# Build tests only if required
2021-02-04 21:56:56 +01:00
if(BNGBLASTER_TESTS)
include(CTest)
endif()
add_subdirectory(code)
2021-02-04 21:56:56 +01:00
set(CPACK_GENERATOR "DEB")
2021-02-05 16:06:35 +01:00
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libssl1.1, libncurses5, libjansson4")
2021-02-04 21:56:56 +01:00
set(CPACK_DEBIAN_LIB_PACKAGE_NAME "bngblaster")
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
2021-02-05 16:06:35 +01:00
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "RtBrick BNG Blaster")
2021-02-04 21:56:56 +01:00
set(CPACK_PACKAGE_CONTACT "RtBrick <bngblaster@rtbrick.com>")
2021-02-05 11:28:18 +01:00
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/rtbrick/bngblaster")
2021-02-05 16:00:09 +01:00
if (NOT DEFINED BNGBLASTER_VERSION)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
else()
set(CPACK_PACKAGE_VERSION ${BNGBLASTER_VERSION})
endif()
include(CPack)