build: Fix CMake and ns3 script bugs, add a test suite and fix formatting

This commit is contained in:
Gabriel Ferreira
2021-12-05 21:53:49 +00:00
parent 1dc223f85a
commit a893eba7e3
123 changed files with 3492 additions and 1135 deletions

View File

@@ -1,9 +1,10 @@
# ######################################################################################################################
# ##############################################################################
# Required CMake version #
# ######################################################################################################################
cmake_minimum_required(VERSION 3.10)
# ##############################################################################
cmake_minimum_required(VERSION 3.10..3.10)
# Use ccache if available
mark_as_advanced(CCACHE_FOUND)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
@@ -11,17 +12,18 @@ if(CCACHE_FOUND)
message(STATUS "CCache is enabled")
# Configure ccache for pch headers
execute_process(COMMAND ${CCACHE_FOUND} --set-config=sloppiness=pch_defines,time_macros,include_file_mtime)
execute_process(
COMMAND ${CCACHE_FOUND}
--set-config=sloppiness=pch_defines,time_macros,include_file_mtime
)
endif()
# ######################################################################################################################
# ##############################################################################
# Project name #
# ######################################################################################################################
# ##############################################################################
project(NS3 CXX C)
include(buildsupport/macros_and_definitions.cmake)
set(NS3_VER 3-dev)
file(STRINGS VERSION NS3_VER)
# common options
option(NS3_ASSERT "Enable assert on failure" OFF)
@@ -38,12 +40,22 @@ option(NS3_TAP "Build with Tap support" ON)
# maintenance and documentation
option(NS3_CLANG_FORMAT "Enforce cody style with clang-format" OFF)
option(NS3_CLANG_TIDY "Use clang-tidy static analysis" OFF)
option(NS3_CLANG_TIMETRACE "Collect compilation statistics to analyze the build process" OFF)
option(NS3_COVERAGE "Enable code coverage measurements and report generation" OFF)
option(NS3_COVERAGE_ZERO_COUNTERS "Zero lcov counters before running. Requires NS3_COVERAGE=ON" OFF)
option(NS3_CLANG_TIMETRACE
"Collect compilation statistics to analyze the build process" OFF
)
option(NS3_COVERAGE "Enable code coverage measurements and report generation"
OFF
)
option(NS3_COVERAGE_ZERO_COUNTERS
"Zero lcov counters before running. Requires NS3_COVERAGE=ON" OFF
)
option(NS3_DOCS "Generate documentation" OFF)
option(NS3_INCLUDE_WHAT_YOU_USE "Use IWYU to determine unnecessary headers included" OFF)
option(NS3_LINK_WHAT_YOU_USE "Use LWYU to determine unnecessary linked libraries" OFF)
option(NS3_INCLUDE_WHAT_YOU_USE
"Use IWYU to determine unnecessary headers included" OFF
)
option(NS3_LINK_WHAT_YOU_USE
"Use LWYU to determine unnecessary linked libraries" OFF
)
option(NS3_SANITIZE "Build with address, leak and undefined sanitizers" OFF)
option(NS3_SANITIZE_MEMORY "Build with memory sanitizer" OFF)
option(NS3_SCAN_PYTHON_BINDINGS "Scan python bindings" OFF)
@@ -57,23 +69,39 @@ option(NS3_GNUPLOT "Build with Gnuplot support" OFF)
option(NS3_GSL "Build with GSL support" ON)
option(NS3_GTK3 "Build with GTK3 support" ON)
option(NS3_LINK_TIME_OPTIMIZATION "Build with link-time optimization" OFF)
option(NS3_MONOLIB "Build a single shared ns-3 library and link it against executables" OFF)
option(NS3_MONOLIB
"Build a single shared ns-3 library and link it against executables" OFF
)
option(NS3_MPI "Build with MPI support" ON)
option(NS3_NATIVE_OPTIMIZATIONS "Build with -march=native -mtune=native" OFF)
option(NS3_NSC "Build with NSC support" OFF) # currently not supported
option(NS3_PRECOMPILE_HEADERS "Precompile module headers to speed up compilation" ON)
set(NS3_OUTPUT_DIRECTORY "" CACHE STRING "Directory to store built artifacts")
option(NS3_PRECOMPILE_HEADERS
"Precompile module headers to speed up compilation" ON
)
option(NS3_PTHREAD "Build with pthread support" ON)
option(NS3_PYTHON_BINDINGS "Build ns-3 python bindings" OFF)
option(NS3_REALTIME "Build with realtime support" ON)
option(NS3_SQLITE "Build with SQLite support" ON)
option(NS3_STATIC "Build a static ns-3 library and link it against executables" OFF)
option(NS3_STATIC "Build a static ns-3 library and link it against executables"
OFF
)
option(NS3_VISUALIZER "Build visualizer module" OFF)
option(NS3_WARNINGS "Enable compiler warnings" ON)
option(NS3_WARNINGS_AS_ERRORS "Treat warnings as errors. Requires NS3_WARNINGS=ON" ON)
option(NS3_WARNINGS_AS_ERRORS
"Treat warnings as errors. Requires NS3_WARNINGS=ON" ON
)
# Options that either select which modules will get built or disable modules
set(NS3_ENABLED_MODULES "" CACHE STRING "List of modules to enable (e.g. core;network;internet)")
set(NS3_DISABLED_MODULES "" CACHE STRING "List of modules to disable (e.g. lte;wimax;wave)")
set(NS3_ENABLED_MODULES ""
CACHE STRING "List of modules to enable (e.g. core;network;internet)"
)
set(NS3_DISABLED_MODULES ""
CACHE STRING "List of modules to disable (e.g. lte;wimax;wave)"
)
# Include macros used below
include(buildsupport/macros_and_definitions.cmake)
# Scan module libraries
subdirlist(libs_to_build ${CMAKE_SOURCE_DIR}/src)
@@ -81,17 +109,23 @@ subdirlist(libs_to_build ${CMAKE_SOURCE_DIR}/src)
# Scan contribution libraries
subdirlist(contrib_libs_to_build ${CMAKE_SOURCE_DIR}/contrib)
# After scanning modules, we can filter enabled and disabled ones
filter_enabled_and_disabled_modules(libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES)
# Before filtering, we need to load settings from .ns3rc
parse_ns3rc(ns3rc_enabled_modules ns3rc_examples_enabled ns3rc_tests_enabled)
# ######################################################################################################################
# After scanning modules, we can filter enabled and disabled ones
filter_enabled_and_disabled_modules(
libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES
ns3rc_enabled_modules
)
# ##############################################################################
# Process options #
# ######################################################################################################################
# ##############################################################################
process_options()
# ######################################################################################################################
# ##############################################################################
# Add subdirectories #
# ######################################################################################################################
# ##############################################################################
# Build NS3 library core
add_subdirectory(src)