2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2021-11-10 22:28:44 -03:00
|
|
|
# Required CMake version #
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
|
|
|
|
cmake_minimum_required(VERSION 3.10..3.10)
|
2021-11-10 22:28:44 -03:00
|
|
|
|
|
|
|
|
# Use ccache if available
|
2021-12-05 21:53:49 +00:00
|
|
|
mark_as_advanced(CCACHE_FOUND)
|
2022-04-03 23:56:07 -03:00
|
|
|
find_program(CCACHE ccache)
|
|
|
|
|
if(NOT ("${CCACHE}" STREQUAL "CCACHE-NOTFOUND"))
|
2021-11-10 22:28:44 -03:00
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
2022-01-08 23:09:57 -03:00
|
|
|
message(
|
|
|
|
|
STATUS "CCache is enabled. Precompiled headers are disabled by default."
|
2021-12-05 21:53:49 +00:00
|
|
|
)
|
2022-01-31 20:02:10 -03:00
|
|
|
set(NS3_PRECOMPILE_HEADERS OFF
|
|
|
|
|
CACHE BOOL "Precompile module headers to speed up compilation" FORCE
|
|
|
|
|
)
|
2021-11-10 22:28:44 -03:00
|
|
|
endif()
|
|
|
|
|
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2021-11-10 22:28:44 -03:00
|
|
|
# Project name #
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2022-03-02 11:51:53 -03:00
|
|
|
project(NS3 CXX)
|
2021-11-10 22:28:44 -03:00
|
|
|
|
2021-12-05 21:53:49 +00:00
|
|
|
file(STRINGS VERSION NS3_VER)
|
2021-11-10 22:28:44 -03:00
|
|
|
|
2021-12-10 02:13:43 +00:00
|
|
|
# minimum compiler versions
|
2021-12-10 10:26:52 -08:00
|
|
|
set(AppleClang_MinVersion 11.0.0)
|
|
|
|
|
set(Clang_MinVersion 6.0.0)
|
|
|
|
|
set(GNU_MinVersion 8.0.0)
|
2021-12-10 02:13:43 +00:00
|
|
|
|
2021-11-10 22:28:44 -03:00
|
|
|
# common options
|
|
|
|
|
option(NS3_ASSERT "Enable assert on failure" OFF)
|
|
|
|
|
option(NS3_DES_METRICS "Enable DES Metrics event collection" OFF)
|
|
|
|
|
option(NS3_EXAMPLES "Enable examples to be built" OFF)
|
|
|
|
|
option(NS3_LOG "Enable logging to be built" OFF)
|
|
|
|
|
option(NS3_TESTS "Enable tests to be built" OFF)
|
|
|
|
|
|
|
|
|
|
# fd-net-device options
|
|
|
|
|
option(NS3_EMU "Build with emulation support" ON)
|
|
|
|
|
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)
|
2021-12-05 21:53:49 +00:00
|
|
|
option(NS3_CLANG_TIMETRACE
|
|
|
|
|
"Collect compilation statistics to analyze the build process" OFF
|
|
|
|
|
)
|
2022-03-19 12:57:05 -03:00
|
|
|
option(NS3_COLORED_OUTPUT "Colorize CMake messages" OFF)
|
2021-12-05 21:53:49 +00:00
|
|
|
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_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
|
|
|
|
|
)
|
2021-11-10 22:28:44 -03:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
# 3rd-party libraries/programs
|
|
|
|
|
option(NS3_NETANIM "Build netanim" OFF)
|
|
|
|
|
|
|
|
|
|
# other options
|
|
|
|
|
option(NS3_ENABLE_BUILD_VERSION "Embed version info into libraries" OFF)
|
|
|
|
|
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)
|
2021-12-05 21:53:49 +00:00
|
|
|
option(NS3_MONOLIB
|
|
|
|
|
"Build a single shared ns-3 library and link it against executables" OFF
|
|
|
|
|
)
|
2022-01-23 17:30:08 -03:00
|
|
|
option(NS3_MPI "Build with MPI support" OFF)
|
2021-11-10 22:28:44 -03:00
|
|
|
option(NS3_NATIVE_OPTIMIZATIONS "Build with -march=native -mtune=native" OFF)
|
2021-12-05 21:53:49 +00:00
|
|
|
set(NS3_OUTPUT_DIRECTORY "" CACHE STRING "Directory to store built artifacts")
|
|
|
|
|
option(NS3_PRECOMPILE_HEADERS
|
|
|
|
|
"Precompile module headers to speed up compilation" ON
|
|
|
|
|
)
|
2021-11-10 22:28:44 -03:00
|
|
|
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)
|
2021-12-05 21:53:49 +00:00
|
|
|
option(NS3_STATIC "Build a static ns-3 library and link it against executables"
|
|
|
|
|
OFF
|
|
|
|
|
)
|
2021-12-16 02:29:59 +00:00
|
|
|
option(NS3_VERBOSE "Print additional build system messages" OFF)
|
2022-01-26 01:53:28 -03:00
|
|
|
option(NS3_VISUALIZER "Build visualizer module" ON)
|
2021-11-10 22:28:44 -03:00
|
|
|
option(NS3_WARNINGS "Enable compiler warnings" ON)
|
2021-12-05 21:53:49 +00:00
|
|
|
option(NS3_WARNINGS_AS_ERRORS
|
|
|
|
|
"Treat warnings as errors. Requires NS3_WARNINGS=ON" ON
|
|
|
|
|
)
|
2021-11-10 22:28:44 -03:00
|
|
|
|
|
|
|
|
# Options that either select which modules will get built or disable modules
|
2021-12-05 21:53:49 +00:00
|
|
|
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
|
2022-01-31 20:02:10 -03:00
|
|
|
include(build-support/macros-and-definitions.cmake)
|
2021-11-10 22:28:44 -03:00
|
|
|
|
|
|
|
|
# Scan module libraries
|
|
|
|
|
subdirlist(libs_to_build ${CMAKE_SOURCE_DIR}/src)
|
|
|
|
|
|
|
|
|
|
# Scan contribution libraries
|
|
|
|
|
subdirlist(contrib_libs_to_build ${CMAKE_SOURCE_DIR}/contrib)
|
|
|
|
|
|
2021-12-05 21:53:49 +00:00
|
|
|
# Before filtering, we need to load settings from .ns3rc
|
|
|
|
|
parse_ns3rc(ns3rc_enabled_modules ns3rc_examples_enabled ns3rc_tests_enabled)
|
|
|
|
|
|
2021-11-10 22:28:44 -03:00
|
|
|
# After scanning modules, we can filter enabled and disabled ones
|
2021-12-05 21:53:49 +00:00
|
|
|
filter_enabled_and_disabled_modules(
|
|
|
|
|
libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES
|
|
|
|
|
ns3rc_enabled_modules
|
|
|
|
|
)
|
2021-11-10 22:28:44 -03:00
|
|
|
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2021-11-10 22:28:44 -03:00
|
|
|
# Process options #
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2021-11-10 22:28:44 -03:00
|
|
|
process_options()
|
|
|
|
|
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2021-11-10 22:28:44 -03:00
|
|
|
# Add subdirectories #
|
2021-12-05 21:53:49 +00:00
|
|
|
# ##############################################################################
|
2021-11-10 22:28:44 -03:00
|
|
|
# Build NS3 library core
|
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
|
|
# Build NS library examples
|
|
|
|
|
add_subdirectory(examples)
|
|
|
|
|
|
|
|
|
|
# Build scratch/simulation scripts
|
|
|
|
|
add_subdirectory(scratch)
|
|
|
|
|
|
|
|
|
|
# Build test utils
|
|
|
|
|
add_subdirectory(utils)
|
|
|
|
|
|
2022-01-31 20:02:10 -03:00
|
|
|
write_lock()
|
|
|
|
|
write_configtable()
|
2022-01-26 01:53:28 -03:00
|
|
|
write_header_to_modules_map()
|
2021-11-10 22:28:44 -03:00
|
|
|
|
|
|
|
|
# Export package targets when installing
|
|
|
|
|
ns3_cmake_package()
|