1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#
# bdf2sfd 1.2.0
# Copyright (c) 2019-2026, Frederic Cambus
# https://github.com/fcambus/bdf2sfd
#
# Created: 2019-11-21
# Last Updated: 2025-03-24
#
# bdf2sfd is released under the BSD 2-Clause license.
# See LICENSE file for details.
#
# SPDX-License-Identifier: BSD-2-Clause
#
cmake_minimum_required(VERSION 3.10)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
project(bdf2sfd C)
include(CheckFunctionExists)
include(GNUInstallDirs)
# Conditional build options
set(ENABLE_SECCOMP 0 CACHE BOOL "Enable building with seccomp")
# Check if system has pledge and strtonum
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_OPENBSD_SOURCE)
check_function_exists(pledge HAVE_PLEDGE)
check_function_exists(strtonum HAVE_STRTONUM)
if(ENABLE_SECCOMP)
# Check if system has seccomp
message(STATUS "Looking for seccomp")
find_path(SECCOMP NAMES "linux/seccomp.h")
if(SECCOMP)
message(STATUS "Looking for seccomp - found")
add_definitions(-DHAVE_SECCOMP)
else()
message(STATUS "Looking for seccomp - not found")
endif()
endif(ENABLE_SECCOMP)
# Additional include directories for compat functions + dependencies
include_directories("compat")
set(SRC src/bdf2sfd.c src/header.c src/parse.c src/polygon.c)
if(NOT HAVE_PLEDGE)
set(SRC ${SRC} compat/pledge.c)
endif()
if(NOT HAVE_STRTONUM)
set(SRC ${SRC} compat/strtonum.c)
endif()
add_definitions(-D_GNU_SOURCE -Wall -Wextra -pedantic)
add_executable(bdf2sfd ${SRC})
install(TARGETS bdf2sfd DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES man/bdf2sfd.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
enable_testing()
add_test(bdf2sfd bdf2sfd)
add_test(8x16 bdf2sfd ${PROJECT_SOURCE_DIR}/tests/spleen-8x16.bdf)
add_test(12x24 bdf2sfd ${PROJECT_SOURCE_DIR}/tests/spleen-12x24.bdf)
add_test(16x32 bdf2sfd ${PROJECT_SOURCE_DIR}/tests/spleen-16x32.bdf)
add_test(32x64 bdf2sfd ${PROJECT_SOURCE_DIR}/tests/spleen-32x64.bdf)
|