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

85 lines
2.6 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
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})
# libdict will be statically linked
2021-02-04 21:56:56 +01:00
find_library(libdict NAMES libdict.a REQUIRED)
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
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
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()
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()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
endif()
2021-02-04 21:56:56 +01:00
install(TARGETS bngblaster DESTINATION sbin)
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()
include(CPack)