2023-12-24 19:27:59 +00:00
|
|
|
cmake_minimum_required(VERSION 3.25)
|
2023-12-24 19:27:59 +00:00
|
|
|
|
|
|
|
# Set the project name and version
|
2023-12-26 13:15:44 +00:00
|
|
|
project(igmpgen VERSION 1.0)
|
2023-12-24 19:27:59 +00:00
|
|
|
|
|
|
|
# Specify the C standard
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
|
|
|
|
2023-12-26 21:47:28 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -Wall -Werror -D_GNU_SOURCE -pedantic")
|
|
|
|
|
|
|
|
|
2023-12-24 19:27:59 +00:00
|
|
|
# Add the executable
|
2023-12-26 21:47:28 +00:00
|
|
|
add_executable(
|
|
|
|
igmpgen
|
|
|
|
src/main.c
|
|
|
|
src/usage.c
|
|
|
|
)
|
2023-12-24 19:27:59 +00:00
|
|
|
|
|
|
|
# Detect the net library
|
|
|
|
find_library(LIBNET_LIBRARY NAMES net libnet libnet1 REQUIRED)
|
|
|
|
message(STATUS "libnet detected as ${LIBNET_LIBRARY}")
|
|
|
|
|
|
|
|
# Add the directories where the compiler can find the libnet headers
|
|
|
|
target_include_directories(igmpgen PRIVATE /usr/include)
|
|
|
|
|
|
|
|
# Add the directories where the compiler can find the libnet libraries
|
|
|
|
target_link_directories(igmpgen PRIVATE /usr/lib)
|
2023-12-24 19:27:59 +00:00
|
|
|
|
|
|
|
# Link the executable to the libnet library
|
2023-12-24 19:27:59 +00:00
|
|
|
target_link_libraries(igmpgen ${LIBNET_LIBRARY})
|
2023-12-26 13:15:44 +00:00
|
|
|
|
|
|
|
# Installation instructions
|
|
|
|
install(TARGETS igmpgen DESTINATION bin)
|
|
|
|
|
2023-12-27 09:23:13 +00:00
|
|
|
# Install the man page
|
2023-12-27 10:14:41 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/misc/)
|
|
|
|
file(
|
|
|
|
ARCHIVE_CREATE
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/misc/igmpgen.1.gz
|
|
|
|
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/misc/igmpgen.man.1
|
|
|
|
FORMAT raw
|
|
|
|
COMPRESSION GZip
|
|
|
|
)
|
2023-12-27 09:55:21 +00:00
|
|
|
install(
|
2023-12-27 10:14:41 +00:00
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/misc/igmpgen.1.gz
|
2023-12-27 10:27:57 +00:00
|
|
|
TYPE MAN
|
2023-12-27 09:55:21 +00:00
|
|
|
)
|
2023-12-27 09:23:13 +00:00
|
|
|
|
2023-12-26 13:15:44 +00:00
|
|
|
# Include CPack for packaging
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${igmpgen_VERSION_MAJOR}")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${igmpgen_VERSION_MINOR}")
|
|
|
|
|
|
|
|
# CPack RPM specific settings
|
2023-12-27 12:13:13 +00:00
|
|
|
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
|
2023-12-26 13:15:44 +00:00
|
|
|
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
|
|
|
set(CPACK_RPM_PACKAGE_SUMMARY "IGMP Packet Generator")
|
|
|
|
set(CPACK_RPM_PACKAGE_NAME "igmpgen")
|
|
|
|
set(CPACK_RPM_PACKAGE_VERSION "${igmpgen_VERSION}")
|
|
|
|
set(CPACK_RPM_PACKAGE_RELEASE 1)
|
|
|
|
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
|
|
|
|
set(CPACK_RPM_PACKAGE_GROUP "Network")
|
|
|
|
set(CPACK_RPM_PACKAGE_VENDOR "Your Company/Organization")
|
|
|
|
set(CPACK_RPM_PACKAGE_DESCRIPTION "A tool for generating IGMP packets.")
|
2023-12-27 12:13:13 +00:00
|
|
|
set(CPACK_RPM_PACKAGE_LICENSE "LGPL-3.0-or-later")
|
2023-12-26 13:15:44 +00:00
|
|
|
|
|
|
|
# CPack DEB specific settings
|
2023-12-27 12:13:13 +00:00
|
|
|
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
|
2023-12-26 13:15:44 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Your Name <your-email@example.com>")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_NAME "igmpgen")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_VERSION "${igmpgen_VERSION}")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SECTION "net")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A tool for generating IGMP packets.")
|
|
|
|
|
|
|
|
set(CPACK_GENERATOR "TGZ;RPM;DEB")
|
|
|
|
include(CPack)
|