2021-02-04 21:56:56 +01:00
|
|
|
# BNG Blaster
|
|
|
|
#
|
2021-05-26 08:21:45 +02:00
|
|
|
# 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)
|
2021-03-17 22:02:04 +01:00
|
|
|
option(BNGBLASTER_NETMAP "Build with netmap support" OFF)
|
2021-02-04 21:56:56 +01:00
|
|
|
|
|
|
|
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h")
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
FILE(GLOB BBL_SOURCES src/*.c)
|
2021-05-27 08:05:08 +02:00
|
|
|
list(SORT BBL_SOURCES)
|
2021-05-26 19:39:12 +02:00
|
|
|
# Deterministic randomness for symbol name creation
|
|
|
|
foreach(_file ${BBL_SOURCES})
|
|
|
|
file(SHA1 ${_file} checksum)
|
|
|
|
string(SUBSTRING ${checksum} 0 8 checksum)
|
|
|
|
set_property(SOURCE ${_file} APPEND_STRING PROPERTY COMPILE_FLAGS "-frandom-seed=0x${checksum}")
|
|
|
|
endforeach()
|
2021-02-04 21:56:56 +01:00
|
|
|
add_executable(bngblaster ${BBL_SOURCES})
|
|
|
|
|
2021-05-26 08:21:45 +02:00
|
|
|
# libdict will be statically linked
|
2021-02-04 21:56:56 +01:00
|
|
|
find_library(libdict NAMES libdict.a REQUIRED)
|
|
|
|
|
2021-05-26 08:21:45 +02:00
|
|
|
set(CURSES_NEED_NCURSES TRUE)
|
|
|
|
include(FindCurses)
|
|
|
|
target_link_libraries(bngblaster ${CURSES_LIBRARIES} crypto jansson ${libdict} m)
|
2021-03-22 16:49:11 +01:00
|
|
|
|
2021-07-09 14:20:06 +02:00
|
|
|
set(PLATFORM_SPECIFIC_LIBS "-lpthread")
|
|
|
|
string(APPEND CMAKE_C_FLAGS "-pthread")
|
2021-04-01 20:07:50 +02:00
|
|
|
|
2021-05-26 19:39:12 +02:00
|
|
|
|
2021-03-22 16:49:11 +01:00
|
|
|
# add experimental netmap support
|
2021-03-17 22:02:04 +01:00
|
|
|
if(BNGBLASTER_NETMAP)
|
|
|
|
add_definitions(-DBNGBLASTER_NETMAP)
|
|
|
|
target_link_libraries(bngblaster netmap)
|
|
|
|
endif()
|
|
|
|
|
2021-05-26 20:49:25 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
|
|
|
|
target_compile_options(bngblaster PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
|
|
|
|
endif()
|
2021-02-04 21:56:56 +01:00
|
|
|
target_compile_options(bngblaster PRIVATE -Werror -Wall -Wextra -m64 -mtune=generic)
|
2021-05-26 19:39:12 +02:00
|
|
|
set_property(TARGET bngblaster PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
2021-02-04 21:56:56 +01:00
|
|
|
|
|
|
|
# Build tests only if required
|
|
|
|
if(BNGBLASTER_TESTS)
|
|
|
|
message("Build Tests")
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
|
|
|
|
2021-10-06 16:28:14 +02:00
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
|
|
|
|
endif()
|
2021-08-04 14:59:47 +02:00
|
|
|
|
2021-02-04 21:56:56 +01:00
|
|
|
install(TARGETS bngblaster DESTINATION sbin)
|
2021-06-23 14:38:16 +02:00
|
|
|
install(PROGRAMS bngblaster-cli DESTINATION sbin)
|
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()
|
2021-05-26 08:21:45 +02:00
|
|
|
include(CPack)
|