diff --git a/.gitignore b/.gitignore index c625606e4..b70b0e7f3 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,10 @@ build/ /.project version.cache + +.idea/ +cmake_cache/ +cmake-build-debug/ +cmake-build-relwithdebinfo/ +cmake-build-minsizerel/ +cmake-build-release/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..6b1e02b59 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,114 @@ +# ###################################################################################################################### +# Required CMake version # +# ###################################################################################################################### +cmake_minimum_required(VERSION 3.10) + +# Use ccache if available +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + 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) +endif() + +# ###################################################################################################################### +# Project name # +# ###################################################################################################################### +project(NS3 CXX C) + +include(buildsupport/macros_and_definitions.cmake) + +set(NS3_VER 3-dev) + +# 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_PLANETLAB "Build with Planetlab support" OFF) +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_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_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) +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) +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_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) + +# 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)") + +# Scan module libraries +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) + +# ###################################################################################################################### +# Process options # +# ###################################################################################################################### +process_options() + +# ###################################################################################################################### +# Add subdirectories # +# ###################################################################################################################### +# 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) + +# Workaround for missing waf files used by test.py +generate_c4che_cachepy() +generate_buildstatus() +generate_fakewaflock() +write_fakewaf_config() + +# Export package targets when installing +ns3_cmake_package() diff --git a/Makefile b/Makefile deleted file mode 100644 index b75e1ba38..000000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Makefile wrapper for waf - -all: - ./waf - -# free free to change this part to suit your requirements -configure: - ./waf configure --enable-examples --enable-tests - -build: - ./waf build - -install: - ./waf install - -clean: - ./waf clean - -distclean: - ./waf distclean diff --git a/buildsupport/.cmake-format.txt b/buildsupport/.cmake-format.txt new file mode 100644 index 000000000..9fee199c7 --- /dev/null +++ b/buildsupport/.cmake-format.txt @@ -0,0 +1,6 @@ +format: + tab_size: 2 + line_width: 120 + dangle_parens: true + autosort: true + max_subgroups_hwrap: 3 \ No newline at end of file diff --git a/buildsupport/3rd_party/FindGTK3.cmake b/buildsupport/3rd_party/FindGTK3.cmake new file mode 100644 index 000000000..7c83c9403 --- /dev/null +++ b/buildsupport/3rd_party/FindGTK3.cmake @@ -0,0 +1,564 @@ +# * FindGTK3.cmake This module can find the GTK3 widget libraries and several of its other optional components like +# gtkmm, glade, and glademm. +# +# NOTE: If you intend to use version checking, CMake 2.6.2 or later is required. +# +# Specify one or more of the following components as you call this find module. See example below. +# +# gtk gtkmm glade glademm +# +# The following variables will be defined for your use +# +# GTK3_FOUND - Were all of your specified components found? GTK3_INCLUDE_DIRS - All include directories GTK3_LIBRARIES - +# All libraries +# +# GTK3_VERSION - The version of GTK3 found (x.y.z) GTK3_MAJOR_VERSION - The major version of GTK3 GTK3_MINOR_VERSION - +# The minor version of GTK3 GTK3_PATCH_VERSION - The patch version of GTK3 +# +# Optional variables you can define prior to calling this module: +# +# GTK3_DEBUG - Enables verbose debugging of the module GTK3_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as +# advanced GTK3_ADDITIONAL_SUFFIXES - Allows defining additional directories to search for include files +# +# ================= +# Example Usage: +# +# Call find_package() once, here are some examples to pick from: +# +# Require GTK 3.0 or later find_package(GTK3 3.0 REQUIRED gtk) +# +# if(GTK3_FOUND) include_directories(${GTK3_INCLUDE_DIRS}) add_executable(mygui mygui.cc) target_link_libraries(mygui +# ${GTK3_LIBRARIES}) endif() +# + +# ============================================================================= +# Copyright 2009 Kitware, Inc. Copyright 2008-2009 Philip Lowman Copyright 2014-2018 Ettercap +# Development Team +# +# Distributed under the OSI-approved BSD License (the "License"); see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the License for more information. +# ============================================================================= +# (To distribute this file outside of CMake, substitute the full License text for the above reference.) + +# Version 0.1 (5/13/2011) * First cut at a GTK3 version (Heavily derived from FindGTK2.cmake) + +# Version 0.2 (3/02/2018) * Run git diff against this file to see all changes +# ============================================================= +# _GTK3_GET_VERSION Internal function to parse the version number in gtkversion.h _OUT_major = Major version number +# _OUT_minor = Minor version number _OUT_micro = Micro version number _gtkversion_hdr = Header file to parse +# ============================================================= +function(_GTK3_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr) + file(READ ${_gtkversion_hdr} _contents) + if(_contents) + string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}") + + string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}") + + string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}") + if(NOT ${_OUT_major} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK3_MAJOR_VERSION!") + endif() + if(NOT ${_OUT_minor} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK3_MINOR_VERSION!") + endif() + if(NOT ${_OUT_micro} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK3_MICRO_VERSION!") + endif() + + set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE) + set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE) + set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE) + else() + message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist") + endif() +endfunction() + +# ============================================================= +# _GTK3_FIND_INCLUDE_DIR Internal function to find the GTK include directories _var = variable to set _hdr = header file +# to look for +# ============================================================= +function(_GTK3_FIND_INCLUDE_DIR _var _hdr) + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " "_GTK3_FIND_INCLUDE_DIR( ${_var} ${_hdr} )") + endif() + + set(_relatives + # If these ever change, things will break. + ${GTK3_ADDITIONAL_SUFFIXES} + glibmm-2.0 + glib-2.0 + atk-1.0 + atkmm-1.0 + cairo + cairomm-1.0 + gdk-pixbuf-2.0 + gdkmm-2.4 + giomm-2.4 + gtk-3.0 + gtkmm-2.4 + libglade-2.0 + libglademm-2.4 + harfbuzz + pango-1.0 + pangomm-1.4 + sigc++-2.2 + gtk-unix-print-2.0 + ) + + set(_suffixes) + foreach(_d ${_relatives}) + list(APPEND _suffixes ${_d}) + list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-2.0/include + endforeach() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " "include suffixes = ${_suffixes}") + endif() + + find_path( + ${_var} ${_hdr} + PATHS # On Windows, glibconfig.h is located under $PREFIX/lib/glib-2.0/include. + C:/GTK/lib/glib-2.0/include + C:/msys64/$ENV{MSYSTEM}/lib/glib-2.0 + # end + /usr/local/lib64 + /usr/local/lib + # fix for Ubuntu == 11.04 (Natty Narwhal) + /usr/lib/i386-linux-gnu/ + /usr/lib/x86_64-linux-gnu/ + # end fix for Ubuntu >= 11.10 (Oneiric Ocelot) + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + # end + /usr/lib64 + /usr + /opt/gnome + /usr/openwin + /sw + /opt/local + $ENV{GTKMM_BASEPATH} + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES ${_suffixes} include lib + ) + + if(${_var}) + set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS} ${${_var}} PARENT_SCOPE) + if(NOT GTK3_SKIP_MARK_AS_ADVANCED) + mark_as_advanced(${_var}) + endif() + endif() + +endfunction() + +# ============================================================= +# _GTK3_FIND_LIBRARY Internal function to find libraries packaged with GTK3 _var = library variable to create +# ============================================================= +function(_GTK3_FIND_LIBRARY _var _lib _expand_vc _append_version) + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )" + ) + endif() + + # Not GTK versions per se but the versions encoded into Windows import libraries (GtkMM 2.14.1 has a + # gtkmm-vc80-2_4.lib for example) Also the MSVC libraries use _ for . (this is handled below) + # ********* SOMEONE WITH WINDOWS NEEDS TO CHECK THIS BIT FOR V3 ********* + # ********* the plain 3 is needed to get Debian Sid to find the libraries + set(_versions + 3.0 + 3 + 2.20 + 2.18 + 2.16 + 2.14 + 2.12 + 2.10 + 2.8 + 2.6 + 2.4 + 2.2 + 2.0 + 1.20 + 1.18 + 1.16 + 1.14 + 1.12 + 1.10 + 1.8 + 1.6 + 1.4 + 1.2 + 1.0 + ) + + set(_library) + set(_library_d) + + set(_library ${_lib}) + + if(_expand_vc AND MSVC) + # Add vc80/vc90/vc100 midfixes + if(MSVC80) + set(_library ${_library}-vc80) + elseif(MSVC90) + set(_library ${_library}-vc90) + elseif(MSVC10) + set(_library ${_library}-vc100) + endif() + set(_library_d ${_library}-d) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "After midfix addition = ${_library} and ${_library_d}" + ) + endif() + + set(_lib_list) + set(_libd_list) + if(_append_version) + foreach(_ver ${_versions}) + list(APPEND _lib_list "${_library}-${_ver}") + list(APPEND _libd_list "${_library_d}-${_ver}") + endforeach() + else() + set(_lib_list ${_library}) + set(_libd_list ${_library_d}) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "library list = ${_lib_list} and library debug list = ${_libd_list}" + ) + endif() + + # For some silly reason the MSVC libraries use _ instead of . in the version fields + if(_expand_vc AND MSVC) + set(_no_dots_lib_list) + set(_no_dots_libd_list) + foreach(_l ${_lib_list}) + string(REPLACE "." "_" _no_dots_library ${_l}) + list(APPEND _no_dots_lib_list ${_no_dots_library}) + endforeach() + # And for debug + set(_no_dots_libsd_list) + foreach(_l ${_libd_list}) + string(REPLACE "." "_" _no_dots_libraryd ${_l}) + list(APPEND _no_dots_libd_list ${_no_dots_libraryd}) + endforeach() + # Copy list back to original names + set(_lib_list ${_no_dots_lib_list}) + set(_libd_list ${_no_dots_libd_list}) + endif() + + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "While searching for ${_var}, our proposed library list is ${_lib_list}" + ) + endif() + + find_library( + ${_var} + NAMES ${_lib_list} + PATHS /opt/gnome /usr/openwin /sw $ENV{GTKMM_BASEPATH} [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES lib lib64 + ) + + if(_expand_vc AND MSVC) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "While searching for ${_var}_DEBUG our proposed library list is ${_libd_list}" + ) + endif() + + find_library( + ${_var}_DEBUG + NAMES ${_libd_list} + PATHS $ENV{GTKMM_BASEPATH} [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES lib + ) + + if(${_var} AND ${_var}_DEBUG) + if(NOT GTK3_SKIP_MARK_AS_ADVANCED) + mark_as_advanced(${_var}_DEBUG) + endif() + set(GTK3_LIBRARIES ${GTK3_LIBRARIES} optimized ${${_var}} debug ${${_var}_DEBUG}) + set(GTK3_LIBRARIES ${GTK3_LIBRARIES} PARENT_SCOPE) + endif() + else() + if(NOT GTK3_SKIP_MARK_AS_ADVANCED) + mark_as_advanced(${_var}) + endif() + set(GTK3_LIBRARIES ${GTK3_LIBRARIES} ${${_var}}) + set(GTK3_LIBRARIES ${GTK3_LIBRARIES} PARENT_SCOPE) + # Set debug to release + set(${_var}_DEBUG ${${_var}}) + set(${_var}_DEBUG ${${_var}} PARENT_SCOPE) + endif() +endfunction() + +# ============================================================= + +# +# main() +# + +set(GTK3_FOUND) +set(GTK3_INCLUDE_DIRS) +set(GTK3_LIBRARIES) + +if(NOT GTK3_FIND_COMPONENTS) + # Assume they only want GTK + set(GTK3_FIND_COMPONENTS gtk) +endif() + +# +# If not specified, enforce version number +# +if(GTK3_FIND_VERSION) + if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION) + cmake_minimum_required(VERSION 2.6.2) + endif() + set(GTK3_FAILED_VERSION_CHECK true) + if(GTK3_DEBUG) + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " "Searching for version ${GTK3_FIND_VERSION}") + endif() + _gtk3_find_include_dir(GTK3_GTK_INCLUDE_DIR gtk/gtk.h) + if(GTK3_GTK_INCLUDE_DIR) + _gtk3_get_version(GTK3_MAJOR_VERSION GTK3_MINOR_VERSION GTK3_PATCH_VERSION ${GTK3_GTK_INCLUDE_DIR}/gtk/gtkversion.h) + set(GTK3_VERSION ${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_PATCH_VERSION}) + if(GTK3_FIND_VERSION_EXACT) + if(GTK3_VERSION VERSION_EQUAL GTK3_FIND_VERSION) + set(GTK3_FAILED_VERSION_CHECK false) + endif() + else() + if(GTK3_VERSION VERSION_EQUAL GTK3_FIND_VERSION OR GTK3_VERSION VERSION_GREATER GTK3_FIND_VERSION) + set(GTK3_FAILED_VERSION_CHECK false) + endif() + endif() + else() + # If we can't find the GTK include dir, we can't do version checking + if(GTK3_FIND_REQUIRED AND NOT GTK3_FIND_QUIETLY) + message(FATAL_ERROR "Could not find GTK3 include directory") + endif() + return() + endif() + + if(GTK3_FAILED_VERSION_CHECK) + if(GTK3_FIND_REQUIRED AND NOT GTK3_FIND_QUIETLY) + if(GTK3_FIND_VERSION_EXACT) + message( + FATAL_ERROR + "GTK3 version check failed. +Version ${GTK3_VERSION} was found, \ +version ${GTK3_FIND_VERSION} is needed exactly." + ) + else() + message( + FATAL_ERROR + "GTK3 version check failed. +Version ${GTK3_VERSION} was found, \ +at least version ${GTK3_FIND_VERSION} is required" + ) + endif() + endif() + + # If the version check fails, exit out of the module here + return() + endif() +endif() + +# +# Find all components +# + +find_package(Freetype QUIET) +list(APPEND GTK3_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS}) +list(APPEND GTK3_LIBRARIES ${FREETYPE_LIBRARIES}) + +foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) + if(_GTK3_component STREQUAL "gtk") + _gtk3_find_include_dir(GTK3_GLIB_INCLUDE_DIR glib.h) + _gtk3_find_include_dir(GTK3_GLIBCONFIG_INCLUDE_DIR glibconfig.h) + _gtk3_find_library(GTK3_GLIB_LIBRARY glib false true) + + _gtk3_find_library(GTK3_GTHREAD_LIBRARY gthread false true) + + _gtk3_find_include_dir(GTK3_GOBJECT_INCLUDE_DIR gobject/gobject.h) + _gtk3_find_library(GTK3_GOBJECT_LIBRARY gobject false true) + + _gtk3_find_include_dir(GTK3_GIO_INCLUDE_DIR gio/gio.h) + _gtk3_find_library(GTK3_GIO_LIBRARY gio false true) + + _gtk3_find_include_dir(GTK3_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) + _gtk3_find_library(GTK3_GDK_PIXBUF_LIBRARY gdk_pixbuf false true) + + _gtk3_find_include_dir(GTK3_GDK_INCLUDE_DIR gdk/gdk.h) + _gtk3_find_include_dir(GTK3_GDKCONFIG_INCLUDE_DIR gdk/gdkconfig.h) + _gtk3_find_include_dir(GTK3_GTK_INCLUDE_DIR gtk/gtk.h) + + # ********* At least on Debian the gdk & gtk libraries ********* don't have the -x11 suffix. + if(UNIX) + _gtk3_find_library(GTK3_GDK_LIBRARY gdk false true) + _gtk3_find_library(GTK3_GTK_LIBRARY gtk false true) + else() + # ********* There are various gtk3 builds/packages/bundles ********* available on Windows. Some of them follow the + # ********* classic naming scheme (libs with -win32 suffix) ********* and others prefer the original names. + # ********* Because we want to support as many packages ********* as possible, we search for both naming styles. + # ********* Starting with the original names. + # ********* + # ********* Tested with both vcpkg (gtk+-3.22.19) ********* and Msys2 (gtk+-3.22.28) + _gtk3_find_library(GTK3_GDK_LIBRARY gdk false true) + _gtk3_find_library(GTK3_GTK_LIBRARY gtk false true) + _gtk3_find_library(GTK3_GDK_LIBRARY gdk-win32 false true) + _gtk3_find_library(GTK3_GTK_LIBRARY gtk-win32 false true) + endif() + + _gtk3_find_include_dir(GTK3_CAIRO_INCLUDE_DIR cairo.h) + _gtk3_find_library(GTK3_CAIRO_LIBRARY cairo false false) + + _gtk3_find_include_dir(GTK3_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + + _gtk3_find_include_dir(GTK3_PANGO_INCLUDE_DIR pango/pango.h) + _gtk3_find_library(GTK3_PANGO_LIBRARY pango false true) + + _gtk3_find_include_dir(GTK3_HARFBUZZ_INCLUDE_DIR hb.h) + + _gtk3_find_include_dir(GTK3_ATK_INCLUDE_DIR atk/atk.h) + _gtk3_find_library(GTK3_ATK_LIBRARY atk false true) + + elseif(_GTK3_component STREQUAL "gtkmm") + + _gtk3_find_include_dir(GTK3_GLIBMM_INCLUDE_DIR glibmm.h) + _gtk3_find_include_dir(GTK3_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h) + _gtk3_find_library(GTK3_GLIBMM_LIBRARY glibmm true true) + + _gtk3_find_include_dir(GTK3_GDKMM_INCLUDE_DIR gdkmm.h) + _gtk3_find_include_dir(GTK3_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h) + _gtk3_find_library(GTK3_GDKMM_LIBRARY gdkmm true true) + + _gtk3_find_include_dir(GTK3_GTKMM_INCLUDE_DIR gtkmm.h) + _gtk3_find_include_dir(GTK3_GTKMMCONFIG_INCLUDE_DIR gtkmmconfig.h) + _gtk3_find_library(GTK3_GTKMM_LIBRARY gtkmm true true) + + _gtk3_find_include_dir(GTK3_CAIROMM_INCLUDE_DIR cairomm/cairomm.h) + _gtk3_find_library(GTK3_CAIROMM_LIBRARY cairomm true true) + + _gtk3_find_include_dir(GTK3_PANGOMM_INCLUDE_DIR pangomm.h) + _gtk3_find_include_dir(GTK3_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h) + _gtk3_find_library(GTK3_PANGOMM_LIBRARY pangomm true true) + + _gtk3_find_include_dir(GTK3_SIGC++_INCLUDE_DIR sigc++/sigc++.h) + _gtk3_find_include_dir(GTK3_SIGC++CONFIG_INCLUDE_DIR sigc++config.h) + _gtk3_find_library(GTK3_SIGC++_LIBRARY sigc true true) + + _gtk3_find_include_dir(GTK3_GIOMM_INCLUDE_DIR giomm.h) + _gtk3_find_include_dir(GTK3_GIOMMCONFIG_INCLUDE_DIR giommconfig.h) + _gtk3_find_library(GTK3_GIOMM_LIBRARY giomm true true) + + _gtk3_find_include_dir(GTK3_ATKMM_INCLUDE_DIR atkmm.h) + _gtk3_find_library(GTK3_ATKMM_LIBRARY atkmm true true) + + elseif(_GTK3_component STREQUAL "glade") + + _gtk3_find_include_dir(GTK3_GLADE_INCLUDE_DIR glade/glade.h) + _gtk3_find_library(GTK3_GLADE_LIBRARY glade false true) + + elseif(_GTK3_component STREQUAL "glademm") + + _gtk3_find_include_dir(GTK3_GLADEMM_INCLUDE_DIR libglademm.h) + _gtk3_find_include_dir(GTK3_GLADEMMCONFIG_INCLUDE_DIR libglademmconfig.h) + _gtk3_find_library(GTK3_GLADEMM_LIBRARY glademm true true) + + else() + message(FATAL_ERROR "Unknown GTK3 component ${_component}") + endif() +endforeach() + +# +# Solve for the GTK3 version if we haven't already +# +if(NOT GTK3_FIND_VERSION AND GTK3_GTK_INCLUDE_DIR) + _gtk3_get_version(GTK3_MAJOR_VERSION GTK3_MINOR_VERSION GTK3_PATCH_VERSION ${GTK3_GTK_INCLUDE_DIR}/gtk/gtkversion.h) + set(GTK3_VERSION ${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_PATCH_VERSION}) + +endif() + +# +# Try to enforce components +# + +set(_GTK3_did_we_find_everything true) # This gets set to GTK3_FOUND + +include(FindPackageHandleStandardArgs) +# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) + string(TOUPPER ${_GTK3_component} _COMPONENT_UPPER) + + if(_GTK3_component STREQUAL "gtk") + find_package_handle_standard_args( + GTK3_${_COMPONENT_UPPER} + "Some or all of the gtk libraries were not found." + GTK3_GTK_LIBRARY + GTK3_GTK_INCLUDE_DIR + GTK3_GLIB_INCLUDE_DIR + GTK3_GLIBCONFIG_INCLUDE_DIR + GTK3_GLIB_LIBRARY + GTK3_GTHREAD_LIBRARY + GTK3_GDK_INCLUDE_DIR + GTK3_GDKCONFIG_INCLUDE_DIR + GTK3_GDK_LIBRARY + ) + elseif(_GTK3_component STREQUAL "gtkmm") + find_package_handle_standard_args( + GTK3_${_COMPONENT_UPPER} + "Some or all of the gtkmm libraries were not found." + GTK3_GTKMM_LIBRARY + GTK3_GTKMM_INCLUDE_DIR + GTK3_GTKMMCONFIG_INCLUDE_DIR + GTK3_GLIBMM_INCLUDE_DIR + GTK3_GLIBMMCONFIG_INCLUDE_DIR + GTK3_GLIBMM_LIBRARY + GTK3_GDKMM_INCLUDE_DIR + GTK3_GDKMMCONFIG_INCLUDE_DIR + GTK3_GDKMM_LIBRARY + ) + elseif(_GTK3_component STREQUAL "glade") + find_package_handle_standard_args( + GTK3_${_COMPONENT_UPPER} "The glade library was not found." GTK3_GLADE_LIBRARY GTK3_GLADE_INCLUDE_DIR + ) + elseif(_GTK3_component STREQUAL "glademm") + find_package_handle_standard_args( + GTK3_${_COMPONENT_UPPER} "The glademm library was not found." GTK3_GLADEMM_LIBRARY GTK3_GLADEMM_INCLUDE_DIR + GTK3_GLADEMMCONFIG_INCLUDE_DIR + ) + endif() + + if(NOT GTK3_${_COMPONENT_UPPER}_FOUND) + set(_GTK3_did_we_find_everything false) + endif() +endforeach() + +if(_GTK3_did_we_find_everything AND NOT GTK3_VERSION_CHECK_FAILED) + set(GTK3_FOUND true) +else() + # Unset our variables. + set(GTK3_FOUND false) + set(GTK3_VERSION) + set(GTK3_VERSION_MAJOR) + set(GTK3_VERSION_MINOR) + set(GTK3_VERSION_PATCH) + set(GTK3_INCLUDE_DIRS) + set(GTK3_LIBRARIES) +endif() + +if(GTK3_INCLUDE_DIRS) + list(REMOVE_DUPLICATES GTK3_INCLUDE_DIRS) +endif() diff --git a/buildsupport/3rd_party/FindHarfBuzz.cmake b/buildsupport/3rd_party/FindHarfBuzz.cmake new file mode 100644 index 000000000..b1bf64582 --- /dev/null +++ b/buildsupport/3rd_party/FindHarfBuzz.cmake @@ -0,0 +1,176 @@ +# Copyright (c) 2012, Intel Corporation Copyright (c) 2019 Sony Interactive Entertainment Inc. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +# following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions and the following +# disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the distribution. +# * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Try to find Harfbuzz include and library directories. +# +# After successful discovery, this will set for inclusion where needed: HarfBuzz_INCLUDE_DIRS - containg the HarfBuzz +# headers HarfBuzz_LIBRARIES - containg the HarfBuzz library + +#[=======================================================================[.rst: +FindHarfBuzz +-------------- + +Find HarfBuzz headers and libraries. + +Imported Targets +^^^^^^^^^^^^^^^^ + +``HarfBuzz::HarfBuzz`` + The HarfBuzz library, if found. + +``HarfBuzz::ICU`` + The HarfBuzz ICU library, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables in your project: + +``HarfBuzz_FOUND`` + true if (the requested version of) HarfBuzz is available. +``HarfBuzz_VERSION`` + the version of HarfBuzz. +``HarfBuzz_LIBRARIES`` + the libraries to link against to use HarfBuzz. +``HarfBuzz_INCLUDE_DIRS`` + where to find the HarfBuzz headers. +``HarfBuzz_COMPILE_OPTIONS`` + this should be passed to target_compile_options(), if the + target is not used for linking + +#]=======================================================================] + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz) +set(HarfBuzz_COMPILE_OPTIONS ${PC_HARFBUZZ_CFLAGS_OTHER}) +set(HarfBuzz_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION}) + +find_path( + HarfBuzz_INCLUDE_DIR + NAMES hb.h + HINTS ${PC_HARFBUZZ_INCLUDEDIR} ${PC_HARFBUZZ_INCLUDE_DIRS} + PATH_SUFFIXES harfbuzz +) + +find_library(HarfBuzz_LIBRARY NAMES ${HarfBuzz_NAMES} harfbuzz HINTS ${PC_HARFBUZZ_LIBDIR} ${PC_HARFBUZZ_LIBRARY_DIRS}) + +if(HarfBuzz_INCLUDE_DIR AND NOT HarfBuzz_VERSION) + if(EXISTS "${HarfBuzz_INCLUDE_DIR}/hb-version.h") + file(READ "${HarfBuzz_INCLUDE_DIR}/hb-version.h" _harfbuzz_version_content) + + string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\.[0-9]+\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}") + set(HarfBuzz_VERSION "${CMAKE_MATCH_1}") + endif() +endif() + +if("${HarfBuzz_FIND_VERSION}" VERSION_GREATER "${HarfBuzz_VERSION}") + message(FATAL_ERROR "Required version (" ${HarfBuzz_FIND_VERSION} ") is higher than found version (" + ${HarfBuzz_VERSION} ")" + ) +endif() + +# Find components +if(HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY) + set(_HarfBuzz_REQUIRED_LIBS_FOUND ON) + set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}") +else() + set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) + set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)") +endif() + +if("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) + pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu) + set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER}) + + find_path( + HarfBuzz_ICU_INCLUDE_DIR + NAMES hb-icu.h + HINTS ${PC_HARFBUZZ_ICU_INCLUDEDIR} ${PC_HARFBUZZ_ICU_INCLUDE_DIRS} + PATH_SUFFIXES harfbuzz + ) + + find_library( + HarfBuzz_ICU_LIBRARY NAMES ${HarfBuzz_ICU_NAMES} harfbuzz-icu HINTS ${PC_HARFBUZZ_ICU_LIBDIR} + ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} + ) + + if(HarfBuzz_ICU_LIBRARY) + if(HarfBuzz_FIND_REQUIRED_ICU) + list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}") + else() + list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}") + endif() + else() + if(HarfBuzz_FIND_REQUIRED_ICU) + set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) + list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (required)") + else() + list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (optional)") + endif() + endif() +endif() + +if(NOT HarfBuzz_FIND_QUIETLY) + if(HarfBuzz_LIBS_FOUND) + message(STATUS "Found the following HarfBuzz libraries:") + foreach(found ${HarfBuzz_LIBS_FOUND}) + message(STATUS " ${found}") + endforeach() + endif() + if(HarfBuzz_LIBS_NOT_FOUND) + message(STATUS "The following HarfBuzz libraries were not found:") + foreach(found ${HarfBuzz_LIBS_NOT_FOUND}) + message(STATUS " ${found}") + endforeach() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + HarfBuzz + FOUND_VAR HarfBuzz_FOUND + REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND + VERSION_VAR HarfBuzz_VERSION +) + +if(HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz) + add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) + set_target_properties( + HarfBuzz::HarfBuzz + PROPERTIES IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" + ) +endif() + +if(HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU) + add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) + set_target_properties( + HarfBuzz::ICU + PROPERTIES IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}" INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced(HarfBuzz_INCLUDE_DIR HarfBuzz_ICU_INCLUDE_DIR HarfBuzz_LIBRARY HarfBuzz_ICU_LIBRARY) + +if(HarfBuzz_FOUND) + set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY}) + set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR}) +endif() diff --git a/buildsupport/3rd_party/FindInt128.cmake b/buildsupport/3rd_party/FindInt128.cmake new file mode 100644 index 000000000..c41db2513 --- /dev/null +++ b/buildsupport/3rd_party/FindInt128.cmake @@ -0,0 +1,139 @@ +# # COPYRIGHT +# +# All contributions by Emanuele Ruffaldi Copyright (c) 2016-2019, E All rights reserved. +# +# All other contributions: Copyright (c) 2019, the respective contributors. All rights reserved. +# +# Each contributor holds copyright over their respective contributions. The project versioning (Git) records all such +# contribution source information. +# +# LICENSE +# +# The BSD 3-Clause License +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +# following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions and the following +# disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the distribution. +# +# * Neither the name of tiny-dnn nor the names of its contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# SOURCE: https://github.com/eruffaldi/cppPosit/blob/master/include/FindInt128.cmake +# + +# * this module looks for 128 bit integer support. It sets up the type defs in util/int128_types.hpp. Simply add +# ${INT128_FLAGS} to the compiler flags. + +include(CheckTypeSize) +include(CheckCXXSourceCompiles) + +macro(CHECK_128_BIT_HASH_FUNCTION VAR_NAME DEF_NAME) + + # message("Testing for presence of 128 bit unsigned integer hash function for ${VAR_NAME}.") + + check_cxx_source_compiles( + " + #include + #include + int main(int argc, char** argv) { + std::hash<${VAR_NAME}>()(0); + return 0; + }" + has_hash_${VAR_NAME} + ) + + if(has_hash_${VAR_NAME}) + # message("std::hash<${VAR_NAME}> defined.") + set(${DEF_NAME} 1) + else() + # message("std::hash<${VAR_NAME}> not defined.") + endif() +endmacro() + +macro(CHECK_INT128 INT128_NAME VARIABLE DEFINE_NAME) + + if(NOT INT128_FOUND) + # message("Testing for 128 bit integer support with ${INT128_NAME}.") + check_type_size("${INT128_NAME}" int128_t_${DEFINE_NAME}) + if(HAVE_int128_t_${DEFINE_NAME}) + if(int128_t_${DEFINE_NAME} EQUAL 16) + # message("Found: Enabling support for 128 bit integers using ${INT128_NAME}.") + set(INT128_FOUND 1) + check_128_bit_hash_function(${INT128_NAME} HAS_INT128_STD_HASH) + set(${VARIABLE} "${DEFINE_NAME}") + else() + # message("${INT128_NAME} has incorrect size, can't use.") + endif() + endif() + endif() +endmacro() + +macro(CHECK_UINT128 UINT128_NAME VARIABLE DEFINE_NAME) + + if(NOT UINT128_FOUND) + # message("Testing for 128 bit unsigned integer support with ${UINT128_NAME}.") + check_type_size("${UINT128_NAME}" uint128_t_${DEFINE_NAME}) + if(HAVE_uint128_t_${DEFINE_NAME}) + if(uint128_t_${DEFINE_NAME} EQUAL 16) + # message("Found: Enabling support for 128 bit integers using ${UINT128_NAME}.") + set(UINT128_FOUND 1) + check_128_bit_hash_function(${UINT128_NAME} HAS_UINT128_STD_HASH) + set(${VARIABLE} "${DEFINE_NAME}") + else() + # message("${UINT128_NAME} has incorrect size, can't use.") + endif() + endif() + endif() +endmacro() + +macro(FIND_INT128_TYPES) + + check_int128("long long" INT128_DEF "HAVEint128_as_long_long") + check_int128("int128_t" INT128_DEF "HAVEint128_t") + check_int128("__int128_t" INT128_DEF "HAVE__int128_t") + check_int128("__int128" INT128_DEF "HAVE__int128") + check_int128("int128" INT128_DEF "HAVEint128") + + if(INT128_FOUND) + set(INT128_FLAGS "-D${INT128_DEF}") + if(HAS_INT128_STD_HASH) + set(INT128_FLAGS "${INT128_FLAGS} -DHASH_FOR_INT128_DEFINED") + endif() + endif() + + check_uint128("unsigned long long" UINT128_DEF "HAVEuint128_as_u_long_long") + check_uint128("uint128_t" UINT128_DEF "HAVEuint128_t") + check_uint128("__uint128_t" UINT128_DEF "HAVE__uint128_t") + check_uint128("__uint128" UINT128_DEF "HAVE__uint128") + check_uint128("uint128" UINT128_DEF "HAVEuint128") + check_uint128("unsigned __int128_t" UINT128_DEF "HAVEunsigned__int128_t") + check_uint128("unsigned int128_t" UINT128_DEF "HAVEunsignedint128_t") + check_uint128("unsigned __int128" UINT128_DEF "HAVEunsigned__int128") + check_uint128("unsigned int128" UINT128_DEF "HAVEunsignedint128") + + if(UINT128_FOUND) + set(INT128_FLAGS "${INT128_FLAGS} -D${UINT128_DEF}") + if(HAS_UINT128_STD_HASH) + set(INT128_FLAGS "${INT128_FLAGS} -DHASH_FOR_UINT128_DEFINED") + endif() + endif() + + # MSVC doesn't support 128 bit soft operations, which is weird since they support 128 bit numbers... Clang does + # support, but didn't expose them https://reviews.llvm.org/D41813 + if(${MSVC}) + set(UINT128_FOUND False) + endif() +endmacro() diff --git a/buildsupport/3rd_party/FindSphinx.cmake b/buildsupport/3rd_party/FindSphinx.cmake new file mode 100644 index 000000000..b7e88ca4a --- /dev/null +++ b/buildsupport/3rd_party/FindSphinx.cmake @@ -0,0 +1,19 @@ +# CMake find_package() Module for Sphinx documentation generator http://sphinx-doc.org/ +# +# Example usage: +# +# find_package(Sphinx) +# +# If successful the following variables will be defined SPHINX_FOUND SPHINX_EXECUTABLE + +find_program(SPHINX_EXECUTABLE NAMES sphinx-build sphinx-build2 DOC "Path to sphinx-build executable") + +# Handle REQUIRED and QUIET arguments this will also set SPHINX_FOUND to true if SPHINX_EXECUTABLE exists +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Sphinx "Failed to locate sphinx-build executable" SPHINX_EXECUTABLE) + +# Provide options for controlling different types of output +option(SPHINX_OUTPUT_HTML "Output standalone HTML files" ON) +option(SPHINX_OUTPUT_MAN "Output man pages" ON) + +option(SPHINX_WARNINGS_AS_ERRORS "When building documentation treat warnings as errors" ON) diff --git a/buildsupport/3rd_party/netanim_cmakelists.cmake b/buildsupport/3rd_party/netanim_cmakelists.cmake new file mode 100644 index 000000000..50dae9593 --- /dev/null +++ b/buildsupport/3rd_party/netanim_cmakelists.cmake @@ -0,0 +1,185 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +find_package(Qt4 COMPONENTS QtGui QUIET) +find_package(Qt5 COMPONENTS Core Widgets PrintSupport Gui QUIET) + +if((NOT ${Qt4_FOUND}) AND (NOT ${Qt5_FOUND})) + message(FATAL_ERROR "You need Qt installed to build NetAnim") +endif() + +# Qt 4 requires these inclusions +if(NOT ${Qt5_found}) + include(${QT_USE_FILE}) + add_definitions(${QT_DEFINITIONS}) + include_directories(${QT_INCLUDES}) +endif() + +# Used by qt +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(source_files + animatormode.cpp + animatorscene.cpp + animatorview.cpp + animlink.cpp + animnode.cpp + animpacket.cpp + animpropertybrowser.cpp + animresource.cpp + animxmlparser.cpp + countertablesscene.cpp + flowmonstatsscene.cpp + flowmonxmlparser.cpp + graphpacket.cpp + interfacestatsscene.cpp + log.cpp + logqt.cpp + main.cpp + mode.cpp + netanim.cpp + packetsmode.cpp + packetsscene.cpp + packetsview.cpp + qcustomplot.cpp + qtpropertybrowser/src/fileedit.cpp + qtpropertybrowser/src/fileeditfactory.cpp + qtpropertybrowser/src/filepathmanager.cpp + qtpropertybrowser/src/qtbuttonpropertybrowser.cpp + qtpropertybrowser/src/qteditorfactory.cpp + qtpropertybrowser/src/qtgroupboxpropertybrowser.cpp + qtpropertybrowser/src/qtpropertybrowser.cpp + qtpropertybrowser/src/qtpropertybrowserutils.cpp + qtpropertybrowser/src/qtpropertymanager.cpp + qtpropertybrowser/src/qttreepropertybrowser.cpp + qtpropertybrowser/src/qtvariantproperty.cpp + resizeableitem.cpp + routingstatsscene.cpp + routingxmlparser.cpp + statsmode.cpp + statsview.cpp + table.cpp + textbubble.cpp +) + +set(header_files + abort.h + animatorconstants.h + animatormode.h + animatorscene.h + animatorview.h + animevent.h + animlink.h + animnode.h + animpacket.h + animpropertybrowser.h + animresource.h + animxmlparser.h + common.h + countertablesscene.h + flowmonstatsscene.h + flowmonxmlparser.h + graphpacket.h + interfacestatsscene.h + logqt.h + mode.h + netanim.h + packetsmode.h + packetsscene.h + packetsview.h + qcustomplot.h + qtpropertybrowser/src/QtAbstractEditorFactoryBase + qtpropertybrowser/src/QtAbstractPropertyBrowser + qtpropertybrowser/src/QtAbstractPropertyManager + qtpropertybrowser/src/QtBoolPropertyManager + qtpropertybrowser/src/QtBrowserItem + qtpropertybrowser/src/QtButtonPropertyBrowser + qtpropertybrowser/src/QtCharEditorFactory + qtpropertybrowser/src/QtCharPropertyManager + qtpropertybrowser/src/QtCheckBoxFactory + qtpropertybrowser/src/QtColorEditorFactory + qtpropertybrowser/src/QtColorPropertyManager + qtpropertybrowser/src/QtCursorEditorFactory + qtpropertybrowser/src/QtCursorPropertyManager + qtpropertybrowser/src/QtDateEditFactory + qtpropertybrowser/src/QtDatePropertyManager + qtpropertybrowser/src/QtDateTimeEditFactory + qtpropertybrowser/src/QtDateTimePropertyManager + qtpropertybrowser/src/QtDoublePropertyManager + qtpropertybrowser/src/QtDoubleSpinBoxFactory + qtpropertybrowser/src/QtEnumEditorFactory + qtpropertybrowser/src/QtEnumPropertyManager + qtpropertybrowser/src/QtFlagPropertyManager + qtpropertybrowser/src/QtFontEditorFactory + qtpropertybrowser/src/QtFontPropertyManager + qtpropertybrowser/src/QtGroupBoxPropertyBrowser + qtpropertybrowser/src/QtGroupPropertyManager + qtpropertybrowser/src/QtIntPropertyManager + qtpropertybrowser/src/QtKeySequenceEditorFactory + qtpropertybrowser/src/QtKeySequencePropertyManager + qtpropertybrowser/src/QtLineEditFactory + qtpropertybrowser/src/QtLocalePropertyManager + qtpropertybrowser/src/QtPointFPropertyManager + qtpropertybrowser/src/QtPointPropertyManager + qtpropertybrowser/src/QtProperty + qtpropertybrowser/src/QtRectFPropertyManager + qtpropertybrowser/src/QtRectPropertyManager + qtpropertybrowser/src/QtScrollBarFactory + qtpropertybrowser/src/QtSizeFPropertyManager + qtpropertybrowser/src/QtSizePolicyPropertyManager + qtpropertybrowser/src/QtSizePropertyManager + qtpropertybrowser/src/QtSliderFactory + qtpropertybrowser/src/QtSpinBoxFactory + qtpropertybrowser/src/QtStringPropertyManager + qtpropertybrowser/src/QtTimeEditFactory + qtpropertybrowser/src/QtTimePropertyManager + qtpropertybrowser/src/QtTreePropertyBrowser + qtpropertybrowser/src/QtVariantEditorFactory + qtpropertybrowser/src/QtVariantProperty + qtpropertybrowser/src/QtVariantPropertyManager + qtpropertybrowser/src/fileedit.h + qtpropertybrowser/src/fileeditfactory.h + qtpropertybrowser/src/filepathmanager.h + qtpropertybrowser/src/qtbuttonpropertybrowser.h + qtpropertybrowser/src/qteditorfactory.h + qtpropertybrowser/src/qtgroupboxpropertybrowser.h + qtpropertybrowser/src/qtpropertybrowser.h + qtpropertybrowser/src/qtpropertybrowserutils_p.h + qtpropertybrowser/src/qtpropertymanager.h + qtpropertybrowser/src/qttreepropertybrowser.h + qtpropertybrowser/src/qtvariantproperty.h + resizeableitem.h + routingstatsscene.h + routingxmlparser.h + statisticsconstants.h + statsmode.h + statsview.h + table.h + textbubble.h + timevalue.h +) + +set(resource_files resources.qrc qtpropertybrowser/src/qtpropertybrowser.qrc) + +add_executable(netanim ${source_files} ${resource_files}) + +if(Qt4_FOUND) + target_link_libraries(netanim PUBLIC ${libcore} Qt4::QtGui) +else() + target_link_libraries(netanim PUBLIC ${libcore} Qt5::Widgets Qt5::Core Qt5::PrintSupport Qt5::Gui) +endif() + +target_include_directories(netanim PUBLIC qtpropertybrowser/src) +set_runtime_outputdirectory(netanim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin) diff --git a/buildsupport/Config.cmake.in b/buildsupport/Config.cmake.in new file mode 100644 index 000000000..077c99a48 --- /dev/null +++ b/buildsupport/Config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/ns3Targets.cmake") \ No newline at end of file diff --git a/buildsupport/config-store-config-template.h b/buildsupport/config-store-config-template.h new file mode 100644 index 000000000..ca3e26cd5 --- /dev/null +++ b/buildsupport/config-store-config-template.h @@ -0,0 +1,10 @@ +#ifndef NS3_CONFIG_STORE_CONFIG_H +#define NS3_CONFIG_STORE_CONFIG_H + +#cmakedefine PYTHONDIR "@PYTHONDIR@" +#cmakedefine PYTHONARCHDIR "@PYTHONARCHDIR@" +#cmakedefine HAVE_PYEMBED +#cmakedefine HAVE_PYEXT +#cmakedefine HAVE_PYTHON_H + +#endif //NS3_CONFIG_STORE_CONFIG_H diff --git a/buildsupport/core-config-template.h b/buildsupport/core-config-template.h new file mode 100644 index 000000000..7269a92d3 --- /dev/null +++ b/buildsupport/core-config-template.h @@ -0,0 +1,21 @@ +#ifndef NS3_CORE_CONFIG_H +#define NS3_CORE_CONFIG_H + +#cmakedefine HAVE_UINT128_T +#cmakedefine01 HAVE___UINT128_T +#cmakedefine INT64X64_USE_128 +#cmakedefine INT64X64_USE_DOUBLE +#cmakedefine INT64X64_USE_CAIRO +#cmakedefine01 HAVE_STDINT_H +#cmakedefine01 HAVE_INTTYPES_H +#cmakedefine HAVE_SYS_INT_TYPES_H +#cmakedefine01 HAVE_SYS_TYPES_H +#cmakedefine01 HAVE_SYS_STAT_H +#cmakedefine01 HAVE_DIRENT_H +#cmakedefine01 HAVE_STDLIB_H +#cmakedefine01 HAVE_GETENV +#cmakedefine01 HAVE_SIGNAL_H +#cmakedefine HAVE_PTHREAD_H +#cmakedefine HAVE_RT + +#endif //NS3_CORE_CONFIG_H diff --git a/buildsupport/custom_modules/ns3_cmake_package.cmake b/buildsupport/custom_modules/ns3_cmake_package.cmake new file mode 100644 index 000000000..4109d61fd --- /dev/null +++ b/buildsupport/custom_modules/ns3_cmake_package.cmake @@ -0,0 +1,48 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +macro(ns3_cmake_package) + install(EXPORT ns3ExportTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ns3 FILE ns3Targets.cmake) + + include(CMakePackageConfigHelpers) + configure_package_config_file( + "buildsupport/Config.cmake.in" "ns3Config.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ns3 + PATH_VARS CMAKE_INSTALL_LIBDIR + ) + + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/ns3ConfigVersion.cmake VERSION ${NS3_VER} COMPATIBILITY ExactVersion + ) + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ns3Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ns3ConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ns3 + ) + + install(DIRECTORY ${CMAKE_HEADER_OUTPUT_DIRECTORY} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + # Hack to get the install_manifest.txt file before finishing the installation, which we can then install along with + # ns3 to make uninstallation trivial + set(sep "/") + install( + CODE "string(REPLACE \";\" \"\\n\" MY_CMAKE_INSTALL_MANIFEST_CONTENT \"\$\{CMAKE_INSTALL_MANIFEST_FILES\}\")\n\ + string(REPLACE \"/\" \"${sep}\" MY_CMAKE_INSTALL_MANIFEST_CONTENT_FINAL \"\$\{MY_CMAKE_INSTALL_MANIFEST_CONTENT\}\")\n\ + file(WRITE manifest.txt \"\$\{MY_CMAKE_INSTALL_MANIFEST_CONTENT_FINAL\}\")" + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.txt DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ns3) +endmacro() + +# You will need administrative privileges to run this +add_custom_target( + uninstall COMMAND rm -R `cat ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/ns3/manifest.txt` && rm -R + ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/ns3 && rm -R ${CMAKE_INSTALL_FULL_INCLUDEDIR}/ns3 +) diff --git a/buildsupport/custom_modules/ns3_contributions.cmake b/buildsupport/custom_modules/ns3_contributions.cmake new file mode 100644 index 000000000..93dc42e2f --- /dev/null +++ b/buildsupport/custom_modules/ns3_contributions.cmake @@ -0,0 +1,46 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +macro(process_contribution contribution_list) + # Create handles to reference contrib libraries + foreach(libname ${contribution_list}) + library_target_name(${libname} targetname) + set(lib${libname} ${targetname} CACHE INTERNAL "") + set(lib${libname}-obj ${targetname}-obj CACHE INTERNAL "") + endforeach() + + # Add contribution folders to be built + foreach(contribname ${contribution_list}) + add_subdirectory("contrib/${contribname}") + endforeach() +endmacro() + +# cmake-format: off +macro( + build_contrib_example + name + source_files + header_files + libraries_to_link +) + # cmake-format: on + build_lib_example_impl( + "contrib/${contribname}" "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + ) +endmacro() + +macro(build_contrib_lib name source_files header_files libraries_to_link test_sources) + build_lib_impl( + "contrib" "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}" + ) +endmacro() diff --git a/buildsupport/custom_modules/ns3_coverage.cmake b/buildsupport/custom_modules/ns3_coverage.cmake new file mode 100644 index 000000000..d72eabb32 --- /dev/null +++ b/buildsupport/custom_modules/ns3_coverage.cmake @@ -0,0 +1,44 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +if(${NS3_COVERAGE}) + + find_program(GCOVp gcov) + if(GCOVp) + add_definitions(--coverage) + link_libraries(-lgcov) + endif() + + find_program(LCOVp lcov) + if(NOT LCOVp) + message(FATAL_ERROR "LCOV is required but it is not installed.") + endif() + + if(${NS3_COVERAGE_ZERO_COUNTERS}) + set(zero_counters "--lcov-zerocounters") + endif() + # The following target will run test.py --nowaf to generate the code coverage files .gcno and .gcda output will be in + # ${CMAKE_BINARY_DIR} a.k.a. cmake_cache or cmake-build-${build_suffix} + + # Create output directory for coverage info and html + file(MAKE_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/coverage) + + # Extract code coverage results and build html report + add_custom_target( + coverage_gcc + COMMAND lcov -o ns3.info -c --directory ${CMAKE_BINARY_DIR} ${zero_counters} + COMMAND genhtml ns3.info + WORKING_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/coverage + DEPENDS run_test_py + ) +endif() diff --git a/buildsupport/custom_modules/ns3_module_macros.cmake b/buildsupport/custom_modules/ns3_module_macros.cmake new file mode 100644 index 000000000..ebcffabf3 --- /dev/null +++ b/buildsupport/custom_modules/ns3_module_macros.cmake @@ -0,0 +1,386 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +# cmake-format: off +# +# This macro processes a ns-3 module +# +# Arguments: +# folder = src or contrib/contributor_module +# libname = core, wifi, contributor_module +# source_files = "list;of;.cc;files;" +# header_files = "list;of;public;.h;files;" +# libraries_to_link = "list;of;${library_names};" +# test_sources = "list;of;.cc;test;files;" +# +# Hidden argument (this is not a function, so you don't really need to pass arguments explicitly) +# deprecated_header_files = "list;of;deprecated;.h;files", copy won't get triggered if deprecated_header_files isn't set +# ignore_pch = TRUE or FALSE, prevents the PCH from including undesired system libraries (e.g. custom GLIBC for DCE) + + +macro( + build_lib_impl + folder + libname + source_files + header_files + libraries_to_link + test_sources + #deprecated_header_files + #ignore_pch +) + # cmake-format: on + message(STATUS "Processing ${folder}/${libname}") + + # Add library to a global list of libraries + if("${folder}" MATCHES "src") + set(ns3-libs "${lib${libname}};${ns3-libs}" CACHE INTERNAL "list of processed upstream modules") + else() + set(ns3-contrib-libs "${lib${libname}};${ns3-contrib-libs}" CACHE INTERNAL "list of processed contrib modules") + endif() + + if(NOT ${XCODE}) + # Create object library with sources and headers, that will be used in lib-ns3-static and the shared library + add_library(${lib${libname}-obj} OBJECT "${source_files}" "${header_files}") + + if(${NS3_PRECOMPILE_HEADERS} AND (NOT ${ignore_pch})) + target_precompile_headers(${lib${libname}-obj} REUSE_FROM stdlib_pch) + endif() + + # Create shared library with previously created object library (saving compilation time for static libraries) + add_library(${lib${libname}} SHARED $) + else() + # Xcode and CMake don't play well when using object libraries, so we have a specific path for that + add_library(${lib${libname}} SHARED "${source_files}") + + if(${NS3_PRECOMPILE_HEADERS} AND (NOT ${ignore_pch})) + target_precompile_headers(${lib${libname}} REUSE_FROM stdlib_pch) + endif() + endif() + + if(${NS3_CLANG_TIMETRACE}) + add_dependencies(timeTraceReport ${lib${libname}}) + endif() + + # Split ns and non-ns libraries to manage their propagation properly + set(non_ns_libraries_to_link) + set(ns_libraries_to_link) + + foreach(library ${libraries_to_link}) + # Remove lib prefix from module name (e.g. libcore -> core) + string(REPLACE "lib" "" module_name "${library}") + if(${module_name} IN_LIST ns3-all-modules) + list(APPEND ns_libraries_to_link ${library}) + else() + list(APPEND non_ns_libraries_to_link ${library}) + endif() + unset(module_name) + endforeach() + + # ns-3 libraries are linked publicly, to make sure other modules can find each other without being directly linked + target_link_libraries(${lib${libname}} PUBLIC ${LIB_AS_NEEDED_PRE} "${ns_libraries_to_link}" ${LIB_AS_NEEDED_POST}) + + # non-ns-3 libraries are linked privately, not propagating unnecessary libraries such as pthread, librt, etc + target_link_libraries( + ${lib${libname}} PRIVATE ${LIB_AS_NEEDED_PRE} "${non_ns_libraries_to_link}" ${LIB_AS_NEEDED_POST} + ) + + # set output name of library + set_target_properties(${lib${libname}} PROPERTIES OUTPUT_NAME ns${NS3_VER}-${libname}${build_profile_suffix}) + + if(${NS3_STATIC} OR ${NS3_MONOLIB}) + set(ns3-external-libs "${non_ns_libraries_to_link};${ns3-external-libs}" + CACHE INTERNAL "list of non-ns libraries to link to NS3_STATIC and NS3_MONOLIB" + ) + set(lib-ns3-static-objs "$;${lib-ns3-static-objs}" + CACHE INTERNAL "list of object files from module used by NS3_STATIC and NS3_MONOLIB" + ) + endif() + + # Write a module header that includes all headers from that module + write_module_header("${libname}" "${header_files}") + + # Copy all header files to outputfolder/include before each build + copy_headers_before_building_lib(${libname} ${CMAKE_HEADER_OUTPUT_DIRECTORY} "${header_files}" public) + if(deprecated_header_files) + copy_headers_before_building_lib( + ${libname} ${CMAKE_HEADER_OUTPUT_DIRECTORY} "${deprecated_header_files}" deprecated + ) + endif() + + # Build tests if requested + if(${NS3_TESTS}) + list(LENGTH test_sources test_source_len) + if(${test_source_len} GREATER 0) + # Create libname of output library test of module + set(test${libname} test-lib${libname} CACHE INTERNAL "") + set(ns3-libs-tests "${test${libname}};${ns3-libs-tests}" CACHE INTERNAL "list of test libraries") + + # Create shared library containing tests of the module + add_library(${test${libname}} SHARED "${test_sources}") + + # Link test library to the module library + if(${NS3_MONOLIB}) + target_link_libraries(${test${libname}} ${LIB_AS_NEEDED_PRE} ${lib-ns3-monolib} ${LIB_AS_NEEDED_POST}) + else() + target_link_libraries( + ${test${libname}} ${LIB_AS_NEEDED_PRE} ${lib${libname}} "${libraries_to_link}" ${LIB_AS_NEEDED_POST} + ) + endif() + set_target_properties( + ${test${libname}} PROPERTIES OUTPUT_NAME ns${NS3_VER}-${libname}-test${build_profile_suffix} + ) + + target_compile_definitions(${test${libname}} PRIVATE NS_TEST_SOURCEDIR="${folder}/${libname}/test") + if(${NS3_PRECOMPILE_HEADERS} AND (NOT ${ignore_pch})) + target_precompile_headers(${test${libname}} REUSE_FROM stdlib_pch) + endif() + endif() + endif() + + # Build lib examples if requested + if(${NS3_EXAMPLES}) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples) + add_subdirectory(examples) + endif() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/example) + add_subdirectory(example) + endif() + endif() + + # Get architecture pair for python bindings + set(arch gcc_ILP32) + set(arch_flag) + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(arch gcc_LP64) + set(arch_flag -m64) + endif() + + # Add target to scan python bindings + if(${NS3_SCAN_PYTHON_BINDINGS} AND EXISTS ${CMAKE_HEADER_OUTPUT_DIRECTORY}/${libname}-module.h) + set(bindings_output_folder ${PROJECT_SOURCE_DIR}/${folder}/${libname}/bindings) + file(MAKE_DIRECTORY ${bindings_output_folder}) + set(module_api ${bindings_output_folder}/modulegen__${arch}.py) + + set(modulescan_modular_command ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bindings/python/ns3modulescan-modular.py) + + # To build the header map for the module, we start by copying the headers and prepending the dictionary start + set(header_map "{\\\"${header_files};") + + # We then remove model/ helper/ prefixes e.g. {'model/angles.h;model/antenna-model.h;... -> + # {'angles.h;antenna-model.h;...) + string(REPLACE "model/" "" header_map "${header_map}") + string(REPLACE "helper/" "" header_map "${header_map}") + + # Now we replace list entry separators (;) with ending of the string quote ("), followed by the relative module e.g. + # {"model/angles.h;model/antenna-model.h;... -> {"angles.h" : "antenna", "antenna-model.h": "antenna", "...) + string(REPLACE ";" "\\\": \\\"${libname}\\\", \\\"" header_map "${header_map}") + + # We now remove the last character ("), which needs to be replaced with a (}), to close the dictionary e.g. + # "antenna-model.h" : "antenna", " -> "antenna-model.h" : "antenna" + string(LENGTH "${header_map}" header_map_len) + math(EXPR header_map_len "${header_map_len}-3") + string(SUBSTRING "${header_map}" 0 ${header_map_len} header_map) + + # Append end of dictionary (}) + string(APPEND header_map "}") + + add_custom_target( + apiscan-${lib${libname}} + COMMAND ${modulescan_modular_command} ${CMAKE_OUTPUT_DIRECTORY} ${libname} ${header_map} ${module_api} + ${arch_flag} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${lib${libname}} + ) + add_dependencies(apiscan-all apiscan-${lib${libname}}) + endif() + + # Build pybindings if requested and if bindings subfolder exists in NS3/src/libname + if(${NS3_PYTHON_BINDINGS} AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/bindings") + set(bindings_output_folder ${CMAKE_OUTPUT_DIRECTORY}/${folder}/${libname}/bindings) + file(MAKE_DIRECTORY ${bindings_output_folder}) + set(module_src ${bindings_output_folder}/ns3module.cc) + set(module_hdr ${bindings_output_folder}/ns3module.h) + + string(REPLACE "-" "_" libname_sub ${libname}) # '-' causes problems (e.g. csma-layout), replace with '_' (e.g. + # csma_layout) + + # Set prefix of binding to _ if a ${libname}.py exists, and copy the ${libname}.py to the output folder + set(prefix) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/bindings/${libname}.py) + set(prefix _) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/${libname}.py + DESTINATION ${CMAKE_OUTPUT_DIRECTORY}/bindings/python/ns + ) + endif() + + # Run modulegen-modular to generate the bindings sources + if((NOT EXISTS ${module_hdr}) OR (NOT EXISTS ${module_src})) # OR TRUE) # to force reprocessing + string(REPLACE ";" "," ENABLED_FEATURES "${ns3-libs}") + set(modulegen_modular_command GCC_RTTI_ABI_COMPLETE=True NS3_ENABLED_FEATURES="${ENABLED_FEATURES}" + ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bindings/python/ns3modulegen-modular.py + ) + execute_process( + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_OUTPUT_DIRECTORY} ${modulegen_modular_command} + ${CMAKE_CURRENT_SOURCE_DIR} ${arch} ${prefix}${libname_sub} ${module_src} + TIMEOUT 60 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_FILE ${module_hdr} + ERROR_FILE ${bindings_output_folder}/ns3modulegen.log + RESULT_VARIABLE error_code + ) + if(${error_code} OR NOT (EXISTS ${module_hdr})) + message( + FATAL_ERROR "Something went wrong during processing of the python bindings of module ${libname}." + " Make sure the correct versions of Pybindgen and Pygccxml are installed (use the pip ones)." + ) + if(EXISTS ${module_src}) + file(REMOVE ${module_src}) + endif() + endif() + endif() + + # Add core module helper sources + set(python_module_files ${module_hdr} ${module_src}) + if(${libname} STREQUAL "core") + list(APPEND python_module_files ${CMAKE_CURRENT_SOURCE_DIR}/bindings/module_helpers.cc + ${CMAKE_CURRENT_SOURCE_DIR}/bindings/scan-header.h + ) + endif() + add_library(${libname}-bindings SHARED "${python_module_files}") + target_include_directories(${libname}-bindings PUBLIC ${Python3_INCLUDE_DIRS} ${bindings_output_folder}) + + # If there is any, remove the "lib" prefix of libraries (search for "set(lib${libname}") + list(LENGTH ns_libraries_to_link num_libraries) + if(num_libraries GREATER "0") + string(REPLACE ";" "-bindings;" bindings_to_link "${ns_libraries_to_link};") # add -bindings suffix to all + # lib${name} + string(REPLACE "lib" "" bindings_to_link "${bindings_to_link}") # remove lib prefix from all lib${name}-bindings + endif() + target_link_libraries( + ${libname}-bindings PUBLIC ${LIB_AS_NEEDED_PRE} ${lib${libname}} "${bindings_to_link}" "${libraries_to_link}" + ${LIB_AS_NEEDED_POST} + ) + target_include_directories(${libname}-bindings PRIVATE ${PROJECT_SOURCE_DIR}/src/core/bindings) + + # Set binding library name and output folder + set_target_properties( + ${libname}-bindings PROPERTIES OUTPUT_NAME ${prefix}${libname_sub} PREFIX "" + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/bindings/python/ns + ) + + set(ns3-python-bindings-modules "${libname}-bindings;${ns3-python-bindings-modules}" + CACHE INTERNAL "list of modules python bindings" + ) + + # Make sure all bindings are built before building the visualizer module that makes use of them + if(NOT (${name} STREQUAL visualizer)) + add_dependencies(${libvisualizer} ${libname}-bindings) + endif() + endif() + + # Handle package export + install(TARGETS ${lib${name}} EXPORT ns3ExportTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endmacro() + +# cmake-format: off +# +# This macro processes a ns-3 module example +# +# Arguments: folder = src or contrib/contributor_module libname = core, wifi, contributor_module (this is implicit, as +# it is called by build_lib_impl) +# name = example name (e.g. command-line-example) +# source_files = "cmake;list;of;.cc;files;" +# header_files = "cmake;list;of;public;.h;files;" +# libraries_to_link = "cmake;list;of;${library_names};" +# +macro( + build_lib_example_impl + folder + name + source_files + header_files + libraries_to_link +) + # cmake-format: on + set(missing_dependencies FALSE) + foreach(lib ${libraries_to_link}) + string(REPLACE "lib" "" lib ${lib}) + if(NOT (${lib} IN_LIST ns3-all-modules)) + set(missing_dependencies TRUE) + endif() + endforeach() + + if(NOT missing_dependencies) + # Create shared library with sources and headers + add_executable(${name} "${source_files}" "${header_files}") + + if(${NS3_STATIC}) + target_link_libraries(${name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-ns3-static}) + elseif(${NS3_MONOLIB}) + target_link_libraries(${name} ${LIB_AS_NEEDED_PRE} ${lib-ns3-monolib} ${LIB_AS_NEEDED_POST}) + else() + target_link_libraries( + ${name} ${LIB_AS_NEEDED_PRE} ${lib${libname}} ${libraries_to_link} ${optional_visualizer_lib} + ${LIB_AS_NEEDED_POST} + ) + endif() + + if(${NS3_PRECOMPILE_HEADERS} AND (NOT ${ignore_pch})) + target_precompile_headers(${name} REUSE_FROM stdlib_pch_exec) + endif() + + set_runtime_outputdirectory(${name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${folder}/examples/) + endif() +endmacro() + +# This macro processes a ns-3 module header file (module_name-module.h) +# +# Arguments: name = module name (e.g. core, wifi) header_files = "cmake;list;of;public;.h;files;" +macro(write_module_header name header_files) + string(TOUPPER ${name} uppercase_name) + string(REPLACE "-" "_" final_name ${uppercase_name}) + # Common module_header + list(APPEND contents "#ifdef NS3_MODULE_COMPILATION ") + list( + APPEND + contents + " + error \"Do not include ns3 module aggregator headers from other modules; these are meant only for end user scripts.\" " + ) + list(APPEND contents " +#endif " + ) + list(APPEND contents " +#ifndef NS3_MODULE_" + ) + list(APPEND contents ${final_name}) + list(APPEND contents " + // Module headers: " + ) + + # Write each header listed to the contents variable + foreach(header ${header_files}) + get_filename_component(head ${header} NAME) + list(APPEND contents " + #include " + ) + # include \"ns3/${head}\"") + endforeach() + + # Common module footer + list(APPEND contents " +#endif " + ) + file(WRITE ${CMAKE_HEADER_OUTPUT_DIRECTORY}/${name}-module.h ${contents}) +endmacro() diff --git a/buildsupport/custom_modules/ns3_versioning.cmake b/buildsupport/custom_modules/ns3_versioning.cmake new file mode 100644 index 000000000..a2207b608 --- /dev/null +++ b/buildsupport/custom_modules/ns3_versioning.cmake @@ -0,0 +1,53 @@ +# Determine if the git repository is an ns-3 repository +# +# A repository is considered an ns-3 repository if it has at least one tag that matches the regex ns-3* + +function(check_git_repo_has_ns3_tags HAS_TAGS GIT_VERSION_TAG) + execute_process(COMMAND ${GIT} describe --tags --abbrev=0 --match ns-3.[0-9]* OUTPUT_VARIABLE GIT_TAG_OUTPUT) + + string(REPLACE "\r" "" GIT_TAG_OUTPUT ${GIT_TAG_OUTPUT}) # remove CR (carriage return) + string(REPLACE "\n" "" GIT_TAG_OUTPUT ${GIT_TAG_OUTPUT}) # remove LF (line feed) + + # Check if tag exists and return values to the caller + string(LENGTH GIT_TAG_OUTPUT GIT_TAG_OUTPUT_LEN) + set(${HAS_TAGS} FALSE PARENT_SCOPE) + set(${GIT_VERSION_TAG} "" PARENT_SCOPE) + if(${GIT_TAG_OUTPUT_LEN} GREATER "0") + set(${HAS_TAGS} TRUE PARENT_SCOPE) + set(${GIT_VERSION_TAG} ${GIT_TAG_OUTPUT} PARENT_SCOPE) + endif() +endfunction() + +# Function to generate version fields from an ns-3 git repository +function(check_ns3_closest_tags CLOSEST_TAG VERSION_TAG_DISTANCE VERSION_COMMIT_HASH VERSION_DIRTY_FLAG) + execute_process(COMMAND ${GIT} describe --tags --dirty --long OUTPUT_VARIABLE GIT_TAG_OUTPUT) + + string(REPLACE "\r" "" GIT_TAG_OUTPUT ${GIT_TAG_OUTPUT}) # remove CR (carriage return) + string(REPLACE "\n" "" GIT_TAG_OUTPUT ${GIT_TAG_OUTPUT}) # remove LF (line feed) + + # Split ns-3..(-RC)-distance-commit(-dirty) into a list + # ns;3..;(RC + +function(generate_buildstatus) + # Build build-status.py file consumed by test.py + set(buildstatus_contents "#! /usr/bin/env python3\n\n") + string(APPEND buildstatus_contents "ns3_runnable_programs = [") + + foreach(executable ${ns3-execs}) + string(APPEND buildstatus_contents "'${executable}', ") + endforeach() + string(APPEND buildstatus_contents "]\n\n") + + string(APPEND buildstatus_contents "ns3_runnable_scripts = [") # missing support + string(APPEND buildstatus_contents "]\n\n") + + file(WRITE ${CMAKE_OUTPUT_DIRECTORY}/build-status.py "${buildstatus_contents}") +endfunction(generate_buildstatus) diff --git a/buildsupport/custom_modules/waf_workaround_c4cache.cmake b/buildsupport/custom_modules/waf_workaround_c4cache.cmake new file mode 100644 index 000000000..b8c2500fa --- /dev/null +++ b/buildsupport/custom_modules/waf_workaround_c4cache.cmake @@ -0,0 +1,75 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +function(cache_cmake_flag cmake_flag cache_entry output_string) + if(${${cmake_flag}}) + set(${output_string} "${${output_string}}${cache_entry} = True\n" PARENT_SCOPE) + else() + set(${output_string} "${${output_string}}${cache_entry} = False\n" PARENT_SCOPE) + endif() +endfunction(cache_cmake_flag) + +function(generate_c4che_cachepy) + # Build _cache.py file consumed by test.py + set(cache_contents "") + + string(APPEND cache_contents "NS3_ENABLED_MODULES = [") + foreach(module_library ${ns3-libs}) # fetch core module libraries + string(APPEND cache_contents "'") + string(REPLACE "lib" "" module_name ${module_library}) # lib${libname} into libname + string(APPEND cache_contents "ns3-${module_name}', ") + endforeach() + string(APPEND cache_contents "]\n") + + string(APPEND cache_contents "NS3_ENABLED_CONTRIBUTED_MODULES = [") + foreach(module_library ${ns3-contrib-libs}) # fetch core module libraries + string(APPEND cache_contents "'") + string(REPLACE "lib" "" module_name ${module_library}) # lib${libname} into libname + string(APPEND cache_contents "ns3-${module_name}', ") + endforeach() + string(APPEND cache_contents "]\n") + + string(REPLACE ":" "', '" PATH_LIST $ENV{PATH}) + string(APPEND cache_contents + "NS3_MODULE_PATH = ['${PATH_LIST}', '${CMAKE_OUTPUT_DIRECTORY}', '${CMAKE_LIBRARY_OUTPUT_DIRECTORY}']\n" + ) + + cache_cmake_flag(NS3_NSC "NSC_ENABLED" cache_contents) # missing support + cache_cmake_flag(ENABLE_REALTIME "ENABLE_REAL_TIME" cache_contents) + cache_cmake_flag(NS3_PTHREAD "ENABLE_THREADING" cache_contents) + cache_cmake_flag(NS3_EXAMPLES "ENABLE_EXAMPLES" cache_contents) + cache_cmake_flag(NS3_TESTS "ENABLE_TESTS" cache_contents) + cache_cmake_flag(NS3_OPENFLOW "ENABLE_OPENFLOW" cache_contents) + cache_cmake_flag(NS3_CLICK "NSCLICK" cache_contents) + cache_cmake_flag(NS3_BRITE "ENABLE_BRITE" cache_contents) + cache_cmake_flag(NS3_PYTHON_BINDINGS "ENABLE_PYTHON_BINDINGS" cache_contents) + + string(APPEND cache_contents "EXAMPLE_DIRECTORIES = [") + foreach(example_folder ${ns3-example-folders}) + string(APPEND cache_contents "'${example_folder}', ") + endforeach() + string(APPEND cache_contents "]\n") + + string(APPEND cache_contents "APPNAME = 'ns'\n") + string(APPEND cache_contents "BUILD_PROFILE = '${build_profile}'\n") + string(APPEND cache_contents "VERSION = '3-dev' \n") + string(APPEND cache_contents "PYTHON = ['${Python3_EXECUTABLE}']\n") + + find_program(VALGRIND valgrind) + if("${VALGRIND}" STREQUAL "VALGRIND-NOTFOUND") + string(APPEND cache_contents "VALGRIND_FOUND = False \n") + else() + string(APPEND cache_contents "VALGRIND_FOUND = True \n") + endif() + file(WRITE ${CMAKE_OUTPUT_DIRECTORY}/c4che/_cache.py "${cache_contents}") +endfunction(generate_c4che_cachepy) diff --git a/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake b/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake new file mode 100644 index 000000000..1057e92b3 --- /dev/null +++ b/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake @@ -0,0 +1,114 @@ +# cmake-format: off +# +# A sample of what Waf currently produces + +# ---- Summary of optional NS-3 features: +# Build profile : debug +# Build directory : +# BRITE Integration : not enabled (BRITE not enabled (see option --with-brite)) +# DES Metrics event collection : not enabled (defaults to disabled) +# DPDK NetDevice : not enabled (libdpdk not found, $RTE_SDK and/or $RTE_TARGET environment variable not set or incorrect) +# Emulation FdNetDevice : enabled +# Examples : not enabled (defaults to disabled) +# File descriptor NetDevice : enabled +# GNU Scientific Library (GSL) : enabled +# Gcrypt library : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.) +# GtkConfigStore : enabled +# MPI Support : not enabled (option --enable-mpi not selected) +# NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick)) +# NS-3 OpenFlow Integration : not enabled (OpenFlow not enabled (see option --with-openflow)) +# Netmap emulation FdNetDevice : not enabled (needs net/netmap_user.h) +# Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc)) +# PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab)) +# PyViz visualizer : not enabled (Missing python modules: pygraphviz, gi.repository.GooCanvas) +# Python API Scanning Support : not enabled (castxml too old) +# Python Bindings : enabled +# Real Time Simulator : enabled +# SQLite stats support : enabled +# Tap Bridge : enabled +# Tap FdNetDevice : enabled +# Tests : not enabled (defaults to disabled) +# Threading Primitives : enabled +# Use sudo to set suid bit : not enabled (option --enable-sudo not selected) +# XmlIo : enabled +# +# cmake-format: on + +# Now the CMake part + +macro(check_on_or_off user_config_switch confirmation_flag) + if(${user_config_switch}) + if(${confirmation_flag}) + string(APPEND out "ON\n") + else() + string(APPEND out "OFF (not found)\n") + endif() + else() + string(APPEND out "OFF\n") + endif() +endmacro() + +macro(write_fakewaf_config) + set(out "---- Summary of optional NS-3 features:\n") + string(APPEND out "Build profile : ${build_profile}\n") + string(APPEND out "Build directory : ${CMAKE_OUTPUT_DIRECTORY}\n") + string(APPEND out "BRITE Integration : ") + check_on_or_off("ON" "${NS3_BRITE}") + + string(APPEND out "DES Metrics event collection : ${NS3_DES_METRICS}\n") + string(APPEND out "DPDK NetDevice : ") + check_on_or_off("ON" "${ENABLE_DPDKDEVNET}") + + string(APPEND out "Emulation FdNetDevice : ") + check_on_or_off("${NS3_EMU}" "${ENABLE_EMU}") + + string(APPEND out "Examples : ${NS3_EXAMPLES}\n") + string(APPEND out "File descriptor NetDevice : ") + check_on_or_off("ON" "${ENABLE_FDNETDEV}") + + string(APPEND out "GNU Scientific Library (GSL) : ") + check_on_or_off("${NS3_GSL}" "${GSL_FOUND}") + + # string(APPEND out "Gcrypt library : not enabled (libgcrypt not found: you can use libgcrypt-config to + # find its location.) + + string(APPEND out "GtkConfigStore : ") + check_on_or_off("${NS3_GTK3}" "${GTK3_FOUND}") + + string(APPEND out "MPI Support : ") + check_on_or_off("${NS3_MPI}" "${MPI_FOUND}") + + string(APPEND out "NS-3 Click Integration : ") + check_on_or_off("ON" "${NS3_CLICK}") + + string(APPEND out "NS-3 OpenFlow Integration : ") + check_on_or_off("ON" "${NS3_OPENFLOW}") + + string(APPEND out "Netmap emulation FdNetDevice : ") + check_on_or_off("${NS3_EMU}" "${ENABLE_NETMAP_EMU}") + + string(APPEND out "Network Simulation Cradle : flag is set to ${NS3_NSC}, but currently not supported\n") + string(APPEND out "PlanetLab FdNetDevice : flag is set to ${NS3_PLANETLAB}, but currently not supported\n") + string(APPEND out "PyViz visualizer : ${NS3_VISUALIZER}\n") + # string(APPEND out "Python API Scanning Support : not enabled (castxml too old) + string(APPEND out "Python Bindings : ${NS3_PYTHON_BINDINGS}\n") + string(APPEND out "Real Time Simulator : ") + check_on_or_off("${NS3_REALTIME}" "${ENABLE_REALTIME}") + + string(APPEND out "SQLite stats support : ") + check_on_or_off("${NS3_SQLITE}" "${ENABLE_SQLITE}") + + string(APPEND out "Tap Bridge : ${NS3_TAP}\n") + string(APPEND out "Tap FdNetDevice : ") + check_on_or_off("${NS3_TAP}" "${ENABLE_TAP}") + + string(APPEND out "Tests : ${NS3_TESTS}\n") + string(APPEND out "Threading Primitives : ") + check_on_or_off("${NS3_PTHREAD}" "${THREADS_ENABLED}") + + # string(APPEND out "Use sudo to set suid bit : not enabled (option --enable-sudo not selected) string(APPEND out + # "XmlIo : enabled + + file(WRITE ${PROJECT_BINARY_DIR}/ns3wafconfig.txt ${out}) + message(STATUS ${out}) +endmacro() diff --git a/buildsupport/custom_modules/waf_workaround_lock.cmake b/buildsupport/custom_modules/waf_workaround_lock.cmake new file mode 100644 index 000000000..822f2d100 --- /dev/null +++ b/buildsupport/custom_modules/waf_workaround_lock.cmake @@ -0,0 +1,31 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +function(generate_fakewaflock) + set(fakewaflock_contents "") + string(APPEND fakewaflock_contents "launch_dir = '${PROJECT_SOURCE_DIR}'\n") + string(APPEND fakewaflock_contents "run_dir = '${PROJECT_SOURCE_DIR}'\n") + string(APPEND fakewaflock_contents "top_dir = '${PROJECT_SOURCE_DIR}'\n") + string(APPEND fakewaflock_contents "out_dir = '${CMAKE_OUTPUT_DIRECTORY}'\n") + + set(fakewaflock_filename) + if(LINUX) + set(fakewaflock_filename .lock-waf_linux_build) + elseif(APPLE) + set(fakewaflock_filename .lock-waf_darwin_build) + else() + message(FATAL_ERROR "Platform not supported") + endif() + + file(WRITE ${PROJECT_SOURCE_DIR}/${fakewaflock_filename} ${fakewaflock_contents}) +endfunction(generate_fakewaflock) diff --git a/buildsupport/empty.cc b/buildsupport/empty.cc new file mode 100644 index 000000000..e69de29bb diff --git a/buildsupport/empty_main.cc b/buildsupport/empty_main.cc new file mode 100644 index 000000000..dbbd85ecc --- /dev/null +++ b/buildsupport/empty_main.cc @@ -0,0 +1 @@ +int main(){} \ No newline at end of file diff --git a/buildsupport/iwyu_wrapper.sh b/buildsupport/iwyu_wrapper.sh new file mode 100644 index 000000000..657bfcd7f --- /dev/null +++ b/buildsupport/iwyu_wrapper.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo >>"$1"/iwyu.log include-what-you-use "${@:2}" +exec include-what-you-use "${@:2}" 2> >(tee -a "$1"/iwyu.log >&2) diff --git a/buildsupport/macros_and_definitions.cmake b/buildsupport/macros_and_definitions.cmake new file mode 100644 index 000000000..6215f04f8 --- /dev/null +++ b/buildsupport/macros_and_definitions.cmake @@ -0,0 +1,1043 @@ +# Copyright (c) 2017-2021 Universidade de Brasília +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +# License version 2 as published by the Free Software Foundation; +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Gabriel Ferreira + +# Export compile time variable setting the directory to the NS3 root folder +add_definitions(-DPROJECT_SOURCE_PATH="${PROJECT_SOURCE_DIR}") + +# Cache options for INT64X64 +set(INT64X64 "INT128" CACHE STRING "Int64x64 implementation") +set(INT64X64 "CAIRO" CACHE STRING "Int64x64 implementation") +set(INT64X64 "DOUBLE" CACHE STRING "Int64x64 implementation") +set_property(CACHE INT64X64 PROPERTY STRINGS INT128 CAIRO DOUBLE) + +# WSLv1 doesn't support tap features +if(EXISTS "/proc/version") + file(READ "/proc/version" CMAKE_LINUX_DISTRO) + string(FIND ${CMAKE_LINUX_DISTRO} "Microsoft" res) + if(res EQUAL -1) + set(WSLv1 False) + else() + set(WSLv1 True) + endif() +endif() + +# Set Linux flag if on Linux +if(UNIX AND NOT APPLE) + set(LINUX TRUE) + add_definitions(-D__LINUX__) +endif() + +if(APPLE) + add_definitions(-D__APPLE__) +endif() + +set(cat_command cat) + +if(CMAKE_XCODE_BUILD_SYSTEM) + set(XCODE True) +else() + set(XCODE False) +endif() + +# Check the number of threads +include(ProcessorCount) +ProcessorCount(NumThreads) + +# Output folders +set(CMAKE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}) +set(CMAKE_HEADER_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/include/ns3) +set(THIRD_PARTY_DIRECTORY ${PROJECT_SOURCE_DIR}/3rd-party) + +# Get installation folder default values for each platform and include package configuration macro +include(GNUInstallDirs) +include(buildsupport/custom_modules/ns3_cmake_package.cmake) + +if(${XCODE}) + # Is that so hard not to break people's CI, AAPL? Why would you output the targets to a Debug/Release subfolder? Why? + foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) + endforeach() +endif() + +# fPIC (position-independent code) and fPIE (position-independent executable) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Identify compiler +set(CLANG FALSE) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CLANG TRUE) +endif() + +set(GCC FALSE) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(GCC TRUE) +endif() + +# Set compiler options and get command to force unused function linkage (useful for libraries) +set(CXX_UNSUPPORTED_STANDARDS 98 11 14) +set(CMAKE_CXX_STANDARD_MINIMUM 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(LIB_AS_NEEDED_PRE) +set(LIB_AS_NEEDED_POST) +if(${GCC} AND NOT APPLE) + # using GCC + set(LIB_AS_NEEDED_PRE -Wl,--no-as-needed) + set(LIB_AS_NEEDED_POST -Wl,--as-needed) + set(LIB_AS_NEEDED_PRE_STATIC -Wl,--whole-archive,-Bstatic) + set(LIB_AS_NEEDED_POST_STATIC -Wl,--no-whole-archive) + set(LIB_AS_NEEDED_POST_STATIC_DYN -Wl,-Bdynamic,--no-whole-archive) +endif() + +if(${CLANG} AND APPLE) + # using Clang set(LIB_AS_NEEDED_PRE -all_load) + set(LIB_AS_NEEDED_POST) +endif() + +macro(SUBDIRLIST result curdir) + file(GLOB children RELATIVE ${curdir} ${curdir}/*) + set(dirlist "") + foreach(child ${children}) + if(IS_DIRECTORY ${curdir}/${child}) + list(APPEND dirlist ${child}) + endif() + endforeach() + set(${result} ${dirlist}) +endmacro() + +macro(library_target_name libname targetname) + set(${targetname} lib${libname}) +endmacro() + +macro(clear_global_cached_variables) + # clear cache variables + unset(build_profile CACHE) + unset(build_profile_suffix CACHE) + unset(lib-ns3-static-objs CACHE) + unset(ns3-contrib-libs CACHE) + unset(ns3-example-folders CACHE) + unset(ns3-execs CACHE) + unset(ns3-external-libs CACHE) + unset(ns3-libs CACHE) + unset(ns3-libs-tests CACHE) + unset(ns3-python-bindings-modules CACHE) +endmacro() + +# process all options passed in main cmakeLists +macro(process_options) + clear_global_cached_variables() + + # process debug switch Used in build-profile-test-suite + string(TOLOWER ${CMAKE_BUILD_TYPE} cmakeBuildType) + set(build_profile "${cmakeBuildType}" CACHE INTERNAL "") + if(${cmakeBuildType} STREQUAL "debug") + add_definitions(-DNS3_BUILD_PROFILE_DEBUG) + elseif(${cmakeBuildType} STREQUAL "relwithdebinfo") + add_definitions(-DNS3_BUILD_PROFILE_RELEASE) + elseif(${cmakeBuildType} STREQUAL "release") + add_definitions(-DNS3_BUILD_PROFILE_OPTIMIZED) + if(${NS3_NATIVE_OPTIMIZATIONS}) + set(build_profile "optimized" CACHE INTERNAL "") + endif() + else() + add_definitions(-DNS3_BUILD_PROFILE_OPTIMIZED) + endif() + + set(profiles_without_suffixes release) + set(build_profile_suffix "" CACHE INTERNAL "") + if(NOT (${build_profile} IN_LIST profiles_without_suffixes)) + set(build_profile_suffix -${build_profile} CACHE INTERNAL "") + endif() + + # Set warning level and warning as errors + if (${NS3_WARNINGS}) + if (MSVC) + add_compile_options(/W3) # /W4 = -Wall + -Wextra + if (${NS3_WARNINGS_AS_ERRORS}) + add_compile_options(/WX) + endif() + else() + add_compile_options(-Wall) # -Wextra + if (${NS3_WARNINGS_AS_ERRORS}) + add_compile_options(-Werror) + endif() + endif() + endif() + + if(${NS3_ENABLE_BUILD_VERSION}) + include(buildsupport/custom_modules/ns3_versioning.cmake) + add_definitions(-DENABLE_BUILD_VERSION=1) + + find_program(GIT git) + if(NOT GIT) + message(FATAL_ERROR "Baking build version into libraries require Git.") + endif() + + check_git_repo_has_ns3_tags(HAS_NS3_TAGS NS3_VERSION_TAG) + + if(NOT ${HAS_NS3_TAGS}) + message(FATAL_ERROR "This repository doesn't contain ns-3 git tags to bake into the libraries.") + endif() + + check_ns3_closest_tags( + NS3_VERSION_CLOSEST_TAG NS3_VERSION_TAG_DISTANCE NS3_VERSION_COMMIT_HASH NS3_VERSION_DIRTY_FLAG + ) + + # Split commit tag (ns-3.[.patch][-RC]) into (ns;3.[.patch];[-RC]): + string(REPLACE "-" ";" NS3_VER_LIST ${NS3_VERSION_TAG}) + list(LENGTH NS3_VER_LIST NS3_VER_LIST_LEN) + + # Get last version tag fragment (RC) + set(NS3_VERSION_RELEASE_CANDIDATE) + if(${NS3_VER_LIST_LEN} GREATER 2) + list(GET NS3_VER_LIST 2 RELEASE_CANDIDATE) + set(NS3_VERSION_RELEASE_CANDIDATE "${RELEASE_CANDIDATE}") + endif() + + # Get 3.[.patch] + list(GET NS3_VER_LIST 1 VERSION_STRING) + # Split into a list 3;[;patch] + string(REPLACE "." ";" VERSION_LIST ${VERSION_STRING}) + list(LENGTH VERSION_LIST VER_LIST_LEN) + + list(GET VERSION_LIST 0 NS3_VERSION_MAJOR) + if(${VER_LIST_LEN} GREATER 1) + list(GET VERSION_LIST 1 NS3_VERSION_MINOR) + if(${VER_LIST_LEN} GREATER 2) + list(GET VERSION_LIST 2 NS3_VERSION_PATCH) + endif() + endif() + + # Transform list with 1 entry into strings + set(NS3_VERSION_MAJOR "${NS3_VERSION_MAJOR}") + set(NS3_VERSION_MINOR "${NS3_VERSION_MINOR}") + set(NS3_VERSION_PATCH "${NS3_VERSION_PATCH}") + set(NS3_VERSION_TAG "${NS3_VERSION_TAG}") + + # Set + set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) + configure_file(buildsupport/version-defines-template.h ${CMAKE_HEADER_OUTPUT_DIRECTORY}/version-defines.h) + endif() + + if(${NS3_CLANG_FORMAT}) + find_program(CLANG_FORMAT clang-format) + if(CLANG_FORMAT) + file( + GLOB_RECURSE + ALL_CXX_SOURCE_FILES + src/*.cc + src/*.h + examples/*.cc + examples/*.h + utils/*.cc + utils/*.h + scratch/*.cc + scratch/*.h + ) + add_custom_target(clang-format COMMAND clang-format -style=file -i ${ALL_CXX_SOURCE_FILES}) + unset(ALL_CXX_SOURCE_FILES) + else() + message(STATUS "Proceeding without clang-format target") + endif() + endif() + + if(${NS3_CLANG_TIDY}) + find_program(CLANG_TIDY clang-tidy) + if(CLANG_TIDY) + set(CMAKE_CXX_CLANG_TIDY "clang-tidy") + else() + message(STATUS "Proceeding without clang-tidy static analysis") + endif() + endif() + + if(${NS3_CLANG_TIMETRACE}) + if(${CLANG}) + # Fetch and build clang build analyzer + include(ExternalProject) + ExternalProject_Add( + ClangBuildAnalyzer + GIT_REPOSITORY "https://github.com/aras-p/ClangBuildAnalyzer.git" + GIT_TAG "5d40542c5b2080637206e9d51e2957d0017ba8b3" + INSTALL_COMMAND cmake -E copy_if_different ClangBuildAnalyzer ${PROJECT_BINARY_DIR} + ) + + # Add compiler flag and create target to do everything automatically + add_definitions(-ftime-trace) + add_custom_target( + timeTraceReport + COMMAND ${PROJECT_BINARY_DIR}/ClangBuildAnalyzer --all ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/clangBuildAnalyzerReport.bin + COMMAND ${PROJECT_BINARY_DIR}/ClangBuildAnalyzer --analyze ${PROJECT_BINARY_DIR}/clangBuildAnalyzerReport.bin > + ${PROJECT_SOURCE_DIR}/ClangBuildAnalyzerReport.txt + DEPENDS ClangBuildAnalyzer + ) + else() + message(FATAL_ERROR "TimeTrace is a Clang feature, but you're using a different compiler.") + endif() + endif() + + find_program(CMAKE_FORMAT_PROGRAM cmake-format HINTS ~/.local/bin) + if(CMAKE_FORMAT_PROGRAM) + file(GLOB_RECURSE ALL_CMAKE_FILES CMakeLists.txt buildsupport/*.cmake) + add_custom_target( + cmake-format COMMAND ${CMAKE_FORMAT_PROGRAM} -c ${PROJECT_SOURCE_DIR}/buildsupport/.cmake-format.txt -i + ${ALL_CMAKE_FILES} + ) + unset(ALL_CMAKE_FILES) + endif() + + # If the user has not set a CXX standard version, assume the minimum + if(NOT "${CMAKE_CXX_STANDARD}") + set(CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD_MINIMUM}) + endif() + + # Search standard provided by the user in the unsupported standards list + list(FIND CXX_UNSUPPORTED_STANDARDS ${CMAKE_CXX_STANDARD} unsupported) + if(${unsupported} GREATER -1) + message(FATAL_ERROR "You're trying to use the unsupported C++ ${CMAKE_CXX_STANDARD}.\n" + "Try -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD_MINIMUM}." + ) + endif() + + if(${NS3_DES_METRICS}) + add_definitions(-DENABLE_DES_METRICS) + endif() + + if(${NS3_SANITIZE} AND ${NS3_SANITIZE_MEMORY}) + message(FATAL_ERROR "The memory sanitizer can't be used with other sanitizers. Disable one of them.") + endif() + + if(${NS3_SANITIZE}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,leak,undefined") + endif() + + if(${NS3_SANITIZE_MEMORY}) + if(${CLANG}) + set(blacklistfile ${PROJECT_SOURCE_DIR}/memory-sanitizer-blacklist.txt) + if(EXISTS ${blacklistfile}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-blacklist=${blacklistfile}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory") + endif() + + if(NOT ($ENV{MSAN_OPTIONS} MATCHES "strict_memcmp=0")) + message( + WARNING "Please export MSAN_OPTIONS=strict_memcmp=0 " + "and call the generated buildsystem directly to proceed.\n" + "Trying to build with cmake or IDEs will probably fail since" + "CMake can't export environment variables to its parent process." + ) + endif() + unset(blacklistfile) + else() + message(FATAL_ERROR "The memory sanitizer is only supported by Clang") + endif() + endif() + + if(${NS3_NATIVE_OPTIMIZATIONS} AND ${GCC}) + add_compile_options(-march=native -mtune=native) + endif() + + if(${NS3_LINK_TIME_OPTIMIZATION}) + # Link-time optimization (LTO) if available + include(CheckIPOSupported) + check_ipo_supported(RESULT LTO_AVAILABLE OUTPUT output) + if(LTO_AVAILABLE) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + message(STATUS "Link-tiem optimization (LTO) is supported.") + else() + message(STATUS "Link-time optimization (LTO) is not supported: ${output}.") + endif() + endif() + + if(${NS3_LINK_WHAT_YOU_USE}) + set(CMAKE_LINK_WHAT_YOU_USE TRUE) + else() + set(CMAKE_LINK_WHAT_YOU_USE FALSE) + endif() + + if(${NS3_INCLUDE_WHAT_YOU_USE}) + # Before using, install iwyu, run "strings /usr/bin/iwyu | grep LLVM" to find the appropriate clang version and + # install it. If you don't do that, it will fail. Worse than that: it will fail silently. We use the wrapper to get + # a iwyu.log file in the ns-3-dev folder. + find_program(INCLUDE_WHAT_YOU_USE_PROG iwyu) + if(NOT INCLUDE_WHAT_YOU_USE_PROG) + message(FATAL_ERROR "iwyu (include-what-you-use) was not found.") + endif() + message(STATUS "iwyu is enabled") + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${PROJECT_SOURCE_DIR}/buildsupport/iwyu_wrapper.sh;${PROJECT_SOURCE_DIR}) + else() + unset(CMAKE_CXX_INCLUDE_WHAT_YOU_USE) + endif() + + if(${XCODE}) + if(${NS3_STATIC} OR ${NS3_MONOLIB}) + message( + FATAL_ERROR "Xcode doesn't play nicely with CMake object libraries," + "and those are used for NS3_STATIC and NS3_MONOLIB.\n" "Disable them or try a different generator" + ) + endif() + set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + else() + unset(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY) + unset(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED) + unset(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY) + endif() + + # Set common include folder (./build/include, where we find ns3/core-module.h) + include_directories(${CMAKE_OUTPUT_DIRECTORY}/include) + + # find required dependencies + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/buildsupport/custom_modules") + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/buildsupport/3rd_party") + + # GTK3 Don't search for it if you don't have it installed, as it take an insane amount of time + if(${NS3_GTK3}) + find_package(HarfBuzz QUIET) + if(NOT ${HarfBuzz_FOUND}) + message(STATUS "Harfbuzz is required by GTK3 and was not found.") + else() + set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "") + find_package(GTK3 QUIET) + unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS CACHE) + if(NOT ${GTK3_FOUND}) + message(STATUS "GTK3 was not found. Continuing without it.") + else() + message(STATUS "GTK3 was found.") + endif() + endif() + endif() + + if(${NS3_STATIC}) + # Warn users that they may be using shared libraries, which won't produce a standalone static library + set(ENABLE_REALTIME FALSE) + set(HAVE_RT FALSE) + message(STATUS "Statically linking 3rd party libraries have not been tested.\n" + "Disable Brite, Click, Gtk, GSL, Mpi, Openflow and SQLite" + " if you want a standalone static ns-3 library." + ) + else() + find_package(LibXml2 QUIET) + if(NOT ${LIBXML2_FOUND}) + message(STATUS "LibXML2 was not found. Continuing without it.") + else() + message(STATUS "LibXML2 was found.") + add_definitions(-DHAVE_LIBXML2) + endif() + + # LibRT + if(${NS3_REALTIME}) + if(APPLE) + message(STATUS "Lib RT is not supported on Mac OS X. Continuing without it.") + else() + find_library(LIBRT rt QUIET) + if(NOT ${LIBRT_FOUND}) + message(FATAL_ERROR "LibRT was not found.") + set(ENABLE_REALTIME FALSE) + else() + message(STATUS "LibRT was found.") + set(ENABLE_REALTIME TRUE) + set(HAVE_RT TRUE) # for core-config.h + endif() + endif() + endif() + endif() + + set(THREADS_ENABLED FALSE) + set(PTHREADS_FOUND FALSE) + if(${NS3_PTHREAD}) + set(THREADS_PREFER_PTHREAD_FLAG) + find_package(Threads QUIET) + if(${CMAKE_USE_PTHREADS_INIT}) + include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) + set(PTHREADS_FOUND TRUE) + set(HAVE_PTHREAD_H TRUE) # for core-config.h + set(THREADS_ENABLED TRUE) + endif() + endif() + + find_package(Python3 COMPONENTS Interpreter Development) + if(${NS3_PYTHON_BINDINGS}) + if(NOT ${Python3_FOUND}) + message(FATAL_ERROR "NS3_PYTHON_BINDINGS requires Python3") + endif() + link_directories(${Python3_LIBRARY_DIRS}) + include_directories(${Python3_INCLUDE_DIRS}) + set(PYTHONDIR ${Python3_SITELIB}) + set(PYTHONARCHDIR ${Python3_SITEARCH}) + set(HAVE_PYEMBED TRUE) + set(HAVE_PYEXT TRUE) + set(HAVE_PYTHON_H TRUE) + set(destination_dir ${CMAKE_OUTPUT_DIRECTORY}/bindings/python/ns) + file(COPY bindings/python/ns__init__.py DESTINATION ${destination_dir}) + file(RENAME ${destination_dir}/ns__init__.py ${destination_dir}/__init__.py) + endif() + + if(${NS3_SCAN_PYTHON_BINDINGS}) + # empty scan target that will depend on other module scan targets to scan all of them + add_custom_target(apiscan-all) + endif() + + if(${NS3_COVERAGE} AND (NOT ${NS3_TESTS} OR NOT ${NS3_EXAMPLES})) + message(FATAL_ERROR "Code coverage requires examples and tests.\n" + "Try reconfiguring CMake with -DNS3_TESTS=ON -DNS3_EXAMPLES=ON" + ) + endif() + + if(${NS3_TESTS}) + add_custom_target(all-test-targets) + + # Create a custom target to run test.py --nowaf Target is also used to produce code coverage output + add_custom_target( + run_test_py + COMMAND ${Python3_EXECUTABLE} test.py --nowaf + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS all-test-targets + ) + if(${NS3_EXAMPLES}) + include(buildsupport/custom_modules/ns3_coverage.cmake) + endif() + endif() + + # Process config-store-config + configure_file(buildsupport/config-store-config-template.h ${CMAKE_HEADER_OUTPUT_DIRECTORY}/config-store-config.h) + + set(ENABLE_MPI FALSE) + if(${NS3_MPI}) + find_package(MPI QUIET) + if(NOT ${MPI_FOUND}) + message(STATUS "MPI was not found. Continuing without it.") + else() + message(STATUS "MPI was found.") + add_definitions(-DNS3_MPI) + set(ENABLE_MPI TRUE) + endif() + endif() + + set(ENABLE_VISUALIZER FALSE) + if(${NS3_VISUALIZER}) + if((NOT ${NS3_PYTHON_BINDINGS}) OR (NOT ${Python3_FOUND})) + message(FATAL_ERROR "Visualizer requires NS3_PYTHON_BINDINGS and Python3") + endif() + set(ENABLE_VISUALIZER TRUE) + endif() + + find_package(Boost QUIET) + if(NOT ${BOOST_FOUND}) + message(STATUS "Boost was not found. Continuing without it.") + else() + message(STATUS "Boost was found.") + include_directories(${Boost_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS}) + endif() + + if(${NS3_GSL}) + find_package(GSL QUIET) + if(NOT ${GSL_FOUND}) + message(STATUS "GSL was not found. Continuing without it.") + else() + message(STATUS "GSL was found.") + endif() + endif() + + if(${NS3_GNUPLOT}) + find_package(Gnuplot-ios) # Not sure what package would contain the correct header/library + if(NOT ${GNUPLOT_FOUND}) + message(STATUS "GNUPLOT was not found. Continuing without it.") + else() + message(STATUS "GNUPLOT was found.") + include_directories(${GNUPLOT_INCLUDE_DIRS}) + link_directories(${GNUPLOT_LIBRARY}) + endif() + endif() + + if(${NS3_DOCS}) + find_package(Doxygen REQUIRED) + find_program(DOT dot) + find_program(DIA dia) + if((NOT DOT) OR (NOT DIA)) + message(FATAL_ERROR "Dot and Dia are required by Doxygen docs." + "They're shipped within the graphviz and dia packages on Ubuntu" + ) + endif() + # Get introspected doxygen + add_custom_target( + run-print-introspected-doxygen + COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_OUTPUT_DIRECTORY}/utils/print-introspected-doxygen > + ${PROJECT_SOURCE_DIR}/doc/introspected-doxygen.h DEPENDS print-introspected-doxygen + ) + add_custom_target( + run-introspected-command-line + COMMAND ${CMAKE_COMMAND} -E env NS_COMMANDLINE_INTROSPECTION=.. ${Python3_EXECUTABLE} ./test.py --nowaf + --constrain=example + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS all-test-targets # all-test-targets only exists if NS3_TESTS is set to ON + ) + + file( + WRITE ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h + "/* This file is automatically generated by +CommandLine::PrintDoxygenUsage() from the CommandLine configuration +in various example programs. Do not edit this file! Edit the +CommandLine configuration in those files instead. +*/ +\n" + ) + add_custom_target( + assemble-introspected-command-line + # works on CMake 3.18 or newer > COMMAND ${CMAKE_COMMAND} -E cat + # ${PROJECT_SOURCE_DIR}/testpy-output/*.command-line > + # ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h + COMMAND ${cat_command} ${PROJECT_SOURCE_DIR}/testpy-output/*.command-line > + ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h 2> NULL + DEPENDS run-introspected-command-line + ) + + add_custom_target( + doxygen + COMMAND Doxygen::doxygen ${PROJECT_SOURCE_DIR}/doc/doxygen.conf + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS run-print-introspected-doxygen assemble-introspected-command-line + ) + + find_package(Sphinx REQUIRED) + find_program(EPSTOPDF epstopdf) + find_program(PDFLATEX pdflatex) + find_program(LATEXMK latexmk) + find_program(CONVERT convert) + find_program(DVIPNG dvipng) + if((NOT EPSTOPDF) + OR (NOT PDFLATEX) + OR (NOT LATEXMK) + OR (NOT CONVERT) + OR (NOT DVIPNG) + ) + message( + FATAL_ERROR + "Convert, Dvipng, Epstopdf, Pdflatex, Latexmk and fncychap.sty are required by Sphinx docs." + " They're shipped within the dvipng, imagemagick, texlive, texlive-font-utils and latexmk packages on Ubuntu." + " Imagemagick may fail due to a security policy issue." + " https://gitlab.com/nsnam/ns-3-dev/-/blob/master/utils/tests/gitlab-ci-doc.yml#L10-11" + ) + endif() + add_custom_target(sphinx COMMENT "Building sphinx documents") + + function(sphinx_target targetname) + add_custom_target( + sphinx_${targetname} COMMAND make SPHINXOPTS=-N -k html singlehtml latexpdf + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doc/${targetname} + ) + add_dependencies(sphinx sphinx_${targetname}) + endfunction() + sphinx_target(manual) + sphinx_target(models) + sphinx_target(tutorial) + endif() + + # Process core-config + if(${INT64X64} MATCHES "INT128") + include(buildsupport/3rd_party/FindInt128.cmake) + find_int128_types() + if(UINT128_FOUND) + set(HAVE___UINT128_T TRUE) + set(INT64X64_USE_128 TRUE) + else() + message(STATUS "Int128 was not found. Falling back to Cairo.") + set(INT64X64 "CAIRO") + endif() + endif() + + if(${INT64X64} MATCHES "CAIRO") + set(INT64X64_USE_CAIRO TRUE) + endif() + + if(${INT64X64} MATCHES "DOUBLE") + # WSLv1 has a long double issue that will result in a few tests failing https://github.com/microsoft/WSL/issues/830 + include(CheckTypeSize) + check_type_size("double" SIZEOF_DOUBLE) + check_type_size("long double" SIZEOF_LONG_DOUBLE) + + if(${SIZEOF_LONG_DOUBLE} EQUAL ${SIZEOF_DOUBLE}) + message( + STATUS "Long double has the wrong size: LD ${SIZEOF_LONG_DOUBLE} vs D ${SIZEOF_DOUBLE}. Falling back to CAIRO." + ) + set(INT64X64 "CAIRO") + else() + set(INT64X64_USE_DOUBLE TRUE) + endif() + endif() + + include(CheckIncludeFileCXX) + include(CheckFunctionExists) + + # Check for required headers and functions, set flags if they're found or warn if they're not found + check_include_file_cxx("stdint.h" "HAVE_STDINT_H") + check_include_file_cxx("inttypes.h" "HAVE_INTTYPES_H") + check_include_file_cxx("sys/types.h" "HAVE_SYS_TYPES_H") + check_include_file_cxx("stat.h" "HAVE_SYS_STAT_H") + check_include_file_cxx("dirent.h" "HAVE_DIRENT_H") + check_include_file_cxx("stdlib.h" "HAVE_STDLIB_H") + check_include_file_cxx("signal.h" "HAVE_SIGNAL_H") + check_include_file_cxx("netpacket/packet.h" "HAVE_PACKETH") + check_function_exists("getenv" "HAVE_GETENV") + + configure_file(buildsupport/core-config-template.h ${CMAKE_HEADER_OUTPUT_DIRECTORY}/core-config.h) + + # Force enable ns-3 logging in debug builds and if requested for other build types + if(${NS3_LOG} OR (${build_profile} STREQUAL "debug")) + add_definitions(-DNS3_LOG_ENABLE) + endif() + # Force enable ns-3 asserts in debug builds and if requested for other build types + if(${NS3_ASSERT} OR (${build_profile} STREQUAL "debug")) + add_definitions(-DNS3_ASSERT_ENABLE) + endif() + + # Enable examples as tests suites + if(${NS3_EXAMPLES}) + set(NS3_ENABLE_EXAMPLES "1") + add_definitions(-DNS3_ENABLE_EXAMPLES -DCMAKE_EXAMPLE_AS_TEST) + endif() + + set(PLATFORM_UNSUPPORTED_PRE "Platform doesn't support") + set(PLATFORM_UNSUPPORTED_POST "features. Continuing without them.") + # Remove from libs_to_build all incompatible libraries or the ones that dependencies couldn't be installed + if(APPLE OR WSLv1) + set(NS3_TAP OFF) + set(NS3_EMU OFF) + list(REMOVE_ITEM libs_to_build fd-net-device) + message(STATUS "${PLATFORM_UNSUPPORTED_PRE} TAP and EMU ${PLATFORM_UNSUPPORTED_POST}") + endif() + + if(NOT ${ENABLE_MPI}) + list(REMOVE_ITEM libs_to_build mpi) + endif() + + if(NOT ${ENABLE_VISUALIZER}) + list(REMOVE_ITEM libs_to_build visualizer) + endif() + + if(NOT ${NS3_TAP}) + list(REMOVE_ITEM libs_to_build tap-bridge) + endif() + + # Create library names to solve dependency problems with macros that will be called at each lib subdirectory + set(ns3-libs) + set(ns3-all-modules) + set(ns3-libs-tests) + set(ns3-contrib-libs) + set(lib-ns3-static-objs) + set(ns3-external-libs) + set(ns3-python-bindings ns${NS3_VER}-pybindings${build_profile_suffix}) + set(ns3-python-bindings-modules) + + foreach(libname ${scanned_modules}) + # Create libname of output library of module + library_target_name(${libname} targetname) + set(lib${libname} ${targetname} CACHE INTERNAL "") + set(lib${libname}-obj ${targetname}-obj CACHE INTERNAL "") + endforeach() + + unset(optional_visualizer_lib) + if(${ENABLE_VISUALIZER}) + set(optional_visualizer_lib ${libvisualizer}) + endif() + + if(${NS3_PRECOMPILE_HEADERS}) + set(precompiled_header_libraries + + + + + + + + + + + + + + + + + + ) + add_library(stdlib_pch OBJECT ${PROJECT_SOURCE_DIR}/buildsupport/empty.cc) + target_precompile_headers(stdlib_pch PUBLIC "${precompiled_header_libraries}") + + add_executable(stdlib_pch_exec ${PROJECT_SOURCE_DIR}/buildsupport/empty_main.cc) + target_precompile_headers(stdlib_pch_exec PUBLIC "${precompiled_header_libraries}") + set_runtime_outputdirectory(stdlib_pch_exec ${CMAKE_BINARY_DIR}) + endif() + + # Create new lib for NS3 static builds + set(lib-ns3-static ns${NS3_VER}-static${build_profile_suffix}) + + # Create a new lib for NS3 monolibrary shared builds + set(lib-ns3-monolib ns${NS3_VER}-monolib${build_profile_suffix}) + + # All contrib libraries can be linked afterwards linking with ${ns3-contrib-libs} + process_contribution("${contrib_libs_to_build}") + + # Netanim depends on ns-3 core, so we built it later + if(${NS3_NETANIM}) + include(FetchContent) + FetchContent_Declare(netanim GIT_REPOSITORY https://gitlab.com/nsnam/netanim.git GIT_TAG netanim-3.108) + FetchContent_Populate(netanim) + file(COPY buildsupport/3rd_party/netanim_cmakelists.cmake DESTINATION ${netanim_SOURCE_DIR}) + file(RENAME ${netanim_SOURCE_DIR}/netanim_cmakelists.cmake ${netanim_SOURCE_DIR}/CMakeLists.txt) + add_subdirectory(${netanim_SOURCE_DIR}) + endif() +endmacro() + +function(set_runtime_outputdirectory target_name output_directory) + set(ns3-exec-outputname ns${NS3_VER}-${target_name}${build_profile_suffix}) + set(ns3-execs "${output_directory}${ns3-exec-outputname};${ns3-execs}" CACHE INTERNAL "list of c++ executables") + + set_target_properties( + ${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_directory} RUNTIME_OUTPUT_NAME ${ns3-exec-outputname} + ) + if(${XCODE}) + # Is that so hard not to break people's CI, AAPL?? Why would you output the targets to a Debug/Release subfolder? + # Why? + foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set_target_properties( + ${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${output_directory} + RUNTIME_OUTPUT_NAME_${OUTPUTCONFIG} ${ns3-exec-outputname} + ) + endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) + endif() + + if(${NS3_TESTS}) + add_dependencies(all-test-targets ${target_name}) + endif() + + if(${NS3_CLANG_TIMETRACE}) + add_dependencies(timeTraceReport ${target_name}) + endif() +endfunction(set_runtime_outputdirectory) + +add_custom_target(copy_all_headers) +function(copy_headers_before_building_lib libname outputdir headers visibility) + set(copy_headers_target copy_headers_${libname}_${visibility}) + add_custom_target(${copy_headers_target}) + foreach(header ${headers}) + get_filename_component(header_name ${header} NAME) + add_custom_command( + TARGET ${copy_headers_target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/${header} ${outputdir}/${header_name} + ) + endforeach() + + # Create a target to copy all headers + add_dependencies(copy_all_headers ${copy_headers_target}) + + # And make sure module headers are copied before compiling them + if(${XCODE}) + add_dependencies(${lib${libname}} copy_all_headers) # Xcode doesn't play nicely with object libraries + else() + add_dependencies(${lib${libname}-obj} copy_all_headers) + endif() +endfunction(copy_headers_before_building_lib) + +# Import macros used for modules and define specialized versions for src modules +include(buildsupport/custom_modules/ns3_module_macros.cmake) + +macro(build_lib libname source_files header_files libraries_to_link test_sources) + build_lib_impl("src" "${libname}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +endmacro() + +macro(build_lib_example name source_files header_files libraries_to_link) + build_lib_example_impl("src/${libname}" "${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endmacro() + +# Contrib modules counterparts of macros above +include(buildsupport/custom_modules/ns3_contributions.cmake) + +# Macro to build examples in ns-3-dev/examples/ +macro(build_example name source_files header_files libraries_to_link) + set(missing_dependencies FALSE) + foreach(lib ${libraries_to_link}) + string(REPLACE "lib" "" lib ${lib}) + if(NOT (${lib} IN_LIST ns3-all-modules)) + set(missing_dependencies TRUE) + endif() + endforeach() + + if(NOT ${missing_dependencies}) + # Create shared library with sources and headers + add_executable(${name} "${source_files}" "${header_files}") + + if(${NS3_STATIC}) + target_link_libraries(${name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-ns3-static}) + elseif(${NS3_MONOLIB}) + target_link_libraries(${name} ${LIB_AS_NEEDED_PRE} ${lib-ns3-monolib} ${LIB_AS_NEEDED_POST}) + else() + # Link the shared library with the libraries passed + target_link_libraries( + ${name} ${LIB_AS_NEEDED_PRE} ${libraries_to_link} ${optional_visualizer_lib} ${LIB_AS_NEEDED_POST} + ) + endif() + + if(${NS3_PRECOMPILE_HEADERS}) + target_precompile_headers(${name} REUSE_FROM stdlib_pch_exec) + endif() + + set_runtime_outputdirectory(${name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/${examplefolder}/) + endif() +endmacro() + +function(filter_modules modules_to_filter all_modules_list filter_in) + set(new_modules_to_build) + # We are receiveing variable names as arguments, so we have to "dereference" them first That is why we have the + # duplicated ${${}} + foreach(module ${${all_modules_list}}) + if(${filter_in} (${module} IN_LIST ${modules_to_filter})) + list(APPEND new_modules_to_build ${module}) + endif() + endforeach() + set(${all_modules_list} ${new_modules_to_build} PARENT_SCOPE) +endfunction() + +function(resolve_dependencies module_name dependencies contrib_dependencies) + # Create cache variables to hold dependencies list and visited + set(dependency_visited "" CACHE INTERNAL "") + set(contrib_dependency_visited "" CACHE INTERNAL "") + recursive_dependency(${module_name}) + if(${module_name} IN_LIST dependency_visited) + set(temp ${dependency_visited}) + list(REMOVE_AT temp 0) + set(${dependencies} ${temp} PARENT_SCOPE) + set(${contrib_dependencies} ${contrib_dependency_visited} PARENT_SCOPE) + else() + set(temp ${contrib_dependency_visited}) + list(REMOVE_AT temp 0) + set(${dependencies} ${dependency_visited} PARENT_SCOPE) + set(${contrib_dependencies} ${temp} PARENT_SCOPE) + endif() + unset(dependency_visited CACHE) + unset(contrib_dependency_visited CACHE) +endfunction() + +function(filter_libraries cmakelists_contents libraries) + string(REGEX MATCHALL "{lib[^}]*[^obj]}" matches "${cmakelists_content}") + list(REMOVE_ITEM matches "{libraries_to_link}") + string(REPLACE "{lib" "" matches "${matches}") + string(REPLACE "}" "" matches "${matches}") + set(${libraries} ${matches} PARENT_SCOPE) +endfunction() + +function(recursive_dependency module_name) + # Read module CMakeLists.txt and search for ns-3 modules + set(src_cmakelist ${PROJECT_SOURCE_DIR}/src/${module_name}/CMakeLists.txt) + set(contrib_cmakelist ${PROJECT_SOURCE_DIR}/contrib/${module_name}/CMakeLists.txt) + set(contrib FALSE) + if(EXISTS ${src_cmakelist}) + file(READ ${src_cmakelist} cmakelists_content) + elseif(EXISTS ${contrib_cmakelist}) + file(READ ${contrib_cmakelist} cmakelists_content) + set(contrib TRUE) + else() + message(STATUS "The CMakeLists.txt file for module ${module_name} was not found.") + endif() + + filter_libraries(${cmakelists_content} matches) + + # Add this visited module dependencies to the dependencies list + if(contrib) + set(contrib_dependency_visited "${contrib_dependency_visited};${module_name}" CACHE INTERNAL "") + set(examples_cmakelist ${contrib_cmakelist}) + else() + set(dependency_visited "${dependency_visited};${module_name}" CACHE INTERNAL "") + set(examples_cmakelist ${src_cmakelist}) + endif() + + # cmake-format: off + # Scan dependencies required by this module examples + #if(${NS3_EXAMPLES}) + # string(REPLACE "${module_name}" "${module_name}/examples" examples_cmakelist ${examples_cmakelist}) + # if(EXISTS ${examples_cmakelist}) + # file(READ ${examples_cmakelist} cmakelists_content) + # filter_libraries(${cmakelists_content} example_matches) + # endif() + #endif() + # cmake-format: on + + # For each dependency, call this same function + set(matches "${matches};${example_matches}") + foreach(match ${matches}) + if(NOT ((${match} IN_LIST dependency_visited) OR (${match} IN_LIST contrib_dependency_visited))) + recursive_dependency(${match}) + endif() + endforeach() +endfunction() + +macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES) + # Before filtering, we set a variable with all scanned moduled in the src directory + set(scanned_modules ${${libs_to_build}}) + + # Now that scanning modules finished, we can remove the disabled modules or replace the modules list with the ones in + # the enabled list + if(NS3_ENABLED_MODULES) + # Filter enabled modules + filter_modules(NS3_ENABLED_MODULES libs_to_build "") + filter_modules(NS3_ENABLED_MODULES contrib_libs_to_build "") + + # Recursively build a list of module dependendencies + foreach(lib ${${contrib_libs_to_build}}) + message(WARNING "contrib ${lib}") + resolve_dependencies(${lib} dependencies contrib_dependencies) + list(APPEND ${contrib_libs_to_build} "${contrib_dependencies}") + list(APPEND ${libs_to_build} "${dependencies}") + unset(dependencies) + unset(contrib_dependencies) + endforeach() + + foreach(lib ${${libs_to_build}}) + resolve_dependencies(${lib} dependencies contrib_dependencies) + list(APPEND ${libs_to_build} "${dependencies}") + unset(dependencies) + unset(contrib_dependencies) + endforeach() + + if(${NS3_TESTS}) + list(APPEND ${libs_to_build} test) # force enable test module if NS3_TESTS is enabled + endif() + endif() + + if(NS3_DISABLED_MODULES) + filter_modules(NS3_DISABLED_MODULES libs_to_build "NOT") + filter_modules(NS3_DISABLED_MODULES contrib_libs_to_build "NOT") + endif() + + # Filter out any eventual duplicates + list(REMOVE_DUPLICATES ${libs_to_build}) + list(REMOVE_DUPLICATES ${contrib_libs_to_build}) + + # Export list with all enabled modules (used to separate ns libraries from non-ns libraries in ns3_module_macros) + set(ns3-all-modules "${${libs_to_build}};${${contrib_libs_to_build}}" CACHE INTERNAL "list with all enabled modules") +endmacro() + +# Waf workaround scripts +include(buildsupport/custom_modules/waf_workaround_c4cache.cmake) +include(buildsupport/custom_modules/waf_workaround_buildstatus.cmake) +include(buildsupport/custom_modules/waf_workaround_lock.cmake) +include(buildsupport/custom_modules/waf_workaround_fakeconfig.cmake) diff --git a/buildsupport/version-defines-template.h b/buildsupport/version-defines-template.h new file mode 100644 index 000000000..a71c7b32d --- /dev/null +++ b/buildsupport/version-defines-template.h @@ -0,0 +1,145 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2018 Lawrence Livermore National Laboratory + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Mathew Bielejeski + */ + +#ifndef NS3_VERSION_DEFINES_H_ +#define NS3_VERSION_DEFINES_H_ + +/** + * \file + * \ingroup buildversion + * Defines the macro values for printing the build version. + * These will be populated by the build system. + */ + +/** + * \ingroup buildversion + * @{ + */ + +/** + * The first tag found which matches the pattern ns-3*. + * + * The expected format of the ns-3 version tag is: ns-3.[.patch][-release_candidate] + * + * The tag is found by starting at the tip of the current branch and walking + * back towards the root. + * + * Type: string literal + */ +#cmakedefine NS3_VERSION_TAG "@NS3_VERSION_TAG@" + +/** + * The tag closest to the tip of the current branch + * + * The tag is found by starting at the tip of the current branch and + * walking back towards the root. + * + * This value will be the same as #NS3_VERSION_TAG when #NS3_VERSION_TAG is + * the closest tag. + * + * Type: string literal + */ +#cmakedefine NS3_VERSION_CLOSEST_TAG "@NS3_VERSION_CLOSEST_TAG@" + +/** + * The major version extracted from #NS3_VERSION_TAG + * + * For a tag with the format ns-.[.digit], the major + * version is the number after ns- and before the first period. + * + * Type: integer + */ +#cmakedefine NS3_VERSION_MAJOR @NS3_VERSION_MAJOR@ + +/** + * The minor version extracted from #NS3_VERSION_TAG + * + * For a tag with the format ns-.[.digit], the minor + * version is the number after the first period. + * + * Type: integer + */ +#cmakedefine NS3_VERSION_MINOR @NS3_VERSION_MINOR@ + +/** + * The patch number extracted from #NS3_VERSION_TAG + * + * For a tag with the format ns-.[.digit], the patch + * is the number after the last period. + * + * The patch value is optional and may not be present in the tag. + * In cases where the patch value is not present, the field will be set to 0 + * + * Type: integer + */ +#cmakedefine NS3_VERSION_PATCH @NS3_VERSION_PATCH@ + +/** + * The portion of the #NS3_VERSION_TAG indicating the version + * of the release candidate (if applicable). + * + * In order for this field to contain a value, the #NS3_VERSION_TAG + * must have the format ns-.[.digit][-RC]. + * The contents of the release candidate will be the RC + * portion of the tag. + * + * Type: string literal + */ +#cmakedefine NS3_VERSION_RELEASE_CANDIDATE "@NS3_VERSION_RELEASE_CANDIDATE@" + +/** + * The number of repository commits between #NS3_VERSION_CLOSEST_TAG + * and the branch HEAD. + * + * Type: integer + */ +#cmakedefine NS3_VERSION_TAG_DISTANCE @NS3_VERSION_TAG_DISTANCE@ + +/** + * Hash value which uniquely identifies the commit of the + * branch HEAD. + * The first character of the commit hash is 'g' to indicate this hash is + * a git hash + * + * Type: string literal + */ +#cmakedefine NS3_VERSION_COMMIT_HASH "@NS3_VERSION_COMMIT_HASH@" + +/** + * Flag indicating whether the repository working tree had uncommitted + * changes when the library was built. + * + * The flag will be 1 if there were uncommitted changes, 0 otherwise. + * + * Type: integer + */ +#cmakedefine01 NS3_VERSION_DIRTY_FLAG + +/** + * Indicates the build profile that was specified by the --build-profile option + * of "waf configure" + * + * Type: string literal + */ +#cmakedefine NS3_VERSION_BUILD_PROFILE "@NS3_VERSION_BUILD_PROFILE@" + +/** @} */ + +#endif diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..6867a30c3 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,10 @@ +if(${NS3_EXAMPLES}) + subdirlist(examples_to_build ${CMAKE_CURRENT_SOURCE_DIR}) + + # Process subdirectories + foreach(examplefolder ${examples_to_build}) + add_subdirectory(${examplefolder}) + + set(ns3-example-folders "${examplefolder};${ns3-example-folders}" CACHE INTERNAL "list of example folders") + endforeach() +endif() diff --git a/examples/channel-models/CMakeLists.txt b/examples/channel-models/CMakeLists.txt new file mode 100644 index 000000000..01c07c6ed --- /dev/null +++ b/examples/channel-models/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name three-gpp-v2v-channel-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libpropagation} ${libspectrum} ${libantenna} ${libbuildings}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/energy/CMakeLists.txt b/examples/energy/CMakeLists.txt new file mode 100644 index 000000000..5d58a2ca9 --- /dev/null +++ b/examples/energy/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name energy-model-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libwifi} ${libenergy} ${libinternet} ${libconfig-store}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name energy-model-with-harvesting-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libwifi} ${libenergy} ${libinternet} ${libconfig-store}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/error-model/CMakeLists.txt b/examples/error-model/CMakeLists.txt new file mode 100644 index 000000000..5bba18d2f --- /dev/null +++ b/examples/error-model/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name simple-error-model) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/ipv6/CMakeLists.txt b/examples/ipv6/CMakeLists.txt new file mode 100644 index 000000000..07bb18990 --- /dev/null +++ b/examples/ipv6/CMakeLists.txt @@ -0,0 +1,53 @@ +set(name fragmentation-ipv6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name fragmentation-ipv6-two-MTU) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name icmpv6-redirect) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name loose-routing-ipv6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name ping6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name radvd) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name radvd-two-prefix) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name test-ipv6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wsn-ping6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblr-wpan} ${libinternet} ${libsixlowpan} ${libmobility} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/matrix-topology/CMakeLists.txt b/examples/matrix-topology/CMakeLists.txt new file mode 100644 index 000000000..38710e58a --- /dev/null +++ b/examples/matrix-topology/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name matrix-topology) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libnetanim} ${libmobility} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/naming/CMakeLists.txt b/examples/naming/CMakeLists.txt new file mode 100644 index 000000000..973612f79 --- /dev/null +++ b/examples/naming/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name object-names) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/realtime/CMakeLists.txt b/examples/realtime/CMakeLists.txt new file mode 100644 index 000000000..b9a3e4996 --- /dev/null +++ b/examples/realtime/CMakeLists.txt @@ -0,0 +1,7 @@ +if(${ENABLE_REALTIME}) + set(name realtime-udp-echo) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) + build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() diff --git a/examples/routing/CMakeLists.txt b/examples/routing/CMakeLists.txt new file mode 100644 index 000000000..786bb6715 --- /dev/null +++ b/examples/routing/CMakeLists.txt @@ -0,0 +1,95 @@ +set(name dynamic-global-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name static-routing-slash32) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name global-routing-slash32) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name global-injection-slash32) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-global-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-alternate-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name mixed-global-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libcsma} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-routing-ping6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name manet-routing-compare) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link + ${libwifi} + ${libdsr} + ${libdsdv} + ${libaodv} + ${libolsr} + ${libinternet} + ${libapplications} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name ripng-simple-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name rip-simple-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libinternet-apps}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name global-routing-multi-switch-plus-router) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link + ${libcore} + ${libnetwork} + ${libapplications} + ${libinternet} + ${libbridge} + ${libcsma} + ${libpoint-to-point} + ${libcsma} + ${libinternet} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-multicast-flooding) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libnetwork} ${libapplications} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/socket/CMakeLists.txt b/examples/socket/CMakeLists.txt new file mode 100644 index 000000000..4fcd6fff4 --- /dev/null +++ b/examples/socket/CMakeLists.txt @@ -0,0 +1,23 @@ +set(name socket-bound-static-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libcsma} ${libpoint-to-point} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name socket-bound-tcp-static-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libcsma} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name socket-options-ipv4) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libcsma} ${libpoint-to-point} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name socket-options-ipv6) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libcsma} ${libpoint-to-point} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/stats/CMakeLists.txt b/examples/stats/CMakeLists.txt new file mode 100644 index 000000000..1daa94e9f --- /dev/null +++ b/examples/stats/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name wifi-example-sim) +set(source_files ${name}.cc wifi-example-apps.cc) +set(header_files wifi-example-apps.h) +set(libraries_to_link ${libstats} ${libinternet} ${libmobility} ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/tcp/CMakeLists.txt b/examples/tcp/CMakeLists.txt new file mode 100644 index 000000000..251fd387a --- /dev/null +++ b/examples/tcp/CMakeLists.txt @@ -0,0 +1,83 @@ +if(${NS3_NSC}) + set(name tcp-nsc-lfn) + set(source_files ${name}.cc) + set(libraries_to_link ${libpoint-to-point} ${libapplications} ${libinternet}) + build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name tcp-nsc-zoo) + set(source_files ${name}.cc) + set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) + build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name tcp-nsc-comparison) + set(source_files ${name}.cc) + set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor}) + build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() + +set(name tcp-large-transfer) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libapplications} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-star-server) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libapplications} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name star) +set(source_files ${name}.cc) +set(libraries_to_link ${libnetanim} ${libpoint-to-point} ${libpoint-to-point-layout} ${libapplications} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-bbr-example) +set(source_files ${name}.cc) +set(libraries_to_link + ${libpoint-to-point} + ${libinternet} + ${libapplications} + ${libtraffic-control} + ${libnetwork} + ${libinternet-apps} + ${libflow-monitor} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-bulk-send) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libapplications} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-pcap-nanosec-example) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libapplications} ${libinternet}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-variants-comparison) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-pacing) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-linux-reno) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libtraffic-control} ${libnetwork}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tcp-validation) +set(source_files ${name}.cc) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libtraffic-control} ${libnetwork} + ${libinternet-apps} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name dctcp-example) +set(source_files ${name}.cc) +set(libraries_to_link ${libcore} ${libnetwork} ${libinternet} ${libpoint-to-point} ${libapplications} + ${libtraffic-control} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/traffic-control/CMakeLists.txt b/examples/traffic-control/CMakeLists.txt new file mode 100644 index 000000000..b2d882309 --- /dev/null +++ b/examples/traffic-control/CMakeLists.txt @@ -0,0 +1,41 @@ +set(name traffic-control) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libapplications} ${libtraffic-control} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name queue-discs-benchmark) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libapplications} ${libinternet-apps} ${libtraffic-control} + ${libflow-monitor} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name red-vs-fengadaptive) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libpoint-to-point-layout} ${libapplications} + ${libtraffic-control} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name red-vs-nlred) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libpoint-to-point-layout} ${libapplications} + ${libtraffic-control} +) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tbf-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libapplications} ${libtraffic-control}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name cobalt-vs-codel) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libapplications} ${libtraffic-control}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/tutorial/CMakeLists.txt b/examples/tutorial/CMakeLists.txt new file mode 100644 index 000000000..0182612c2 --- /dev/null +++ b/examples/tutorial/CMakeLists.txt @@ -0,0 +1,47 @@ +set(name hello-simulator) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name first) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name second) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpoint-to-point} ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name third) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpoint-to-point} ${libcsma} ${libwifi} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name fourth) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name fifth) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name sixth) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name seventh) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libstats} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/udp-client-server/CMakeLists.txt b/examples/udp-client-server/CMakeLists.txt new file mode 100644 index 000000000..27c61efa2 --- /dev/null +++ b/examples/udp-client-server/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name udp-client-server) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name udp-trace-client-server) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/udp/CMakeLists.txt b/examples/udp/CMakeLists.txt new file mode 100644 index 000000000..c28d3bca0 --- /dev/null +++ b/examples/udp/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name udp-echo) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/wireless/CMakeLists.txt b/examples/wireless/CMakeLists.txt new file mode 100644 index 000000000..a6d9e543a --- /dev/null +++ b/examples/wireless/CMakeLists.txt @@ -0,0 +1,233 @@ +set(name mixed-wired-wireless) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications} ${libolsr} ${libnetanim}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-80211e-txop) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-80211n-mimo) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-adhoc) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-aggregation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-ap) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-backward-compatibility) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-blockack) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-clear-channel-cmu) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-dsss-validation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-he-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-hidden-terminal) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-ht-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-mixed-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-multi-tos) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-multirate) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libwifi} ${libolsr} ${libapplications} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-ofdm-he-validation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-ofdm-ht-validation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-ofdm-validation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-ofdm-vht-validation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libwifi} ${libconfig-store} ${libstats}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-error-models-comparison) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-power-adaptation-distance) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-power-adaptation-interference) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications} ${libflow-monitor}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-rate-adaptation-distance) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-simple-adhoc) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-simple-adhoc-grid) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libwifi} ${libolsr}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-simple-ht-hidden-stations) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-simple-infra) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-simple-interference) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libwifi}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-sleep) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-spatial-reuse) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-spectrum-per-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-spectrum-per-interference) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-spectrum-saturation-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-tcp) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-timing-attributes) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-txop-aggregation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-vht-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-wired-bridging) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libcsma} ${libbridge} ${libapplications}) +build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/ns3 b/ns3 new file mode 100755 index 000000000..f23778951 --- /dev/null +++ b/ns3 @@ -0,0 +1,722 @@ +#! /usr/bin/env python3 + +import argparse +import glob +import os +import re +import shutil +import subprocess +import sys + +from utils import read_config_file + + +def on_off_argument(parser, option_name, help_on, help_off=None): + parser.add_argument('--enable-%s' % option_name, + help=('Enable %s' % help_on) if help_off is None else help_on, + action="store_true", default=None) + parser.add_argument('--disable-%s' % option_name, + help=('Disable %s' % help_on) if help_off is None else help_off, + action="store_true", default=None) + return parser + + +def on_off(condition): + return "ON" if condition else "OFF" + + +def on_off_condition(args, cmake_flag, option_name): + enable_option = args.__getattribute__("enable_" + option_name) + disable_option = args.__getattribute__("disable_" + option_name) + cmake_arg = None + if enable_option is not None or disable_option is not None: + cmake_arg = "-DNS3_%s=%s" % (cmake_flag, on_off(enable_option and not disable_option)) + return cmake_arg + + +def parse_args(argv): + parser = argparse.ArgumentParser("ns-3 wrapper for the CMake build system") + sub_parser = parser.add_subparsers() + + parser_configure = sub_parser.add_parser('configure', help='configure --help') + parser_configure.add_argument('configure', + nargs='?', + action='store', default=True) + parser_configure.add_argument('-d', '--build-profile', + help='Build profile', + dest='build_profile', + choices=["debug", "release", "optimized"], + action="store", type=str, default=None) + + parser_configure.add_argument('-G', + help=('CMake generator ' + '(e.g. https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html)'), + action="store", type=str, default=None) + + parser_configure.add_argument('--cxx-standard', + help='Compile NS-3 with the given C++ standard', + type=str, default=None) + + parser_configure = on_off_argument(parser_configure, "asserts", "the asserts regardless of the compile mode") + parser_configure = on_off_argument(parser_configure, "logs", "the logs regardless of the compile mode") + parser_configure = on_off_argument(parser_configure, "tests", "the ns-3 tests") + parser_configure = on_off_argument(parser_configure, "examples", "the ns-3 examples") + parser_configure = on_off_argument(parser_configure, "static", "Build a single static library with all ns-3", + "Restore the shared libraries") + parser_configure = on_off_argument(parser_configure, "mpi", "the MPI support for distributed simulation") + parser_configure = on_off_argument(parser_configure, "des-metrics", + "Logging all events in a json file with the name of the executable " + "(which must call CommandLine::Parse(argc, argv)") + parser_configure = on_off_argument(parser_configure, "gcov", "code coverage analysis") + parser_configure = on_off_argument(parser_configure, "gtk", "GTK support in ConfigStore") + parser_configure = on_off_argument(parser_configure, "warnings", "compiler warnings") + parser_configure = on_off_argument(parser_configure, "werror", "Treat compiler warnings as errors", + "Treat compiler warnings as warnings") + + parser_configure.add_argument('--enable-modules', + help='List of modules to build (e.g. core;network;internet)', + action="store", type=str, default=None) + parser_configure.add_argument('--disable-modules', + help='List of modules not to build (e.g. lte;wimax)', + action="store", type=str, default=None) + parser_configure.add_argument('--lcov-report', + help=('Generate a code coverage report ' + '(use this option after configuring with --enable-gcov and running a program)'), + action="store_true", default=None) + parser_configure.add_argument('--lcov-zerocounters', + help=('Zero the lcov counters' + '(use this option before rerunning a program' + 'when generating repeated lcov reports)'), + action="store_true", default=None) + + parser_configure.add_argument('--with-brite', + help=('Use BRITE integration support, given by the indicated path,' + ' to allow the use of the BRITE topology generator'), + type=str, default=None) + parser_configure.add_argument('--with-click', + help='Path to Click source or installation prefix for NS-3 Click Integration support', + type=str, default=None) + parser_configure.add_argument('--with-openflow', + help='Path to OFSID source for NS-3 OpenFlow Integration support', + type=str, default=None) + parser_configure.add_argument('--force-refresh', + help='Force refresh the CMake cache by deleting' + 'the cache and reconfiguring the project', + action="store_true", default=None) + + parser_build = sub_parser.add_parser('build', help='build --help') + parser_build.add_argument('build', + help='Build the entire project or the specified target and dependencies', + action="store", nargs='*', default=None) + + parser_clean = sub_parser.add_parser('clean', help='clean --help') + parser_clean.add_argument('clean', + nargs="?", + action="store", default=True) + + parser.add_argument('--verbose', + help="Print underlying commands", + action="store_true", default=None) + parser.add_argument('--check-config', + help='Print the current configuration.', + action="store_true", default=None) + + parser.add_argument('--cwd', + help='Set the working directory for a program.', + action="store", type=str, default=None) + parser.add_argument('--no-task-lines', + help="Don't print task lines, i.e. messages saying which tasks are being executed.", + action="store_true", default=None) + + parser.add_argument('--run', + help=('Run a locally built program; argument can be a program name,' + ' or a command starting with the program name.'), + type=str, default='') + parser.add_argument('--run-no-build', + help=( + 'Run a locally built program without rebuilding the project;' + 'argument can be a program name, or a command starting with the program name.'), + type=str, default='') + parser.add_argument('--visualize', + help='Modify --run arguments to enable the visualizer', + action="store_true", default=None) + parser.add_argument('--command-template', + help=('Template of the command used to run the program given by --run;' + ' It should be a shell command string containing %s inside,' + ' which will be replaced by the actual program.'), + type=str, default=None) + parser.add_argument('--pyrun', + help=('Run a python program using locally built ns3 python module;' + ' argument is the path to the python program, optionally followed' + ' by command-line options that are passed to the program.'), + type=str, default='') + parser.add_argument('--pyrun-no-build', + help=( + 'Run a python program using locally built ns3 python module without rebuilding the project;' + ' argument is the path to the python program, optionally followed' + ' by command-line options that are passed to the program.'), + type=str, default='') + parser.add_argument('--gdb', + help='Change the default command template to run programs and unit tests with gdb', + action="store_true", default=None) + parser.add_argument('--valgrind', + help='Change the default command template to run programs and unit tests with valgrind', + action="store_true", default=None) + # parser.add_argument('--shell', + # help=('DEPRECATED (run ./waf shell)'), + # action="store_true", default=None) + # parser.add_argument('--enable-sudo', + # help=('Use sudo to setup suid bits on ns3 executables.'), + # dest='enable_sudo', action='store_true', + # default=None) + + parser.add_argument('--check', + help='DEPRECATED (run ./test.py)', + action='store_true', default=None) + + # parser.add_argument('--doxygen-no-build', + # help=('Run doxygen to generate html documentation from source comments, ' + # 'but do not wait for ns-3 to finish the full build.'), + # action="store_true", default=None) + # parser.add_argument('--docset', + # help=( + # 'Create Docset, without building. This requires the docsetutil tool from Xcode 9.2 or earlier.' + # 'See Bugzilla 2196 for more details.'), + # action="store_true", default=None, + # dest="docset_build") + + return parser.parse_args(argv) + + +def check_build_profile(ns3_path): + # Check the c4cache for the build type (in case there are multiple cmake cache folders + c4che_path = os.sep.join([ns3_path, "build", "c4che", "_cache.py"]) + build_profile = None + ns3_version = None + ns3_modules = None + if os.path.exists(c4che_path): + c4che_info = {} + exec(open(c4che_path).read(), globals(), c4che_info) + build_profile = c4che_info["BUILD_PROFILE"] + ns3_version = c4che_info["VERSION"] + ns3_modules = c4che_info["NS3_ENABLED_MODULES"] + return build_profile, ns3_version, ns3_modules + + +def clean_cmake_artifacts(ns3_path, verbose=False): + if verbose: + print("rm -R %s/build" % ns3_path) + + shutil.rmtree(ns3_path + os.sep + "build", ignore_errors=True) + cmake_cache_files = glob.glob("./**/CMakeCache.txt", recursive=True) + + for cmake_cache_file in cmake_cache_files: + dirname = os.path.dirname(cmake_cache_file) + if verbose: + print("rm -R %s" % dirname) + shutil.rmtree(dirname, ignore_errors=True) + + +def search_cmake_cache(ns3_path, build_profile): + # Search for the CMake cache + cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True) + current_cmake_cache_folder = None + current_cmake_generator = None + + if cmake_cache_files: + # In case there are multiple cache files, get the correct one + for cmake_cache_file in cmake_cache_files: + # We found the right cache folder + if current_cmake_cache_folder and current_cmake_generator: + break + + # Still looking for it + current_cmake_cache_folder = None + current_cmake_generator = None + with open(cmake_cache_file, "r") as f: + lines = f.read().split("\n") + + while len(lines): + line = lines[0] + lines.pop(0) + + # Check for EOF + if current_cmake_cache_folder and current_cmake_generator: + break + + # Check the build profile + if "CMAKE_BUILD_TYPE" in line: + if build_profile == line.split("=")[-1].lower(): + current_cmake_cache_folder = os.path.dirname(cmake_cache_file) + + # Check the generator + if "CMAKE_GENERATOR" in line: + current_cmake_generator = line.split("=")[-1] + + if not current_cmake_generator: + # Search for available generators + cmake_generator_map = {"make": "Unix Makefiles", + "ninja": "Ninja", + "xcodebuild": "Xcode" + } + available_generators = [] + for generator in cmake_generator_map.keys(): + if shutil.which(generator): + available_generators.append(generator) + + # Select the first one + if len(available_generators) == 0: + raise Exception("No generator available.") + + current_cmake_generator = cmake_generator_map[available_generators[0]] + + return current_cmake_cache_folder, current_cmake_generator + + +def check_config(current_cmake_cache_folder): + waf_like_config_table = current_cmake_cache_folder + os.sep + "ns3wafconfig.txt" + if not os.path.exists(waf_like_config_table): + raise Exception("Project was not configured") + with open(waf_like_config_table, "r") as f: + print(f.read()) + + +def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_generator, output, verbose=False): + # Aggregate all flags to configure CMake + cmake_args = [cmake] + + first_run = False + if not os.path.exists(current_cmake_cache_folder + os.sep + "CMakeCache.txt"): + first_run = True + + if "configure" in args: + if first_run: + # Set default build type to default if a previous cache doesn't exist + if args.build_profile is None: + args.build_profile = "debug" + + # Set generator if a previous cache doesn't exist + if args.G is None: + args.G = current_cmake_generator + + # C++ standard + if args.cxx_standard is not None: + cmake_args.append("-DCMAKE_CXX_STANDARD=%s" % args.cxx_standard) + + # Build type + if args.build_profile is not None: + args.build_profile = args.build_profile.lower() + if args.build_profile not in ["debug", "release", "optimized"]: + raise Exception("Unknown build type") + else: + if args.build_profile == "debug": + cmake_args.append("-DCMAKE_BUILD_TYPE=debug") + else: + cmake_args.append("-DCMAKE_BUILD_TYPE=release") + cmake_args.append("-DNS3_NATIVE_OPTIMIZATIONS=%s" % on_off((args.build_profile == "optimized"))) + + options = (("ASSERT", "asserts"), + ("LOG", "logs"), + ("TESTS", "tests"), + ("EXAMPLES", "examples"), + ("COVERAGE", "gcov"), + ("DES_METRICS", "des_metrics"), + ("STATIC", "static"), + ("MPI", "mpi"), + ("GTK3", "gtk"), + ("WARNINGS", "warnings"), + ("WARNINGS_AS_ERRORS", "werror") + ) + for (cmake_flag, option_name) in options: + arg = on_off_condition(args, cmake_flag, option_name) + if arg: + cmake_args.append(arg) + + if args.lcov_zerocounters is not None: + cmake_args.append("-DNS3_COVERAGE_ZERO_COUNTERS=%s" % on_off(args.lcov_zerocounters)) + + # Brite, Click and Openflow + if args.with_brite is not None: + cmake_args.append("-DNS3_WITH_BRITE=%s" % args.with_brite) + + if args.with_click is not None: + cmake_args.append("-DNS3_WITH_CLICK=%s" % args.with_click) + + if args.with_openflow is not None: + cmake_args.append("-DNS3_WITH_OPENFLOW=%s" % args.with_openflow) + + # Build and link visualizer + if args.visualize is not None: + cmake_args.append("-DNS3_VISUALIZER=%s" % on_off(args.visualize)) + + # Process enabled/disabled modules + if args.enable_modules: + cmake_args.append("-DNS3_ENABLED_MODULES=%s" % args.enable_modules) + + if args.disable_modules: + cmake_args.append("-DNS3_DISABLED_MODULES=%s" % args.disable_modules) + + # Try to set specified generator (will probably fail if there is an old cache) + if args.G: + cmake_args.append("-G%s" % args.G) + + if "configure" not in args: + if first_run: + print("You need to configure ns-3 first: try ./ns3 configure") + exit(0) + + # Configure cmake + cmake_args.append("..") # for now, assuming the cmake_cache directory is inside the ns-3-dev folder + + # Echo out the configure command + if verbose: + print("cd %s; %s" % (current_cmake_cache_folder, " ".join(cmake_args))) + + # Run cmake + subprocess.run(cmake_args, cwd=current_cmake_cache_folder, stdout=output) + + return first_run + + +def get_program_shortcuts(ns3_path, build_profile, ns3_version): + build_status_file = os.sep.join([ns3_path, "build", "build-status.py"]) + + # Import programs from build-status.py + programs_dict = {} + exec(open(build_status_file).read(), globals(), programs_dict) + + # We can now build a map to simplify things for users (at this point we could remove versioning prefix/suffix) + ns3_program_map = {} + for program in programs_dict["ns3_runnable_programs"]: + if "pch_exec" in program: + continue + temp_path = program.split("build")[-1].split(os.sep) + # Remove version prefix and buildtype suffix from shortcuts (or keep them too?) + temp_path[-1] = temp_path[-1].replace("-" + build_profile, "").replace("ns" + ns3_version + "-", "") + + # Check if there is a .cc file for that specific program + source_file_path = os.sep.join(temp_path) + ".cc" + source_shortcut = False + if os.path.exists(ns3_path + source_file_path): + source_shortcut = True + + program = program.strip() + while len(temp_path): + # Shortcuts: /src/aodv/examples/aodv can be accessed with aodv/examples/aodv, examples/aodv, aodv + shortcut_path = os.sep.join(temp_path) + ns3_program_map[shortcut_path] = program + if source_shortcut: + ns3_program_map[shortcut_path + ".cc"] = program + temp_path.pop(0) + return ns3_program_map + + +def cmake_build(current_cmake_cache_folder, output, target=None, verbose=False): + cmake_build_command = "cmake --build . -j %d%s" % (os.cpu_count(), (" --target %s" % target) if target else "") + if verbose: + print("cd %s; %s" % (current_cmake_cache_folder, cmake_build_command)) + subprocess.run(cmake_build_command.split(), cwd=current_cmake_cache_folder, stdout=output) + + +def extract_cmakecache_settings(current_cmake_cache_folder): + try: + with open(current_cmake_cache_folder + os.sep + "CMakeCache.txt", "r", encoding="utf-8") as f: + contents = f.read() + except FileNotFoundError as e: + raise e + current_settings = re.findall("(NS3_.*):.*=(.*)", contents) # extract NS3 specific settings + current_settings.extend(re.findall("(CMAKE_BUILD_TYPE):.*=(.*)", contents)) # extract buildtype + current_settings.extend(re.findall("(CMAKE_GENERATOR):.*=(.*)", contents)) # extract generator + + return dict(current_settings) + + +def reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output, verbose=False): + import json + settings_bak_file = "settings.json" + + # Extract settings or recover from the backup + if not os.path.exists(settings_bak_file): + settings = extract_cmakecache_settings(current_cmake_cache_folder) + else: + with open(settings_bak_file, "r", encoding="utf-8") as f: + settings = json.load(f) + + # Delete cache folder and then recreate it + if verbose: + print("rm -R %s; mkdir %s" % current_cmake_cache_folder * 2) + shutil.rmtree(current_cmake_cache_folder) + os.mkdir(current_cmake_cache_folder) + + # Save settings backup to prevent loss + with open(settings_bak_file, "w", encoding="utf-8") as f: + json.dump(settings, f, indent=2) + + # Reconfigure CMake preserving previous NS3 settings + cmake_args = [cmake] + for setting in settings.items(): + if setting[1]: + cmake_args.append("-D%s=%s" % setting) + cmake_args.append("..") + + # Echo out the configure command + if verbose: + print("cd %s; %s" % (current_cmake_cache_folder, " ".join(cmake_args))) + + # Call cmake + ret = subprocess.run(cmake_args, cwd=current_cmake_cache_folder, stdout=output) + + # If it succeeds, delete backup, otherwise raise exception + if ret.returncode == 0: + os.remove(settings_bak_file) + else: + raise Exception("Reconfiguring CMake to force refresh failed. " + "A backup of the settings was saved in %s" % settings_bak_file) + + +def get_target_to_build(program_name, ns3_version, build_profile): + build_profile_suffix = "" if build_profile in ["release"] else "-" + build_profile + return re.findall("%s-(.*)%s" % (ns3_version, build_profile_suffix), program_name)[0] + + +def check_ns3rc_config_file(args): + (config_file_exists, modules_enabled, examples_enabled, tests_enabled) = read_config_file() + if not config_file_exists: + return args + + if not args.enable_modules and len(modules_enabled) > 0 and modules_enabled[0] != "all_modules": + args.enable_modules = ";".join(modules_enabled) + if not args.enable_examples and not args.disable_examples: + if examples_enabled: + args.enable_examples = True + else: + args.disable_examples = True + if not args.enable_tests and not args.disable_tests: + if tests_enabled: + args.enable_tests = True + else: + args.disable_tests = True + return args + + +def configuration_step(ns3_path, current_cmake_cache_folder, current_cmake_generator, args, run_only, configure_and_run, + output): + # There are a few cases where we want to reconfigure/refresh the cmake cache + # MANUALLY (does require ./ns3 configure) + # 1. When we want to change settings (e.g. --enable-something or -DNS3_something=ON in CMake-land) + # AUTOMATICALLY (does not require ./ns3 configure) + # 2. When we want to add/remove source files from modules (e.g. add a new .cc file to a CMakeLists.txt) + + # If we are not only running with --run-no-build or --pyrun-no-build + if not run_only or configure_and_run: + # Create a new cmake_cache folder if one does not exist + if not current_cmake_cache_folder: + current_cmake_cache_folder = ns3_path + os.sep + "cmake_cache" + os.sep + if not os.path.exists(current_cmake_cache_folder): + if args.verbose: + print("mkdir %s" % current_cmake_cache_folder) + os.mkdir(current_cmake_cache_folder) + current_cmake_cache_folder = os.path.abspath(current_cmake_cache_folder) + + # Search for the CMake binary + cmake = shutil.which("cmake") + if not cmake: + raise Exception("CMake was not found") + + # FORCE REFRESH IS ONLY TRIGGERED MANUALLY + # If --force-refresh, we load settings from the CMakeCache, delete it, then reconfigure CMake to + # force refresh cached packages/libraries that were installed/removed, without losing the current settings + if "configure" in args and args.force_refresh: + reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output, args.verbose) + exit(0) + + # Call cmake to configure/reconfigure/refresh the project + first_run = configure_cmake(cmake, + args, + current_cmake_cache_folder, + current_cmake_generator, + output, + args.verbose + ) + + # If manually configuring, we end the script earlier + if "configure" in args: + exit(0) + + return first_run, current_cmake_cache_folder + return False, current_cmake_cache_folder + + +def build_step(args, + configure_and_run, + target_to_run, + current_cmake_cache_folder, + ns3_modules, + ns3_version, + build_profile, + output): + # There are two scenarios where we build everything: ./ns3 build and ./ns3 --check + if args.check or ("build" in args and len(args.build) == 0): + cmake_build(current_cmake_cache_folder, output=output, verbose=args.verbose) + if "build" in args: + # We can exit early if only building + exit(0) + + # If we are building specific targets, we build them one by one + if "build" in args: + # Build targets in the list + for target in args.build: + if target in ns3_modules: + target = "lib" + target + else: + target = os.path.basename(target) # This will get rid of path to the executables + cmake_build(current_cmake_cache_folder, target=target, output=output, verbose=args.verbose) + # We can also exit earlier in this case + exit(0) + + # The remaining case is when we want to build something to run + if configure_and_run: + cmake_build(current_cmake_cache_folder, + target=get_target_to_build(os.path.basename(target_to_run), ns3_version, build_profile), + output=output, + verbose=args.verbose + ) + + +def main(): + # Parse arguments + args = parse_args(sys.argv[1:]) + ns3_path = os.path.dirname(os.path.abspath(__file__)) + output = subprocess.DEVNULL if args.no_task_lines else None + + # no arguments were passed, so can't possibly be reconfiguring anything, then we refresh and rebuild + if len(sys.argv) == 1: + args.build = [] + + # Load settings from config file + args = check_ns3rc_config_file(args) + + # Clean project if needed + if "clean" in args and args.clean: + clean_cmake_artifacts(ns3_path, verbose=args.verbose) + # We end things earlier when cleaning + return + + # Get build profile + build_profile, ns3_version, ns3_modules = check_build_profile(ns3_path) + + # Check if running something or reconfiguring ns-3 + run_only = args.run_no_build or args.pyrun_no_build + configure_and_run = args.run or args.pyrun + target_to_run = None + if not args.check and (run_only or configure_and_run): + target_to_run = max(args.run_no_build, args.pyrun_no_build, args.run, args.pyrun) + if len(target_to_run) > 0: + target_to_run = target_to_run.split() + target_to_run, target_args = target_to_run[0], target_to_run[1:] + else: + raise Exception("You need to specify a program to run") + + # Get current CMake cache folder and CMake generator (used when reconfiguring) + current_cmake_cache_folder, current_cmake_generator = search_cmake_cache(ns3_path, build_profile) + + if args.check_config: + check_config(current_cmake_cache_folder) + # We end things earlier if only checking the current project configuration + return + + first_run, current_cmake_cache_folder = configuration_step(ns3_path, + current_cmake_cache_folder, + current_cmake_generator, + args, + run_only, + configure_and_run, + output + ) + + # re-run build profile check to get up-to-date information before loading the program shortcuts + if first_run: + build_profile, ns3_version, ns3_modules = check_build_profile(ns3_path) + + # We could also replace the "ns3-" prefix used in c4che with the "lib" prefix currently used in cmake + ns3_modules = [module.replace("ns3-", "") for module in ns3_modules] + + # Now that CMake is configured, we can look for c++ targets in build-status.py + ns3_programs = get_program_shortcuts(ns3_path, build_profile, ns3_version) + + # If we have a target to run, replace shortcut with full path or raise exception + if run_only or configure_and_run: + if target_to_run in ns3_programs: + target_to_run = ns3_programs[target_to_run] + else: + raise Exception("Couldn't find the specified program: %s" % target_to_run) + + build_step(args, + configure_and_run, + target_to_run, + current_cmake_cache_folder, + ns3_modules, + ns3_version, + build_profile, + output + ) + + # If we're only trying to run the target, we need to check if it actually exists first + if (run_only or configure_and_run) and not os.path.exists(target_to_run): + raise Exception("Executable has not been built yet") + + # Finally, we try to run it + if args.check or run_only or configure_and_run: + path_sep = ";" if os.name == "nt" else ":" + paths_to_add = path_sep.join(["%s/build/" % ns3_path, + "%s/build/lib" % ns3_path, + "%s/build/bindings/python" % ns3_path, + ]) + proc_env = {"PATH": os.getenv("PATH") + path_sep + paths_to_add, + "LD_LIBRARY_PATH": paths_to_add, + "PYTHON_PATH": paths_to_add, + } + + # running from ns-3-dev (ns3_path) or cwd + working_dir = args.cwd if args.cwd else ns3_path + debugging_software = [] + + # running valgrind? + if args.valgrind: + debugging_software.append(shutil.which("valgrind")) + + # running gdb? + if args.gdb: + debugging_software.extend([shutil.which("gdb"), "--args"]) + + # running with visualizer? + if args.visualize: + target_args.append("--SimulatorImplementationType=ns3::VisualSimulatorImpl") + + # running test.py/check? + if args.check: + target_to_run = ns3_path + os.sep + "test.py" + target_args = ["--nowaf"] + + # running with command template? + if args.command_template: + commands = (args.command_template % target_to_run).split() + target_to_run = commands[0] + target_args = commands[1:] + target_args + + program_arguments = [*debugging_software, target_to_run, *target_args] + + if args.verbose: + exported_variables = "export " + for item in proc_env.items(): + exported_variables += "=".join(item) + " " + print("cd %s; %s; %s" % (working_dir, exported_variables, " ".join(program_arguments))) + + try: + subprocess.run(program_arguments, env=proc_env, cwd=working_dir) + except KeyboardInterrupt: + print("Process was interrupted by the user") + return 0 + + +main() diff --git a/scratch/.gitignore b/scratch/.gitignore index 7932ba266..d29af8d20 100644 --- a/scratch/.gitignore +++ b/scratch/.gitignore @@ -3,3 +3,4 @@ !.gitignore !subdir/ !scratch-simulator.cc +!CMakeLists.txt diff --git a/scratch/CMakeLists.txt b/scratch/CMakeLists.txt new file mode 100644 index 000000000..eb7520812 --- /dev/null +++ b/scratch/CMakeLists.txt @@ -0,0 +1,25 @@ +file(GLOB_RECURSE scratches ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) + +set(DONT_BUILD) + +foreach(scratch_src ${scratches}) + # Get source filename without path or extension + get_filename_component(scratch_name ${scratch_src} NAME) + string(REGEX REPLACE "\\.[^.]*$" "" scratch_name ${scratch_name}) + + # Get source absolute path and transform into relative path + get_filename_component(scratch_absolute_directory ${scratch_src} DIRECTORY) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" scratch_directory ${scratch_absolute_directory}) + + # Build scratch if not listed as a DONT_BUILD + string(FIND "${DONT_BUILD}" "${scratch_name}" res) + if(res LESS 0) + add_executable(${scratch_name} "${scratch_src}") + if(${NS3_STATIC}) + target_link_libraries(${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-ns3-static}) + else() + target_link_libraries(${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}") + endif() + set_runtime_outputdirectory(${scratch_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/scratch/${scratch_directory}/) + endif() +endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..d5b8f2715 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,55 @@ +set(libs "${libs_to_build}") + +# Process the visualizer module first if enabled +if(${ENABLE_VISUALIZER}) + add_subdirectory(visualizer) + list(REMOVE_ITEM libs visualizer) +endif() + +# Process subdirectories +foreach(libname ${libs}) + add_subdirectory(${libname}) +endforeach() + +# Build the lib-ns3-static (ns3.x-static-buildtype.a/.lib) with all sublibraries +if(${NS3_STATIC}) + add_library(${lib-ns3-static} STATIC ${PROJECT_SOURCE_DIR}/buildsupport/empty.cc "${lib-ns3-static-objs}") + + # Replace shared library suffix and check if static version exists before linking + set(ns3-external-static-libs) + foreach(sharedlib ${ns3-external-libs}) + if(NOT (${sharedlib} MATCHES ".so")) + continue() + endif() + + string(REPLACE ".so" ".a" output ${sharedlib}) + if(EXISTS ${output}) + list(APPEND ns3-external-static-libs ${output}) + else() + message(FATAL_ERROR "Static library version of ${sharedlib} was not found") + endif() + endforeach() + + target_link_libraries( + ${lib-ns3-static} + -static + -static-libstdc++ + -static-libgcc + ${LIB_AS_NEEDED_PRE_STATIC} + ${ns3-external-static-libs} + ${LIB_AS_NEEDED_POST_STATIC} + ) + if(${NS3_CLANG_TIMETRACE}) + add_dependencies(timeTraceReport ${lib-ns3-static}) + endif() +endif() + +# Build the lib-ns3-static (ns3.x-monolib-buildtype.dll/.dylib/.so) with all sublibraries +if(${NS3_MONOLIB}) + add_library(${lib-ns3-monolib} SHARED ${PROJECT_SOURCE_DIR}/buildsupport/empty.cc "${lib-ns3-static-objs}") + set_target_properties(${lib-ns3-monolib} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) + target_link_libraries(${lib-ns3-monolib} ${LIB_AS_NEEDED_PRE} ${ns3-external-libs} ${LIB_AS_NEEDED_POST}) + if(${NS3_CLANG_TIMETRACE}) + add_dependencies(timeTraceReport ${lib-ns3-monolib}) + endif() +endif() diff --git a/src/antenna/CMakeLists.txt b/src/antenna/CMakeLists.txt new file mode 100644 index 000000000..9d96bb800 --- /dev/null +++ b/src/antenna/CMakeLists.txt @@ -0,0 +1,32 @@ +set(name antenna) + +set(source_files + model/angles.cc + model/antenna-model.cc + model/cosine-antenna-model.cc + model/isotropic-antenna-model.cc + model/parabolic-antenna-model.cc + model/phased-array-model.cc + model/three-gpp-antenna-model.cc + model/uniform-planar-array.cc +) + +set(header_files + model/angles.h + model/antenna-model.h + model/cosine-antenna-model.h + model/isotropic-antenna-model.h + model/parabolic-antenna-model.h + model/phased-array-model.h + model/three-gpp-antenna-model.h + model/uniform-planar-array.h +) + +# link to dependencies +set(libraries_to_link ${libcore}) + +set(test_sources test/test-angles.cc test/test-degrees-radians.cc test/test-isotropic-antenna.cc + test/test-cosine-antenna.cc test/test-parabolic-antenna.cc test/test-uniform-planar-array.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/aodv/CMakeLists.txt b/src/aodv/CMakeLists.txt new file mode 100644 index 000000000..71b2a6876 --- /dev/null +++ b/src/aodv/CMakeLists.txt @@ -0,0 +1,32 @@ +set(name aodv) + +set(source_files + helper/aodv-helper.cc + model/aodv-dpd.cc + model/aodv-id-cache.cc + model/aodv-neighbor.cc + model/aodv-packet.cc + model/aodv-routing-protocol.cc + model/aodv-rqueue.cc + model/aodv-rtable.cc +) + +set(header_files + helper/aodv-helper.h + model/aodv-dpd.h + model/aodv-id-cache.h + model/aodv-neighbor.h + model/aodv-packet.h + model/aodv-routing-protocol.h + model/aodv-rqueue.h + model/aodv-rtable.h +) + +# link to dependencies +set(libraries_to_link ${libinternet} ${libwifi}) + +set(test_sources test/aodv-id-cache-test-suite.cc test/aodv-regression.cc test/aodv-test-suite.cc test/loopback.cc + test/bug-772.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/aodv/examples/CMakeLists.txt b/src/aodv/examples/CMakeLists.txt new file mode 100644 index 000000000..bae72d1f8 --- /dev/null +++ b/src/aodv/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name aodv) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libinternet} ${libaodv} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/applications/CMakeLists.txt b/src/applications/CMakeLists.txt new file mode 100644 index 000000000..285c05ca9 --- /dev/null +++ b/src/applications/CMakeLists.txt @@ -0,0 +1,62 @@ +set(name applications) + +set(source_files + helper/bulk-send-helper.cc + helper/on-off-helper.cc + helper/packet-sink-helper.cc + helper/three-gpp-http-helper.cc + helper/udp-client-server-helper.cc + helper/udp-echo-helper.cc + model/application-packet-probe.cc + model/bulk-send-application.cc + model/onoff-application.cc + model/packet-loss-counter.cc + model/packet-sink.cc + model/seq-ts-echo-header.cc + model/seq-ts-header.cc + model/seq-ts-size-header.cc + model/three-gpp-http-client.cc + model/three-gpp-http-header.cc + model/three-gpp-http-server.cc + model/three-gpp-http-variables.cc + model/udp-client.cc + model/udp-echo-client.cc + model/udp-echo-server.cc + model/udp-server.cc + model/udp-trace-client.cc +) + +set(header_files + helper/bulk-send-helper.h + helper/on-off-helper.h + helper/packet-sink-helper.h + helper/three-gpp-http-helper.h + helper/udp-client-server-helper.h + helper/udp-echo-helper.h + model/application-packet-probe.h + model/bulk-send-application.h + model/onoff-application.h + model/packet-loss-counter.h + model/packet-sink.h + model/seq-ts-echo-header.h + model/seq-ts-header.h + model/seq-ts-size-header.h + model/three-gpp-http-client.h + model/three-gpp-http-header.h + model/three-gpp-http-server.h + model/three-gpp-http-variables.h + model/udp-client.h + model/udp-echo-client.h + model/udp-echo-server.h + model/udp-server.h + model/udp-trace-client.h +) + +# link to dependencies +set(libraries_to_link ${libinternet} ${libstats}) + +set(test_sources test/three-gpp-http-client-server-test.cc test/bulk-send-application-test-suite.cc + test/udp-client-server-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/applications/examples/CMakeLists.txt b/src/applications/examples/CMakeLists.txt new file mode 100644 index 000000000..86b48826a --- /dev/null +++ b/src/applications/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name three-gpp-http-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libapplications} ${libpoint-to-point} ${libinternet} ${libnetwork}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/bridge/CMakeLists.txt b/src/bridge/CMakeLists.txt new file mode 100644 index 000000000..bc14d81d7 --- /dev/null +++ b/src/bridge/CMakeLists.txt @@ -0,0 +1,12 @@ +set(name bridge) + +set(source_files helper/bridge-helper.cc model/bridge-channel.cc model/bridge-net-device.cc) + +set(header_files helper/bridge-helper.h model/bridge-channel.h model/bridge-net-device.h) + +# link to dependencies +set(libraries_to_link ${libnetwork}) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/bridge/examples/CMakeLists.txt b/src/bridge/examples/CMakeLists.txt new file mode 100644 index 000000000..57195d969 --- /dev/null +++ b/src/bridge/examples/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name csma-bridge) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libbridge} ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name csma-bridge-one-hop) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libbridge} ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/brite/CMakeLists.txt b/src/brite/CMakeLists.txt new file mode 100644 index 000000000..80d9fd8bb --- /dev/null +++ b/src/brite/CMakeLists.txt @@ -0,0 +1,31 @@ +set(NS3_WITH_BRITE "" CACHE PATH "Build with brite support") +set(NS3_BRITE "OFF" CACHE INTERNAL "ON if Brite is found in NS3_WITH_BRITE") +if(NOT NS3_WITH_BRITE) + return() +endif() + +find_library(brite_dep brite PATHS ${NS3_WITH_BRITE} PATH_SUFFIXES /build /build/lib /lib) +find_file(brite_header Brite.h HINTS ${NS3_WITH_BRITE} PATH_SUFFIXES /build /build/include /include) + +if(NOT (brite_dep AND brite_header)) + message(STATUS "Brite was not found in ${NS3_WITH_BRITE}") + return() +endif() + +# Only process module if include folder and library have been found +get_filename_component(brite_include_folder ${brite_header} DIRECTORY) +include_directories(${brite_include_folder}) +set(NS3_BRITE "ON" CACHE INTERNAL "ON if Brite is found in NS3_WITH_BRITE") + +set(name brite) + +set(source_files helper/brite-topology-helper.cc) + +set(header_files helper/brite-topology-helper.h) + +# link to dependencies +set(libraries_to_link ${libnetwork} ${libcore} ${libinternet} ${libpoint-to-point} ${brite_dep}) + +set(test_sources test/brite-test-topology.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/brite/examples/CMakeLists.txt b/src/brite/examples/CMakeLists.txt new file mode 100644 index 000000000..88eb547a9 --- /dev/null +++ b/src/brite/examples/CMakeLists.txt @@ -0,0 +1,22 @@ +set(name brite-generic-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libbrite} ${libinternet} ${libpoint-to-point} ${libnix-vector-routing} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +if(${ENABLE_MPI}) + set(name brite-MPI-example) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link + ${libbrite} + ${libinternet} + ${libpoint-to-point} + ${libnix-vector-routing} + ${libapplications} + ${libmpi} + ${MPI_CXX_LIBRARIES} + ) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + target_include_directories(${name} PUBLIC ${MPI_CXX_INCLUDE_DIRS}) +endif() diff --git a/src/buildings/CMakeLists.txt b/src/buildings/CMakeLists.txt new file mode 100644 index 000000000..e7f516ecd --- /dev/null +++ b/src/buildings/CMakeLists.txt @@ -0,0 +1,49 @@ +set(name buildings) + +set(source_files + helper/building-allocator.cc + helper/building-container.cc + helper/building-position-allocator.cc + helper/buildings-helper.cc + model/building-list.cc + model/building.cc + model/buildings-channel-condition-model.cc + model/buildings-propagation-loss-model.cc + model/hybrid-buildings-propagation-loss-model.cc + model/itu-r-1238-propagation-loss-model.cc + model/mobility-building-info.cc + model/oh-buildings-propagation-loss-model.cc + model/random-walk-2d-outdoor-mobility-model.cc + model/three-gpp-v2v-channel-condition-model.cc +) + +set(header_files + helper/building-allocator.h + helper/building-container.h + helper/building-position-allocator.h + helper/buildings-helper.h + model/building-list.h + model/building.h + model/buildings-channel-condition-model.h + model/buildings-propagation-loss-model.h + model/hybrid-buildings-propagation-loss-model.h + model/itu-r-1238-propagation-loss-model.h + model/mobility-building-info.h + model/oh-buildings-propagation-loss-model.h + model/random-walk-2d-outdoor-mobility-model.h + model/three-gpp-v2v-channel-condition-model.h +) + +set(libraries_to_link ${libmobility} ${libpropagation} ${libconfig-store}) + +set(test_sources + test/building-position-allocator-test.cc + test/buildings-helper-test.cc + test/buildings-pathloss-test.cc + test/buildings-shadowing-test.cc + test/buildings-channel-condition-model-test.cc + test/outdoor-random-walk-test.cc + test/three-gpp-v2v-channel-condition-model-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/buildings/examples/CMakeLists.txt b/src/buildings/examples/CMakeLists.txt new file mode 100644 index 000000000..8d8412e2f --- /dev/null +++ b/src/buildings/examples/CMakeLists.txt @@ -0,0 +1,17 @@ +set(name buildings-pathloss-profiler) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libconfig-store} ${libmobility} ${libbuildings}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name outdoor-group-mobility-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libbuildings}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name outdoor-random-walk-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libbuildings}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/click/CMakeLists.txt b/src/click/CMakeLists.txt new file mode 100644 index 000000000..1ee0bb7a5 --- /dev/null +++ b/src/click/CMakeLists.txt @@ -0,0 +1,39 @@ +set(NS3_WITH_CLICK "" CACHE PATH "Build with click support") +set(NS3_CLICK "OFF" CACHE INTERNAL "ON if Click is found in NS3_WITH_CLICK") + +if(NOT NS3_WITH_CLICK) + return() +endif() + +find_library(click_dep click PATHS ${NS3_WITH_CLICK} PATH_SUFFIXES /build /build/lib /lib) +find_file(click_header simclick.h HINTS ${NS3_WITH_CLICK} PATH_SUFFIXES /build /include /build/include + /build/include/click /include/click +) + +if(NOT (click_dep AND click_header)) + message(STATUS "Click was not found in ${NS3_WITH_CLICK}") + return() +endif() + +get_filename_component(openflow_header_include_folder ${openflow_header} DIRECTORY) # include/click/ (simclick.h) +get_filename_component(openflow_header_include_folder ${openflow_header_include_folder} DIRECTORY) # include/(click) +include_directories(${openflow_header_include_folder}) +set(NS3_CLICK "ON" CACHE INTERNAL "ON if Click is found in NS3_WITH_CLICK") +add_definitions(-DNS3_CLICK) + +set(name click) + +set(source_files helper/click-internet-stack-helper.cc model/ipv4-click-routing.cc model/ipv4-l3-click-protocol.cc) + +set(header_files helper/click-internet-stack-helper.h model/ipv4-click-routing.h model/ipv4-l3-click-protocol.h) + +set(libraries_to_link ${libcore} ${libnetwork} ${libinternet} ${click_dep}) + +set(test_sources test/ipv4-click-routing-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") + +# click install headers when finished and we can't start compiling before that happens +if(NOT ${XCODE}) + add_dependencies(${libclick-obj} ${click_dep}) +endif() diff --git a/src/click/examples/CMakeLists.txt b/src/click/examples/CMakeLists.txt new file mode 100644 index 000000000..677cb1281 --- /dev/null +++ b/src/click/examples/CMakeLists.txt @@ -0,0 +1,37 @@ +link_libraries(click_dep) + +set(name nsclick-simple-lan) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libclick} ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name nsclick-raw-wlan) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libclick} ${libwifi} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name nsclick-udp-client-server-csma) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libclick} ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name nsclick-udp-client-server-wifi) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libclick} ${libwifi} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name nsclick-routing) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libclick} ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name nsclick-defines) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libclick}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/config-store/CMakeLists.txt b/src/config-store/CMakeLists.txt new file mode 100644 index 000000000..1d8e90bee --- /dev/null +++ b/src/config-store/CMakeLists.txt @@ -0,0 +1,35 @@ +set(name config-store) + +if(${GTK3_FOUND}) + set(gtk3_sources model/display-functions.cc model/gtk-config-store.cc model/model-node-creator.cc + model/model-typeid-creator.cc + ) + + set(gtk3_headers model/gtk-config-store.h) + include_directories(${GTK3_INCLUDE_DIRS} ${HarfBuzz_INCLUDE_DIRS}) + set(gtk_libraries ${GTK3_LIBRARIES}) +endif() + +if(${LIBXML2_FOUND}) + set(xml2_sources model/xml-config.cc) + set(xml2_libraries ${LIBXML2_LIBRARIES}) + include_directories(${LIBXML2_INCLUDE_DIR}) +endif() + +set(source_files + ${gtk3_sources} + ${xml2_sources} + model/attribute-default-iterator.cc + model/attribute-iterator.cc + model/config-store.cc + model/file-config.cc + model/raw-text-config.cc +) + +set(header_files ${gtk3_headers} model/file-config.h model/config-store.h) + +set(libraries_to_link ${libcore} ${libnetwork} ${xml2_libraries} ${gtk_libraries}) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/config-store/examples/CMakeLists.txt b/src/config-store/examples/CMakeLists.txt new file mode 100644 index 000000000..195d65239 --- /dev/null +++ b/src/config-store/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name config-store-save) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libconfig-store}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 000000000..2da4fa866 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1,292 @@ +# Set module name +set(name core) + +# Set lib core link dependencies +set(libraries_to_link) + +set(gsl_test_sources) +if(${GSL_FOUND}) + include_directories(${GSL_INCLUDE_DIRS}) + set(libraries_to_link ${libraries_to_link} ${GSL_LIBRARIES}) + set(gsl_test_sources test/rng-test-suite.cc test/random-variable-stream-test-suite.cc) +endif() + +# Check for dependencies and add sources accordingly +check_include_file_cxx("boost/units/quantity.hpp" HAVE_BOOST_UNITS_QUANTITY) +check_include_file_cxx("boost/units/systems/si.hpp" HAVE_BOOST_UNITS_SI) +if(${HAVE_BOOST_UNITS_QUANTITY} AND ${HAVE_BOOST_UNITS_SI}) + add_definitions(-DHAVE_BOOST -DHAVE_BOOST_UNITS) + message(STATUS "Boost Units have been found.") +else() + message(STATUS "Boost Units are an optional feature of length.cc." + " Ubuntu ships it within the libboost-dev package." + " You may need to clean up the CMake cache after installing it to pass this check." + ) +endif() + +set(rt_sources model/realtime-simulator-impl.cc model/wall-clock-synchronizer.cc) +set(rt_headers model/realtime-simulator-impl.h model/wall-clock-synchronizer.h) +if(${ENABLE_REALTIME}) + set(libraries_to_link ${libraries_to_link} ${LIBRT}) +endif() + +set(osclock_sources) +set(osclock_sources model/unix-system-wall-clock-ms.cc) + +set(int64x64_sources) +set(int64x64_headers) + +if(${INT64X64} MATCHES "INT128") + set(int64x64_sources model/int64x64-128.cc) + set(int64x64_headers model/int64x64-128.h) +elseif(${INT64X64} MATCHES "DOUBLE") + set(int64x64_headers model/int64x64-double.h) +elseif(${INT64X64} MATCHES "CAIRO") + set(int64x64_sources model/int64x64-cairo.cc) + set(int64x64_headers model/int64x64-cairo.h model/cairo-wideint-private.h) +endif() + +set(thread_sources) +set(thread_headers) +set(thread_test_sources) + +if(${NS3_PTHREAD}) + if(${THREADS_FOUND}) + set(thread_sources model/unix-fd-reader.cc) + set(thread_headers model/unix-fd-reader.h) + set(thread_sources ${thread_sources} model/system-thread.cc model/unix-system-mutex.cc + model/unix-system-condition.cc + ) + + set(thread_headers ${thread_headers} model/system-mutex.h model/system-thread.h model/system-condition.h) + set(libraries_to_link ${libraries_to_link} pthread) + set(thread_test_sources test/threaded-test-suite.cc) + endif() +endif() + +if(${NS3_EXAMPLES}) + set(example_as_test_sources model/example-as-test.cc) + set(example_as_test_headers model/example-as-test.h) + set(example_as_test_suite test/examples-as-tests-test-suite.cc) +endif() + +# Embedded version support +set(embedded_version_sources) +set(embedded_version_headers) +if(${NS3_ENABLE_BUILD_VERSION}) + set(embedded_version_sources model/version.cc) + set(embedded_version_headers model/version.h) +endif() + +# Define core lib sources +set(source_files + ${rt_sources} + ${osclock_sources} + ${int64x64_sources} + ${thread_sources} + ${valgrind_sources} + ${example_as_test_sources} + ${embedded_version_sources} + helper/csv-reader.cc + helper/random-variable-stream-helper.cc + helper/event-garbage-collector.cc + model/time.cc + model/event-id.cc + model/scheduler.cc + model/list-scheduler.cc + model/map-scheduler.cc + model/heap-scheduler.cc + model/calendar-scheduler.cc + model/priority-queue-scheduler.cc + model/event-impl.cc + model/simulator.cc + model/simulator-impl.cc + model/default-simulator-impl.cc + model/timer.cc + model/watchdog.cc + model/synchronizer.cc + model/make-event.cc + model/log.cc + model/breakpoint.cc + model/type-id.cc + model/attribute-construction-list.cc + model/object-base.cc + model/ref-count-base.cc + model/object.cc + model/test.cc + model/random-variable-stream.cc + model/rng-seed-manager.cc + model/rng-stream.cc + model/command-line.cc + model/type-name.cc + model/attribute.cc + model/boolean.cc + model/integer.cc + model/uinteger.cc + model/enum.cc + model/double.cc + model/int64x64.cc + model/string.cc + model/pointer.cc + model/object-ptr-container.cc + model/object-factory.cc + model/global-value.cc + model/trace-source-accessor.cc + model/config.cc + model/callback.cc + model/names.cc + model/vector.cc + model/fatal-impl.cc + model/system-path.cc + model/hash-function.cc + model/hash-murmur3.cc + model/hash-fnv.cc + model/hash.cc + model/des-metrics.cc + model/ascii-file.cc + model/node-printer.cc + model/show-progress.cc + model/time-printer.cc + model/system-wall-clock-timestamp.cc + model/length.cc + model/trickle-timer.cc +) + +# Define core lib headers +set(header_files + ${rt_headers} + ${int64x64_headers} + ${thread_headers} + ${example_as_test_headers} + ${embedded_version_headers} + helper/csv-reader.h + helper/event-garbage-collector.h + helper/random-variable-stream-helper.h + model/abort.h + model/ascii-file.h + model/ascii-test.h + model/assert.h + model/attribute-accessor-helper.h + model/attribute-construction-list.h + model/attribute-container-accessor-helper.h + model/attribute-container.h + model/attribute-helper.h + model/attribute.h + model/boolean.h + model/breakpoint.h + model/build-profile.h + model/calendar-scheduler.h + model/callback.h + model/command-line.h + model/config.h + model/default-deleter.h + model/default-simulator-impl.h + model/deprecated.h + model/des-metrics.h + model/double.h + model/empty.h + model/enum.h + model/event-id.h + model/event-impl.h + model/fatal-error.h + model/fatal-impl.h + model/global-value.h + model/hash-fnv.h + model/hash-function.h + model/hash-murmur3.h + model/hash.h + model/heap-scheduler.h + model/int-to-type.h + model/int64x64-double.h + model/int64x64.h + model/integer.h + model/length.h + model/list-scheduler.h + model/log-macros-disabled.h + model/log-macros-enabled.h + model/log.h + model/make-event.h + model/map-scheduler.h + model/math.h + model/names.h + model/node-printer.h + model/non-copyable.h + model/nstime.h + model/object-base.h + model/object-factory.h + model/object-map.h + model/object-ptr-container.h + model/object-vector.h + model/object.h + model/pair.h + model/pointer.h + model/priority-queue-scheduler.h + model/ptr.h + model/random-variable-stream.h + model/ref-count-base.h + model/rng-seed-manager.h + model/rng-stream.h + model/scheduler.h + model/show-progress.h + model/simple-ref-count.h + model/simulation-singleton.h + model/simulator-impl.h + model/simulator.h + model/singleton.h + model/string.h + model/synchronizer.h + model/system-path.h + model/system-wall-clock-ms.h + model/system-wall-clock-timestamp.h + model/test.h + model/time-printer.h + model/timer-impl.h + model/timer.h + model/trace-source-accessor.h + model/traced-callback.h + model/traced-value.h + model/trickle-timer.h + model/type-id.h + model/type-name.h + model/type-traits.h + model/uinteger.h + model/unused.h + model/valgrind.h + model/vector.h + model/watchdog.h +) + +set(test_sources + ${example_as_test_suite} + ${gsl_test_sources} + ${thread_test_sources} + test/attribute-container-test-suite.cc + test/attribute-test-suite.cc + test/build-profile-test-suite.cc + test/callback-test-suite.cc + test/command-line-test-suite.cc + test/config-test-suite.cc + test/event-garbage-collector-test-suite.cc + test/global-value-test-suite.cc + test/hash-test-suite.cc + test/int64x64-test-suite.cc + test/length-test-suite.cc + test/many-uniform-random-variables-one-get-value-call-test-suite.cc + test/names-test-suite.cc + test/object-test-suite.cc + test/one-uniform-random-variable-many-get-value-calls-test-suite.cc + test/pair-value-test-suite.cc + test/ptr-test-suite.cc + test/sample-test-suite.cc + test/simulator-test-suite.cc + test/time-test-suite.cc + test/timer-test-suite.cc + test/traced-callback-test-suite.cc + test/trickle-timer-test-suite.cc + test/type-id-test-suite.cc + test/type-traits-test-suite.cc + test/watchdog-test-suite.cc +) + +# Build core lib +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/core/examples/CMakeLists.txt b/src/core/examples/CMakeLists.txt new file mode 100644 index 000000000..2e46f29bd --- /dev/null +++ b/src/core/examples/CMakeLists.txt @@ -0,0 +1,105 @@ +set(name main-callback) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name sample-simulator) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-ptr) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-random-variable-stream) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libconfig-store} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name sample-random-variable) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name sample-random-variable-stream) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name command-line-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name fatal-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name hash-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name sample-log-time-format) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name test-string-value-formatting) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name sample-show-progress) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +if(${NS3_ENABLE_BUILD_VERSION}) + set(name build-version-example) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libcore}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() + +if(${ENABLE_REALTIME}) + set(name main-test-sync) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libnetwork}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() + +set(name length-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name empirical-random-variable-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libflow-monitor}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name system-path-examples) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/core/model/example-as-test.cc b/src/core/model/example-as-test.cc index 835f8f8c8..105aca4a6 100644 --- a/src/core/model/example-as-test.cc +++ b/src/core/model/example-as-test.cc @@ -88,7 +88,7 @@ ExampleAsTestCase::DoRun (void) std::stringstream ss; // Use bash as shell to allow use of PIPESTATUS - ss << "bash -c './waf --run-no-build " << m_program + ss << "bash -c './ns3 --run-no-build " << m_program << " --command-template=\"" << GetCommandTemplate () << "\"" // redirect std::clog, std::cerr to std::cout diff --git a/src/csma-layout/CMakeLists.txt b/src/csma-layout/CMakeLists.txt new file mode 100644 index 000000000..5ed1bc6e3 --- /dev/null +++ b/src/csma-layout/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name csma-layout) + +set(source_files model/csma-star-helper.cc) + +set(header_files model/csma-star-helper.h) + +set(libraries_to_link ${libnetwork} ${libinternet} ${libcsma} ${libpoint-to-point}) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/csma-layout/examples/CMakeLists.txt b/src/csma-layout/examples/CMakeLists.txt new file mode 100644 index 000000000..c5e268c2f --- /dev/null +++ b/src/csma-layout/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name csma-star) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libcsma-layout} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/csma/CMakeLists.txt b/src/csma/CMakeLists.txt new file mode 100644 index 000000000..819c23f9c --- /dev/null +++ b/src/csma/CMakeLists.txt @@ -0,0 +1,13 @@ +set(name csma) + +set(source_files helper/csma-helper.cc model/backoff.cc model/csma-channel.cc model/csma-net-device.cc) + +set(header_files helper/csma-helper.h model/backoff.h model/csma-channel.h model/csma-net-device.h) + +# Set lib csma link dependencies +set(libraries_to_link ${libnetwork}) + +set(test_sources) + +# Build csma lib +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/csma/examples/CMakeLists.txt b/src/csma/examples/CMakeLists.txt new file mode 100644 index 000000000..5235b8eb5 --- /dev/null +++ b/src/csma/examples/CMakeLists.txt @@ -0,0 +1,35 @@ +set(name csma-one-subnet) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name csma-broadcast) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name csma-packet-socket) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name csma-multicast) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name csma-raw-ip-socket) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name csma-ping) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcsma} ${libinternet} ${libapplications} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/dsdv/CMakeLists.txt b/src/dsdv/CMakeLists.txt new file mode 100644 index 000000000..623e99a15 --- /dev/null +++ b/src/dsdv/CMakeLists.txt @@ -0,0 +1,15 @@ +set(name dsdv) + +set(source_files helper/dsdv-helper.cc model/dsdv-packet-queue.cc model/dsdv-packet.cc model/dsdv-routing-protocol.cc + model/dsdv-rtable.cc +) + +set(header_files helper/dsdv-helper.h model/dsdv-packet-queue.h model/dsdv-packet.h model/dsdv-routing-protocol.h + model/dsdv-rtable.h +) + +set(libraries_to_link ${libinternet}) + +set(test_sources test/dsdv-testcase.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/dsdv/examples/CMakeLists.txt b/src/dsdv/examples/CMakeLists.txt new file mode 100644 index 000000000..228ba5a1b --- /dev/null +++ b/src/dsdv/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name dsdv-manet) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libinternet} ${libdsdv} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/dsr/CMakeLists.txt b/src/dsr/CMakeLists.txt new file mode 100644 index 000000000..bf9177288 --- /dev/null +++ b/src/dsr/CMakeLists.txt @@ -0,0 +1,40 @@ +set(name dsr) +set(source_files + helper/dsr-helper.cc + helper/dsr-main-helper.cc + model/dsr-errorbuff.cc + model/dsr-fs-header.cc + model/dsr-gratuitous-reply-table.cc + model/dsr-maintain-buff.cc + model/dsr-network-queue.cc + model/dsr-option-header.cc + model/dsr-options.cc + model/dsr-passive-buff.cc + model/dsr-rcache.cc + model/dsr-routing.cc + model/dsr-rreq-table.cc + model/dsr-rsendbuff.cc +) + +set(header_files + helper/dsr-helper.h + helper/dsr-main-helper.h + model/dsr-errorbuff.h + model/dsr-fs-header.h + model/dsr-gratuitous-reply-table.h + model/dsr-maintain-buff.h + model/dsr-network-queue.h + model/dsr-option-header.h + model/dsr-options.h + model/dsr-passive-buff.h + model/dsr-rcache.h + model/dsr-routing.h + model/dsr-rreq-table.h + model/dsr-rsendbuff.h +) + +set(libraries_to_link ${libinternet} ${libwifi}) + +set(test_sources test/dsr-test-suite.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/dsr/examples/CMakeLists.txt b/src/dsr/examples/CMakeLists.txt new file mode 100644 index 000000000..0a41942b6 --- /dev/null +++ b/src/dsr/examples/CMakeLists.txt @@ -0,0 +1,14 @@ +set(name dsr) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link + ${libcore} + ${libnetwork} + ${libinternet} + ${libapplications} + ${libmobility} + ${libconfig-store} + ${libwifi} + ${libdsr} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/energy/CMakeLists.txt b/src/energy/CMakeLists.txt new file mode 100644 index 000000000..9a325b2aa --- /dev/null +++ b/src/energy/CMakeLists.txt @@ -0,0 +1,47 @@ +set(name energy) + +set(source_files + helper/basic-energy-harvester-helper.cc + helper/basic-energy-source-helper.cc + helper/energy-harvester-container.cc + helper/energy-harvester-helper.cc + helper/energy-model-helper.cc + helper/energy-source-container.cc + helper/li-ion-energy-source-helper.cc + helper/rv-battery-model-helper.cc + model/basic-energy-harvester.cc + model/basic-energy-source.cc + model/device-energy-model-container.cc + model/device-energy-model.cc + model/energy-harvester.cc + model/energy-source.cc + model/li-ion-energy-source.cc + model/rv-battery-model.cc + model/simple-device-energy-model.cc +) + +set(header_files + helper/basic-energy-harvester-helper.h + helper/basic-energy-source-helper.h + helper/energy-harvester-container.h + helper/energy-harvester-helper.h + helper/energy-model-helper.h + helper/energy-source-container.h + helper/li-ion-energy-source-helper.h + helper/rv-battery-model-helper.h + model/basic-energy-harvester.h + model/basic-energy-source.h + model/device-energy-model-container.h + model/device-energy-model.h + model/energy-harvester.h + model/energy-source.h + model/li-ion-energy-source.h + model/rv-battery-model.h + model/simple-device-energy-model.h +) + +set(libraries_to_link ${libnetwork}) + +set(test_sources test/basic-energy-harvester-test.cc test/li-ion-energy-source-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/energy/examples/CMakeLists.txt b/src/energy/examples/CMakeLists.txt new file mode 100644 index 000000000..3f54e99c6 --- /dev/null +++ b/src/energy/examples/CMakeLists.txt @@ -0,0 +1,17 @@ +set(name li-ion-energy-source) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libenergy}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name rv-battery-model-test) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libenergy} ${libwifi}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name basic-energy-model-test) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libenergy} ${libwifi}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/fd-net-device/CMakeLists.txt b/src/fd-net-device/CMakeLists.txt new file mode 100644 index 000000000..60caa4fc0 --- /dev/null +++ b/src/fd-net-device/CMakeLists.txt @@ -0,0 +1,150 @@ +set(name fd-net-device) + +set(ENABLE_THREADING ${HAVE_PTHREAD_H}) + +check_include_file_cxx(net/ethernet.h HAVE_NET_ETHERNET_H) +check_include_file_cxx(netpacket/packet.h HAVE_PACKET_H) +check_include_file_cxx(net/if.h HAVE_IF_NETS_H) +check_include_file_cxx(linux/if_tun.h HAVE_IF_TUN_H) +check_include_file_cxx(net/netmap_user.h HAVE_NETMAP_USER_H) +check_include_file_cxx(sys/ioctl.h HAVE_SYS_IOCTL_H) + +include(FindPkgConfig) +if(PKG_CONFIG_FOUND) + pkg_check_modules(DPDK libdpdk) +endif() + +set(ENABLE_FDNETDEV False CACHE INTERNAL "") +set(ENABLE_DPDKDEVNET False CACHE INTERNAL "") +set(ENABLE_TAP False CACHE INTERNAL "") +set(ENABLE_EMU False CACHE INTERNAL "") +set(ENABLE_NETMAP_EMU False CACHE INTERNAL "") + +if(${THREADS_ENABLED} AND HAVE_NET_ETHERNET_H) + set(ENABLE_FDNETDEV True CACHE INTERNAL "") + + if(PKG_CONFIG_FOUND AND DPDK_FOUND) + set(ENABLE_DPDKDEVNET True CACHE INTERNAL "") + endif() + + if(HAVE_IF_NETS_H + AND HAVE_IF_TUN_H + AND HAVE_SYS_IOCTL_H + AND ${NS3_TAP} + ) + set(ENABLE_TAP True CACHE INTERNAL "") + endif() + + if(HAVE_IF_NETS_H + AND HAVE_PACKET_H + AND HAVE_SYS_IOCTL_H + AND ${NS3_EMU} + ) + set(ENABLE_EMU True CACHE INTERNAL "") + add_definitions(-DHAVE_PACKET_H) + endif() + + if(HAVE_IF_NETS_H AND HAVE_NETMAP_USER_H AND HAVE_SYS_IOCTL_H) + set(ENABLE_NETMAP_EMU True CACHE INTERNAL "") + add_definitions(-DHAVE_NETMAP_USER_H) + endif() +endif() + +if(${ENABLE_FDNETDEV}) + set(fd-net-device_creators) + + macro(exec_name name) + set(${name} ${name}) + endmacro() + + if(${ENABLE_EMU}) + set(emu_sources helper/emu-fd-net-device-helper.cc) + set(emu_headers helper/emu-fd-net-device-helper.h) + + exec_name(raw-sock-creator) + add_executable(raw-sock-creator helper/creator-utils.cc helper/encode-decode.cc helper/raw-sock-creator.cc) + add_definitions(-DRAW_SOCK_CREATOR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${raw-sock-creator}") + set_runtime_outputdirectory(raw-sock-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/) + + list(APPEND fd-net-device_creators raw-sock-creator) + endif() + + if(${ENABLE_TAP}) + set(tap_sources helper/tap-fd-net-device-helper.cc) + set(tap_headers helper/tap-fd-net-device-helper.h) + + exec_name(tap-device-creator) + add_executable(tap-device-creator helper/creator-utils.cc helper/encode-decode.cc helper/tap-device-creator.cc) + add_definitions(-DTAP_DEV_CREATOR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/${tap-device-creator}") + set_runtime_outputdirectory(tap-device-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/) + + list(APPEND fd-net-device_creators tap-device-creator) + endif() + + if(${ENABLE_TAP} AND ${NS3_PLANETLAB}) # todo: find planetlab libraries + set(planetlab_sources helper/planetlab-fd-net-device-helper.cc) + set(planetlab_headers helper/planetlab-fd-net-device-helper.h) + + exec_name(planetlab-tap-creator) + add_executable( + planetlab-tap-creator helper/creator-utils.cc helper/encode-decode.cc helper/planetlab-tap-creator.cc + ) + add_definitions(-DPLANETLAB_TAP_CREATOR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${planetlab-tap-creator}") + target_link_libraries(planetlab-tap-creator ${PLANETLAB_LIBRARIES}) + set_runtime_outputdirectory(planetlab-tap-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/) + + list(APPEND fd-net-device_creators planetlab-tap-creator) + endif() + + if(${ENABLE_NETMAP_EMU}) + set(netmap_sources helper/netmap-net-device-helper.cc model/netmap-net-device.cc) + set(netmap_headers helper/netmap-net-device-helper.h model/netmap-net-device.h) + + exec_name(netmap-device-creator) + add_executable( + netmap-device-creator helper/creator-utils.cc helper/encode-decode.cc helper/netmap-device-creator.cc + ) + add_definitions(-DNETMAP_DEV_CREATOR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${netmap-device-creator}") + set_runtime_outputdirectory(netmap-device-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/) + + list(APPEND fd-net-device_creators netmap-device-creator) + endif() + + if(${ENABLE_DPDKDEVNET}) + set(dpdk_sources model/dpdk-net-device.cc helper/dpdk-net-device-helper.cc) + set(dpdk_headers model/dpdk-net-device.h helper/dpdk-net-device-helper.h) + add_definitions(-DHAVE_DPDK_USER_H) + endif() + + set(source_files + ${tap_sources} + ${emu_sources} + ${planetlab_sources} + ${netmap_sources} + ${dpdk_sources} + helper/creator-utils.cc + helper/encode-decode.cc + helper/fd-net-device-helper.cc + model/fd-net-device.cc + ) + + set(header_files ${tap_headers} ${emu_headers} ${planetlab_headers} ${dpdk_headers} model/fd-net-device.h + helper/fd-net-device-helper.h + ) + + set(libraries_to_link ${libnetwork} ${LIB_AS_NEEDED_PRE} ${DPDK_LIBRARIES} ${LIB_AS_NEEDED_POST}) + + set(test_sources) + + build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") + + if(${ENABLE_DPDKDEVNET}) + target_include_directories(${libfd-net-device-obj} PRIVATE ${DPDK_INCLUDE_DIRS}) + target_compile_options(${libfd-net-device-obj} PRIVATE ${DPDK_CFLAGS}) + endif() + + list(LENGTH fd-net-device_creators num_creators) + if(${num_creators} GREATER 0) + add_dependencies(${libfd-net-device} ${fd-net-device_creators}) + endif() +endif() diff --git a/src/fd-net-device/examples/CMakeLists.txt b/src/fd-net-device/examples/CMakeLists.txt new file mode 100644 index 000000000..b9275d978 --- /dev/null +++ b/src/fd-net-device/examples/CMakeLists.txt @@ -0,0 +1,81 @@ +include_directories(${DPDK_INCLUDE_DIRS}) + +set(name dummy-network) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libfd-net-device} ${libinternet} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name fd2fd-onoff) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libfd-net-device} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +if(${ENABLE_REALTIME}) + set(name realtime-dummy-network) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libinternet-apps}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name realtime-fd2fd-onoff) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libapplications}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() + +if(${ENABLE_EMU}) + set(name fd-emu-ping) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libinternet-apps}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name fd-emu-udp-echo) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libapplications}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name fd-emu-onoff) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libapplications}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name fd-emu-send) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libapplications} ${libinternet-apps} ${libtraffic-control}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name fd-emu-tc) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libapplications} ${libinternet-apps} ${libtraffic-control}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() + +if(${ENABLE_TAP}) + set(name fd-tap-ping) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libinternet-apps}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name fd-tap-ping6) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libinternet-apps} ${libcsma}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() + +if(${NS3_PLANETLAB}) + set(name fd-planetlab-ping) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libfd-net-device} ${libinternet} ${libinternet-apps}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() diff --git a/src/flow-monitor/CMakeLists.txt b/src/flow-monitor/CMakeLists.txt new file mode 100644 index 000000000..dff89e78f --- /dev/null +++ b/src/flow-monitor/CMakeLists.txt @@ -0,0 +1,29 @@ +set(name flow-monitor) + +set(source_files + helper/flow-monitor-helper.cc + model/flow-classifier.cc + model/flow-monitor.cc + model/flow-probe.cc + model/ipv4-flow-classifier.cc + model/ipv4-flow-probe.cc + model/ipv6-flow-classifier.cc + model/ipv6-flow-probe.cc +) + +set(header_files + helper/flow-monitor-helper.h + model/flow-classifier.h + model/flow-monitor.h + model/flow-probe.h + model/ipv4-flow-classifier.h + model/ipv4-flow-probe.h + model/ipv6-flow-classifier.h + model/ipv6-flow-probe.h +) + +set(libraries_to_link ${libinternet} ${libconfig-store}) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/flow-monitor/examples/CMakeLists.txt b/src/flow-monitor/examples/CMakeLists.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/flow-monitor/examples/CMakeLists.txt @@ -0,0 +1 @@ + diff --git a/src/internet-apps/CMakeLists.txt b/src/internet-apps/CMakeLists.txt new file mode 100644 index 000000000..66286bbac --- /dev/null +++ b/src/internet-apps/CMakeLists.txt @@ -0,0 +1,41 @@ +set(name internet-apps) + +set(source_files + helper/dhcp-helper.cc + helper/ping6-helper.cc + helper/radvd-helper.cc + helper/v4ping-helper.cc + helper/v4traceroute-helper.cc + model/dhcp-client.cc + model/dhcp-header.cc + model/dhcp-server.cc + model/ping6.cc + model/radvd-interface.cc + model/radvd-prefix.cc + model/radvd.cc + model/v4ping.cc + model/v4traceroute.cc +) + +set(header_files + helper/dhcp-helper.h + helper/ping6-helper.h + helper/radvd-helper.h + helper/v4ping-helper.h + helper/v4traceroute-helper.h + model/dhcp-client.h + model/dhcp-header.h + model/dhcp-server.h + model/ping6.h + model/radvd-interface.h + model/radvd-prefix.h + model/radvd.h + model/v4ping.h + model/v4traceroute.h +) + +set(libraries_to_link ${libinternet}) + +set(test_sources test/dhcp-test.cc test/ipv6-radvd-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/internet-apps/examples/CMakeLists.txt b/src/internet-apps/examples/CMakeLists.txt new file mode 100644 index 000000000..4ecbcc6bc --- /dev/null +++ b/src/internet-apps/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name dhcp-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libinternet-apps} ${libcsma} ${libpoint-to-point} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt new file mode 100644 index 000000000..c10ba9130 --- /dev/null +++ b/src/internet/CMakeLists.txt @@ -0,0 +1,344 @@ +set(name internet) + +set(nsc_sources) +set(nsc_headers) +if(${NS3_NSC}) + set(nsc_sources nsc-sysctl.cc nsc-tcp-l4-protocol.cc nsc-tcp-socket-factory-impl.cc nsc-tcp-socket-impl.cc) + set(nsc_headers nsc-sysctl.h nsc-tcp-l4-protocol.h nsc-tcp-socket-factory-impl.h nsc-tcp-socket-impl.h) +endif() + +set(source_files + ${nsc_sources} + helper/internet-stack-helper.cc + helper/internet-trace-helper.cc + helper/ipv4-address-helper.cc + helper/ipv4-global-routing-helper.cc + helper/ipv4-interface-container.cc + helper/ipv4-list-routing-helper.cc + helper/ipv4-routing-helper.cc + helper/ipv4-static-routing-helper.cc + helper/ipv6-address-helper.cc + helper/ipv6-interface-container.cc + helper/ipv6-list-routing-helper.cc + helper/ipv6-routing-helper.cc + helper/ipv6-static-routing-helper.cc + helper/rip-helper.cc + helper/ripng-helper.cc + model/arp-cache.cc + model/arp-header.cc + model/arp-l3-protocol.cc + model/arp-queue-disc-item.cc + model/candidate-queue.cc + model/global-route-manager-impl.cc + model/global-route-manager.cc + model/global-router-interface.cc + model/icmpv4-l4-protocol.cc + model/icmpv4.cc + model/icmpv6-header.cc + model/icmpv6-l4-protocol.cc + model/ip-l4-protocol.cc + model/ipv4-address-generator.cc + model/ipv4-end-point-demux.cc + model/ipv4-end-point.cc + model/ipv4-global-routing.cc + model/ipv4-header.cc + model/ipv4-interface-address.cc + model/ipv4-interface.cc + model/ipv4-l3-protocol.cc + model/ipv4-list-routing.cc + model/ipv4-packet-filter.cc + model/ipv4-packet-info-tag.cc + model/ipv4-packet-probe.cc + model/ipv4-queue-disc-item.cc + model/ipv4-raw-socket-factory-impl.cc + model/ipv4-raw-socket-factory.cc + model/ipv4-raw-socket-impl.cc + model/ipv4-route.cc + model/ipv4-routing-protocol.cc + model/ipv4-routing-table-entry.cc + model/ipv4-static-routing.cc + model/ipv4.cc + model/ipv6-address-generator.cc + model/ipv6-autoconfigured-prefix.cc + model/ipv6-end-point-demux.cc + model/ipv6-end-point.cc + model/ipv6-extension-demux.cc + model/ipv6-extension-header.cc + model/ipv6-extension.cc + model/ipv6-header.cc + model/ipv6-interface-address.cc + model/ipv6-interface.cc + model/ipv6-l3-protocol.cc + model/ipv6-list-routing.cc + model/ipv6-option-demux.cc + model/ipv6-option-header.cc + model/ipv6-option.cc + model/ipv6-packet-filter.cc + model/ipv6-packet-info-tag.cc + model/ipv6-packet-probe.cc + model/ipv6-pmtu-cache.cc + model/ipv6-queue-disc-item.cc + model/ipv6-raw-socket-factory-impl.cc + model/ipv6-raw-socket-factory.cc + model/ipv6-raw-socket-impl.cc + model/ipv6-route.cc + model/ipv6-routing-protocol.cc + model/ipv6-routing-table-entry.cc + model/ipv6-static-routing.cc + model/ipv6.cc + model/loopback-net-device.cc + model/ndisc-cache.cc + model/pending-data.cc + model/rip-header.cc + model/rip.cc + model/ripng-header.cc + model/ripng.cc + model/rtt-estimator.cc + model/tcp-bbr.cc + model/tcp-bic.cc + model/tcp-congestion-ops.cc + model/tcp-cubic.cc + model/tcp-dctcp.cc + model/tcp-header.cc + model/tcp-highspeed.cc + model/tcp-htcp.cc + model/tcp-hybla.cc + model/tcp-illinois.cc + model/tcp-l4-protocol.cc + model/tcp-ledbat.cc + model/tcp-linux-reno.cc + model/tcp-lp.cc + model/tcp-option-rfc793.cc + model/tcp-option-sack-permitted.cc + model/tcp-option-sack.cc + model/tcp-option-ts.cc + model/tcp-option-winscale.cc + model/tcp-option.cc + model/tcp-prr-recovery.cc + model/tcp-rate-ops.cc + model/tcp-recovery-ops.cc + model/tcp-rx-buffer.cc + model/tcp-scalable.cc + model/tcp-socket-base.cc + model/tcp-socket-factory-impl.cc + model/tcp-socket-factory.cc + model/tcp-socket-state.cc + model/tcp-socket.cc + model/tcp-tx-buffer.cc + model/tcp-tx-item.cc + model/tcp-vegas.cc + model/tcp-veno.cc + model/tcp-westwood.cc + model/tcp-yeah.cc + model/udp-header.cc + model/udp-l4-protocol.cc + model/udp-socket-factory-impl.cc + model/udp-socket-factory.cc + model/udp-socket-impl.cc + model/udp-socket.cc +) + +set(private_header_files) + +set(header_files + ${header_files} + helper/internet-stack-helper.h + helper/internet-trace-helper.h + helper/ipv4-address-helper.h + helper/ipv4-global-routing-helper.h + helper/ipv4-interface-container.h + helper/ipv4-list-routing-helper.h + helper/ipv4-routing-helper.h + helper/ipv4-static-routing-helper.h + helper/ipv6-address-helper.h + helper/ipv6-interface-container.h + helper/ipv6-list-routing-helper.h + helper/ipv6-routing-helper.h + helper/ipv6-static-routing-helper.h + helper/rip-helper.h + helper/ripng-helper.h + model/arp-cache.h + model/arp-header.h + model/arp-l3-protocol.h + model/arp-queue-disc-item.h + model/candidate-queue.h + model/global-route-manager-impl.h + model/global-route-manager.h + model/global-router-interface.h + model/icmpv4-l4-protocol.h + model/icmpv4.h + model/icmpv6-header.h + model/icmpv6-l4-protocol.h + model/ip-l4-protocol.h + model/ipv4-address-generator.h + model/ipv4-end-point-demux.h + model/ipv4-end-point.h + model/ipv4-global-routing.h + model/ipv4-header.h + model/ipv4-interface-address.h + model/ipv4-interface.h + model/ipv4-l3-protocol.h + model/ipv4-list-routing.h + model/ipv4-packet-filter.h + model/ipv4-packet-info-tag.h + model/ipv4-packet-probe.h + model/ipv4-queue-disc-item.h + model/ipv4-raw-socket-factory.h + model/ipv4-raw-socket-impl.h + model/ipv4-route.h + model/ipv4-routing-protocol.h + model/ipv4-routing-table-entry.h + model/ipv4-static-routing.h + model/ipv4.h + model/ipv6-address-generator.h + model/ipv6-end-point-demux.h + model/ipv6-end-point.h + model/ipv6-extension-demux.h + model/ipv6-extension-header.h + model/ipv6-extension.h + model/ipv6-header.h + model/ipv6-interface-address.h + model/ipv6-interface.h + model/ipv6-l3-protocol.h + model/ipv6-list-routing.h + model/ipv6-option-header.h + model/ipv6-option.h + model/ipv6-packet-filter.h + model/ipv6-packet-info-tag.h + model/ipv6-packet-probe.h + model/ipv6-pmtu-cache.h + model/ipv6-queue-disc-item.h + model/ipv6-raw-socket-factory.h + model/ipv6-route.h + model/ipv6-routing-protocol.h + model/ipv6-routing-table-entry.h + model/ipv6-static-routing.h + model/ipv6.h + model/loopback-net-device.h + model/ndisc-cache.h + model/rip-header.h + model/rip.h + model/ripng-header.h + model/ripng.h + model/rtt-estimator.h + model/tcp-bbr.h + model/tcp-bic.h + model/tcp-congestion-ops.h + model/tcp-cubic.h + model/tcp-dctcp.h + model/tcp-header.h + model/tcp-highspeed.h + model/tcp-htcp.h + model/tcp-hybla.h + model/tcp-illinois.h + model/tcp-l4-protocol.h + model/tcp-ledbat.h + model/tcp-linux-reno.h + model/tcp-lp.h + model/tcp-option-rfc793.h + model/tcp-option-sack-permitted.h + model/tcp-option-sack.h + model/tcp-option-ts.h + model/tcp-option-winscale.h + model/tcp-option.h + model/tcp-prr-recovery.h + model/tcp-rate-ops.h + model/tcp-recovery-ops.h + model/tcp-rx-buffer.h + model/tcp-scalable.h + model/tcp-socket-base.h + model/tcp-socket-factory.h + model/tcp-socket-state.h + model/tcp-socket.h + model/tcp-tx-buffer.h + model/tcp-tx-item.h + model/tcp-vegas.h + model/tcp-veno.h + model/tcp-westwood.h + model/tcp-yeah.h + model/udp-header.h + model/udp-l4-protocol.h + model/udp-socket-factory.h + model/udp-socket-impl.h + model/udp-socket.h + model/windowed-filter.h +) + +set(libraries_to_link ${libnetwork} ${libcore} ${libbridge} ${libtraffic-control}) + +set(test_sources + test/global-route-manager-impl-test-suite.cc + test/icmp-test.cc + test/ipv4-address-generator-test-suite.cc + test/ipv4-address-helper-test-suite.cc + test/ipv4-deduplication-test.cc + test/ipv4-forwarding-test.cc + test/ipv4-fragmentation-test.cc + test/ipv4-global-routing-test-suite.cc + test/ipv4-header-test.cc + test/ipv4-list-routing-test-suite.cc + test/ipv4-packet-info-tag-test-suite.cc + test/ipv4-raw-test.cc + test/ipv4-rip-test.cc + test/ipv4-static-routing-test-suite.cc + test/ipv4-test.cc + test/ipv6-address-duplication-test.cc + test/ipv6-address-generator-test-suite.cc + test/ipv6-address-helper-test-suite.cc + test/ipv6-dual-stack-test-suite.cc + test/ipv6-extension-header-test-suite.cc + test/ipv6-forwarding-test.cc + test/ipv6-fragmentation-test.cc + test/ipv6-list-routing-test-suite.cc + test/ipv6-packet-info-tag-test-suite.cc + test/ipv6-raw-test.cc + test/ipv6-ripng-test.cc + test/ipv6-test.cc + test/rtt-test.cc + test/tcp-advertised-window-test.cc + test/tcp-bbr-test.cc + test/tcp-bic-test.cc + test/tcp-bytes-in-flight-test.cc + test/tcp-classic-recovery-test.cc + test/tcp-close-test.cc + test/tcp-cong-avoid-test.cc + test/tcp-datasentcb-test.cc + test/tcp-dctcp-test.cc + test/tcp-ecn-test.cc + test/tcp-endpoint-bug2211.cc + test/tcp-error-model.cc + test/tcp-fast-retr-test.cc + test/tcp-general-test.cc + test/tcp-header-test.cc + test/tcp-highspeed-test.cc + test/tcp-htcp-test.cc + test/tcp-hybla-test.cc + test/tcp-illinois-test.cc + test/tcp-ledbat-test.cc + test/tcp-linux-reno-test.cc + test/tcp-loss-test.cc + test/tcp-lp-test.cc + test/tcp-option-test.cc + test/tcp-pacing-test.cc + test/tcp-pkts-acked-test.cc + test/tcp-prr-recovery-test.cc + test/tcp-rate-ops-test.cc + test/tcp-rto-test.cc + test/tcp-rtt-estimation.cc + test/tcp-rx-buffer-test.cc + test/tcp-sack-permitted-test.cc + test/tcp-scalable-test.cc + test/tcp-slow-start-test.cc + test/tcp-syn-connection-failed-test.cc + test/tcp-test.cc + test/tcp-timestamp-test.cc + test/tcp-tx-buffer-test.cc + test/tcp-vegas-test.cc + test/tcp-veno-test.cc + test/tcp-wscaling-test.cc + test/tcp-yeah-test.cc + test/tcp-zero-window-test.cc + test/udp-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/internet/examples/CMakeLists.txt b/src/internet/examples/CMakeLists.txt new file mode 100644 index 000000000..79f660dbb --- /dev/null +++ b/src/internet/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name main-simple) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/lr-wpan/CMakeLists.txt b/src/lr-wpan/CMakeLists.txt new file mode 100644 index 000000000..79c46588a --- /dev/null +++ b/src/lr-wpan/CMakeLists.txt @@ -0,0 +1,52 @@ +set(name lr-wpan) + +set(source_files + helper/lr-wpan-helper.cc + model/lr-wpan-csmaca.cc + model/lr-wpan-error-model.cc + model/lr-wpan-fields.cc + model/lr-wpan-interference-helper.cc + model/lr-wpan-lqi-tag.cc + model/lr-wpan-mac-header.cc + model/lr-wpan-mac-pl-headers.cc + model/lr-wpan-mac-trailer.cc + model/lr-wpan-mac.cc + model/lr-wpan-net-device.cc + model/lr-wpan-phy.cc + model/lr-wpan-spectrum-signal-parameters.cc + model/lr-wpan-spectrum-value-helper.cc +) + +set(header_files + helper/lr-wpan-helper.h + model/lr-wpan-csmaca.h + model/lr-wpan-error-model.h + model/lr-wpan-fields.h + model/lr-wpan-interference-helper.h + model/lr-wpan-lqi-tag.h + model/lr-wpan-mac-header.h + model/lr-wpan-mac-pl-headers.h + model/lr-wpan-mac-trailer.h + model/lr-wpan-mac.h + model/lr-wpan-net-device.h + model/lr-wpan-phy.h + model/lr-wpan-spectrum-signal-parameters.h + model/lr-wpan-spectrum-value-helper.h +) + +set(libraries_to_link ${libnetwork} ${libcore} ${libmobility} ${libspectrum} ${libpropagation}) + +set(test_sources + test/lr-wpan-ack-test.cc + test/lr-wpan-cca-test.cc + test/lr-wpan-collision-test.cc + test/lr-wpan-ed-test.cc + test/lr-wpan-error-model-test.cc + test/lr-wpan-packet-test.cc + test/lr-wpan-pd-plme-sap-test.cc + test/lr-wpan-spectrum-value-helper-test.cc + test/lr-wpan-ifs-test.cc + test/lr-wpan-slotted-csmaca-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/lr-wpan/examples/CMakeLists.txt b/src/lr-wpan/examples/CMakeLists.txt new file mode 100644 index 000000000..60f46c3a3 --- /dev/null +++ b/src/lr-wpan/examples/CMakeLists.txt @@ -0,0 +1,29 @@ +set(name lr-wpan-data) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblr-wpan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lr-wpan-error-distance-plot) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblr-wpan} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lr-wpan-error-model-plot) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblr-wpan} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lr-wpan-packet-print) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblr-wpan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lr-wpan-phy-test) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblr-wpan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/lte/CMakeLists.txt b/src/lte/CMakeLists.txt new file mode 100644 index 000000000..08e06e563 --- /dev/null +++ b/src/lte/CMakeLists.txt @@ -0,0 +1,345 @@ +set(name lte) + +if(${NS3_EMU}) + set(emu_sources helper/emu-epc-helper.cc) + set(emu_headers helper/emu-epc-helper.h) + set(emu_libraries ${libfd-net-device}) +endif() + +set(source_files + ${emu_sources} + helper/cc-helper.cc + helper/epc-helper.cc + helper/lte-global-pathloss-database.cc + helper/lte-helper.cc + helper/lte-hex-grid-enb-topology-helper.cc + helper/lte-stats-calculator.cc + helper/mac-stats-calculator.cc + helper/no-backhaul-epc-helper.cc + helper/phy-rx-stats-calculator.cc + helper/phy-stats-calculator.cc + helper/phy-tx-stats-calculator.cc + helper/point-to-point-epc-helper.cc + helper/radio-bearer-stats-calculator.cc + helper/radio-bearer-stats-connector.cc + helper/radio-environment-map-helper.cc + model/a2-a4-rsrq-handover-algorithm.cc + model/a3-rsrp-handover-algorithm.cc + model/component-carrier-enb.cc + model/component-carrier-ue.cc + model/component-carrier.cc + model/cqa-ff-mac-scheduler.cc + model/epc-enb-application.cc + model/epc-enb-s1-sap.cc + model/epc-gtpc-header.cc + model/epc-gtpu-header.cc + model/epc-mme-application.cc + model/epc-pgw-application.cc + model/epc-s11-sap.cc + model/epc-s1ap-sap.cc + model/epc-sgw-application.cc + model/epc-tft-classifier.cc + model/epc-tft.cc + model/epc-ue-nas.cc + model/epc-x2-header.cc + model/epc-x2-sap.cc + model/epc-x2.cc + model/eps-bearer-tag.cc + model/eps-bearer.cc + model/fdbet-ff-mac-scheduler.cc + model/fdmt-ff-mac-scheduler.cc + model/fdtbfq-ff-mac-scheduler.cc + model/ff-mac-common.cc + model/ff-mac-csched-sap.cc + model/ff-mac-sched-sap.cc + model/ff-mac-scheduler.cc + model/lte-amc.cc + model/lte-anr-sap.cc + model/lte-anr.cc + model/lte-as-sap.cc + model/lte-asn1-header.cc + model/lte-ccm-mac-sap.cc + model/lte-ccm-rrc-sap.cc + model/lte-chunk-processor.cc + model/lte-common.cc + model/lte-control-messages.cc + model/lte-enb-cmac-sap.cc + model/lte-enb-component-carrier-manager.cc + model/lte-enb-cphy-sap.cc + model/lte-enb-mac.cc + model/lte-enb-net-device.cc + model/lte-enb-phy-sap.cc + model/lte-enb-phy.cc + model/lte-enb-rrc.cc + model/lte-ffr-algorithm.cc + model/lte-ffr-distributed-algorithm.cc + model/lte-ffr-enhanced-algorithm.cc + model/lte-ffr-rrc-sap.cc + model/lte-ffr-sap.cc + model/lte-ffr-soft-algorithm.cc + model/lte-fr-hard-algorithm.cc + model/lte-fr-no-op-algorithm.cc + model/lte-fr-soft-algorithm.cc + model/lte-fr-strict-algorithm.cc + model/lte-handover-algorithm.cc + model/lte-handover-management-sap.cc + model/lte-harq-phy.cc + model/lte-interference.cc + model/lte-mac-sap.cc + model/lte-mi-error-model.cc + model/lte-net-device.cc + model/lte-pdcp-header.cc + model/lte-pdcp-sap.cc + model/lte-pdcp-tag.cc + model/lte-pdcp.cc + model/lte-phy-tag.cc + model/lte-phy.cc + model/lte-radio-bearer-info.cc + model/lte-radio-bearer-tag.cc + model/lte-rlc-am-header.cc + model/lte-rlc-am.cc + model/lte-rlc-header.cc + model/lte-rlc-sap.cc + model/lte-rlc-sdu-status-tag.cc + model/lte-rlc-sequence-number.cc + model/lte-rlc-tag.cc + model/lte-rlc-tm.cc + model/lte-rlc-um.cc + model/lte-rlc.cc + model/lte-rrc-header.cc + model/lte-rrc-protocol-ideal.cc + model/lte-rrc-protocol-real.cc + model/lte-rrc-sap.cc + model/lte-spectrum-phy.cc + model/lte-spectrum-signal-parameters.cc + model/lte-spectrum-value-helper.cc + model/lte-ue-ccm-rrc-sap.cc + model/lte-ue-cmac-sap.cc + model/lte-ue-component-carrier-manager.cc + model/lte-ue-cphy-sap.cc + model/lte-ue-mac.cc + model/lte-ue-net-device.cc + model/lte-ue-phy-sap.cc + model/lte-ue-phy.cc + model/lte-ue-power-control.cc + model/lte-ue-rrc.cc + model/lte-vendor-specific-parameters.cc + model/no-op-component-carrier-manager.cc + model/no-op-handover-algorithm.cc + model/pf-ff-mac-scheduler.cc + model/pss-ff-mac-scheduler.cc + model/rem-spectrum-phy.cc + model/rr-ff-mac-scheduler.cc + model/simple-ue-component-carrier-manager.cc + model/tdbet-ff-mac-scheduler.cc + model/tdmt-ff-mac-scheduler.cc + model/tdtbfq-ff-mac-scheduler.cc + model/tta-ff-mac-scheduler.cc +) + +set(header_files + ${emu_headers} + helper/cc-helper.h + helper/epc-helper.h + helper/lte-global-pathloss-database.h + helper/lte-helper.h + helper/lte-hex-grid-enb-topology-helper.h + helper/lte-stats-calculator.h + helper/mac-stats-calculator.h + helper/no-backhaul-epc-helper.h + helper/phy-rx-stats-calculator.h + helper/phy-stats-calculator.h + helper/phy-tx-stats-calculator.h + helper/point-to-point-epc-helper.h + helper/radio-bearer-stats-calculator.h + helper/radio-bearer-stats-connector.h + helper/radio-environment-map-helper.h + model/a2-a4-rsrq-handover-algorithm.h + model/a3-rsrp-handover-algorithm.h + model/component-carrier-enb.h + model/component-carrier-ue.h + model/component-carrier.h + model/cqa-ff-mac-scheduler.h + model/epc-enb-application.h + model/epc-enb-s1-sap.h + model/epc-gtpc-header.h + model/epc-gtpu-header.h + model/epc-mme-application.h + model/epc-pgw-application.h + model/epc-s11-sap.h + model/epc-s1ap-sap.h + model/epc-sgw-application.h + model/epc-tft-classifier.h + model/epc-tft.h + model/epc-ue-nas.h + model/epc-x2-header.h + model/epc-x2-sap.h + model/epc-x2.h + model/eps-bearer-tag.h + model/eps-bearer.h + model/fdbet-ff-mac-scheduler.h + model/fdmt-ff-mac-scheduler.h + model/fdtbfq-ff-mac-scheduler.h + model/ff-mac-common.h + model/ff-mac-csched-sap.h + model/ff-mac-sched-sap.h + model/ff-mac-scheduler.h + model/lte-amc.h + model/lte-anr-sap.h + model/lte-anr.h + model/lte-as-sap.h + model/lte-asn1-header.h + model/lte-ccm-mac-sap.h + model/lte-ccm-rrc-sap.h + model/lte-chunk-processor.h + model/lte-common.h + model/lte-control-messages.h + model/lte-enb-cmac-sap.h + model/lte-enb-component-carrier-manager.h + model/lte-enb-cphy-sap.h + model/lte-enb-mac.h + model/lte-enb-net-device.h + model/lte-enb-phy-sap.h + model/lte-enb-phy.h + model/lte-enb-rrc.h + model/lte-ffr-algorithm.h + model/lte-ffr-distributed-algorithm.h + model/lte-ffr-enhanced-algorithm.h + model/lte-ffr-rrc-sap.h + model/lte-ffr-sap.h + model/lte-ffr-soft-algorithm.h + model/lte-fr-hard-algorithm.h + model/lte-fr-no-op-algorithm.h + model/lte-fr-soft-algorithm.h + model/lte-fr-strict-algorithm.h + model/lte-handover-algorithm.h + model/lte-handover-management-sap.h + model/lte-harq-phy.h + model/lte-interference.h + model/lte-mac-sap.h + model/lte-mi-error-model.h + model/lte-net-device.h + model/lte-pdcp-header.h + model/lte-pdcp-sap.h + model/lte-pdcp-tag.h + model/lte-pdcp.h + model/lte-phy-tag.h + model/lte-phy.h + model/lte-radio-bearer-info.h + model/lte-radio-bearer-tag.h + model/lte-rlc-am-header.h + model/lte-rlc-am.h + model/lte-rlc-header.h + model/lte-rlc-sap.h + model/lte-rlc-sdu-status-tag.h + model/lte-rlc-sequence-number.h + model/lte-rlc-tag.h + model/lte-rlc-tm.h + model/lte-rlc-um.h + model/lte-rlc.h + model/lte-rrc-header.h + model/lte-rrc-protocol-ideal.h + model/lte-rrc-protocol-real.h + model/lte-rrc-sap.h + model/lte-spectrum-phy.h + model/lte-spectrum-signal-parameters.h + model/lte-spectrum-value-helper.h + model/lte-ue-ccm-rrc-sap.h + model/lte-ue-cmac-sap.h + model/lte-ue-component-carrier-manager.h + model/lte-ue-cphy-sap.h + model/lte-ue-mac.h + model/lte-ue-net-device.h + model/lte-ue-phy-sap.h + model/lte-ue-phy.h + model/lte-ue-power-control.h + model/lte-ue-rrc.h + model/lte-vendor-specific-parameters.h + model/no-op-component-carrier-manager.h + model/no-op-handover-algorithm.h + model/pf-ff-mac-scheduler.h + model/pss-ff-mac-scheduler.h + model/rem-spectrum-phy.h + model/rr-ff-mac-scheduler.h + model/simple-ue-component-carrier-manager.h + model/tdbet-ff-mac-scheduler.h + model/tdmt-ff-mac-scheduler.h + model/tdtbfq-ff-mac-scheduler.h + model/tta-ff-mac-scheduler.h +) + +set(libraries_to_link + ${emu_libraries} + ${libcore} + ${libnetwork} + ${libspectrum} + ${libstats} + ${libbuildings} + ${libvirtual-net-device} + ${libpoint-to-point} + ${libapplications} + ${libinternet} + ${libcsma} +) + +set(test_sources + test/epc-test-gtpu.cc + test/epc-test-s1u-downlink.cc + test/epc-test-s1u-uplink.cc + test/lte-ffr-simple.cc + test/lte-simple-helper.cc + test/lte-simple-net-device.cc + test/lte-simple-spectrum-phy.cc + test/lte-test-aggregation-throughput-scale.cc + test/lte-test-carrier-aggregation-configuration.cc + test/lte-test-carrier-aggregation.cc + test/lte-test-cell-selection.cc + test/lte-test-cqa-ff-mac-scheduler.cc + test/lte-test-cqi-generation.cc + test/lte-test-deactivate-bearer.cc + test/lte-test-downlink-power-control.cc + test/lte-test-downlink-sinr.cc + test/lte-test-earfcn.cc + test/lte-test-entities.cc + test/lte-test-fdbet-ff-mac-scheduler.cc + test/lte-test-fdmt-ff-mac-scheduler.cc + test/lte-test-fdtbfq-ff-mac-scheduler.cc + test/lte-test-frequency-reuse.cc + test/lte-test-harq.cc + test/lte-test-interference-fr.cc + test/lte-test-interference.cc + test/lte-test-ipv6-routing.cc + test/lte-test-link-adaptation.cc + test/lte-test-mimo.cc + test/lte-test-pathloss-model.cc + test/lte-test-pf-ff-mac-scheduler.cc + test/lte-test-phy-error-model.cc + test/lte-test-pss-ff-mac-scheduler.cc + test/lte-test-radio-link-failure.cc + test/lte-test-rlc-am-e2e.cc + test/lte-test-rlc-am-transmitter.cc + test/lte-test-rlc-um-e2e.cc + test/lte-test-rlc-um-transmitter.cc + test/lte-test-rr-ff-mac-scheduler.cc + test/lte-test-spectrum-value-helper.cc + test/lte-test-tdbet-ff-mac-scheduler.cc + test/lte-test-tdmt-ff-mac-scheduler.cc + test/lte-test-tdtbfq-ff-mac-scheduler.cc + test/lte-test-tta-ff-mac-scheduler.cc + test/lte-test-ue-measurements.cc + test/lte-test-ue-phy.cc + test/lte-test-uplink-power-control.cc + test/lte-test-uplink-sinr.cc + test/test-asn1-encoding.cc + test/test-epc-tft-classifier.cc + test/test-lte-antenna.cc + test/test-lte-epc-e2e-data.cc + test/test-lte-handover-delay.cc + test/test-lte-handover-target.cc + test/test-lte-rlc-header.cc + test/test-lte-rrc.cc + test/test-lte-x2-handover-measures.cc + test/test-lte-x2-handover.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/lte/examples/CMakeLists.txt b/src/lte/examples/CMakeLists.txt new file mode 100644 index 000000000..5aebbc185 --- /dev/null +++ b/src/lte/examples/CMakeLists.txt @@ -0,0 +1,133 @@ +set(name lena-cqi-threshold) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-dual-stripe) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-fading) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-intercell-interference) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-pathloss-traces) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-profiling) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-rem) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-rem-sector-antenna) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-rlc-traces) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-simple) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-simple-epc) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-deactivate-bearer) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-x2-handover) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-x2-handover-measures) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-frequency-reuse) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-distributed-ffr) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-uplink-power-control) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-ipv6-addr-conf) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-ipv6-ue-rh) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-ipv6-ue-ue) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lena-radio-link-failure) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +if(${NS3_EMU}) + set(name lena-simple-epc-emu) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${liblte} ${fd-net-device}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt new file mode 100644 index 000000000..fdd2f121d --- /dev/null +++ b/src/mesh/CMakeLists.txt @@ -0,0 +1,88 @@ +set(name mesh) + +set(source_files + helper/dot11s/dot11s-installer.cc + helper/flame/flame-installer.cc + helper/mesh-helper.cc + helper/mesh-stack-installer.cc + model/dot11s/airtime-metric.cc + model/dot11s/dot11s-mac-header.cc + model/dot11s/hwmp-protocol-mac.cc + model/dot11s/hwmp-protocol.cc + model/dot11s/hwmp-rtable.cc + model/dot11s/hwmp-tag.cc + model/dot11s/ie-dot11s-beacon-timing.cc + model/dot11s/ie-dot11s-configuration.cc + model/dot11s/ie-dot11s-id.cc + model/dot11s/ie-dot11s-metric-report.cc + model/dot11s/ie-dot11s-peer-management.cc + model/dot11s/ie-dot11s-peering-protocol.cc + model/dot11s/ie-dot11s-perr.cc + model/dot11s/ie-dot11s-prep.cc + model/dot11s/ie-dot11s-preq.cc + model/dot11s/ie-dot11s-rann.cc + model/dot11s/peer-link-frame.cc + model/dot11s/peer-link.cc + model/dot11s/peer-management-protocol-mac.cc + model/dot11s/peer-management-protocol.cc + model/flame/flame-header.cc + model/flame/flame-protocol-mac.cc + model/flame/flame-protocol.cc + model/flame/flame-rtable.cc + model/mesh-information-element-vector.cc + model/mesh-l2-routing-protocol.cc + model/mesh-point-device.cc + model/mesh-wifi-beacon.cc + model/mesh-wifi-interface-mac.cc +) + +set(header_files + helper/dot11s/dot11s-installer.h + helper/flame/flame-installer.h + helper/mesh-helper.h + helper/mesh-stack-installer.h + model/dot11s/dot11s-mac-header.h + model/dot11s/hwmp-protocol.h + model/dot11s/hwmp-rtable.h + model/dot11s/ie-dot11s-beacon-timing.h + model/dot11s/ie-dot11s-configuration.h + model/dot11s/ie-dot11s-id.h + model/dot11s/ie-dot11s-metric-report.h + model/dot11s/ie-dot11s-peer-management.h + model/dot11s/ie-dot11s-peering-protocol.h + model/dot11s/ie-dot11s-perr.h + model/dot11s/ie-dot11s-prep.h + model/dot11s/ie-dot11s-preq.h + model/dot11s/ie-dot11s-rann.h + model/dot11s/peer-link-frame.h + model/dot11s/peer-link.h + model/dot11s/peer-management-protocol.h + model/flame/flame-header.h + model/flame/flame-protocol-mac.h + model/flame/flame-protocol.h + model/flame/flame-rtable.h + model/mesh-information-element-vector.h + model/mesh-l2-routing-protocol.h + model/mesh-point-device.h + model/mesh-wifi-beacon.h + model/mesh-wifi-interface-mac-plugin.h + model/mesh-wifi-interface-mac.h +) + +set(libraries_to_link ${libinternet} ${libwifi} ${libapplications}) + +set(test_sources + test/dot11s/dot11s-test-suite.cc + test/dot11s/hwmp-proactive-regression.cc + test/dot11s/hwmp-reactive-regression.cc + test/dot11s/hwmp-simplest-regression.cc + test/dot11s/hwmp-target-flags-regression.cc + test/dot11s/pmp-regression.cc + test/dot11s/regression.cc + test/flame/flame-regression.cc + test/flame/flame-test-suite.cc + test/flame/regression.cc + test/mesh-information-element-vector-test-suite.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/mesh/examples/CMakeLists.txt b/src/mesh/examples/CMakeLists.txt new file mode 100644 index 000000000..9ba81dce0 --- /dev/null +++ b/src/mesh/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name mesh) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libmobility} ${libwifi} ${libmesh} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/mobility/CMakeLists.txt b/src/mobility/CMakeLists.txt new file mode 100644 index 000000000..c970cd381 --- /dev/null +++ b/src/mobility/CMakeLists.txt @@ -0,0 +1,62 @@ +set(name mobility) + +set(source_files + helper/group-mobility-helper.cc + helper/mobility-helper.cc + helper/ns2-mobility-helper.cc + model/box.cc + model/constant-acceleration-mobility-model.cc + model/constant-position-mobility-model.cc + model/constant-velocity-helper.cc + model/constant-velocity-mobility-model.cc + model/gauss-markov-mobility-model.cc + model/geographic-positions.cc + model/hierarchical-mobility-model.cc + model/mobility-model.cc + model/position-allocator.cc + model/random-direction-2d-mobility-model.cc + model/random-walk-2d-mobility-model.cc + model/random-waypoint-mobility-model.cc + model/rectangle.cc + model/steady-state-random-waypoint-mobility-model.cc + model/waypoint-mobility-model.cc + model/waypoint.cc +) + +set(header_files + helper/group-mobility-helper.h + helper/mobility-helper.h + helper/ns2-mobility-helper.h + model/box.h + model/constant-acceleration-mobility-model.h + model/constant-position-mobility-model.h + model/constant-velocity-helper.h + model/constant-velocity-mobility-model.h + model/gauss-markov-mobility-model.h + model/geographic-positions.h + model/hierarchical-mobility-model.h + model/mobility-model.h + model/position-allocator.h + model/random-direction-2d-mobility-model.h + model/random-walk-2d-mobility-model.h + model/random-waypoint-mobility-model.h + model/rectangle.h + model/steady-state-random-waypoint-mobility-model.h + model/waypoint-mobility-model.h + model/waypoint.h +) + +set(libraries_to_link ${libnetwork}) + +set(test_sources + test/box-line-intersection-test.cc + test/geo-to-cartesian-test.cc + test/mobility-test-suite.cc + test/mobility-trace-test-suite.cc + test/ns2-mobility-helper-test-suite.cc + test/rand-cart-around-geo-test.cc + test/steady-state-random-waypoint-mobility-model-test.cc + test/waypoint-mobility-model-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/mobility/examples/CMakeLists.txt b/src/mobility/examples/CMakeLists.txt new file mode 100644 index 000000000..7f7080636 --- /dev/null +++ b/src/mobility/examples/CMakeLists.txt @@ -0,0 +1,41 @@ +set(name bonnmotion-ns2-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-grid-topology) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libnetwork}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-random-topology) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-random-walk) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name mobility-trace-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libnetwork}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name ns2-mobility-trace) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name reference-point-group-mobility-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libmobility}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/mpi/CMakeLists.txt b/src/mpi/CMakeLists.txt new file mode 100644 index 000000000..a4b66b1d4 --- /dev/null +++ b/src/mpi/CMakeLists.txt @@ -0,0 +1,28 @@ +set(name mpi) + +include_directories(${MPI_CXX_INCLUDE_DIRS}) + +set(source_files + model/distributed-simulator-impl.cc + model/granted-time-window-mpi-interface.cc + model/mpi-interface.cc + model/mpi-receiver.cc + model/null-message-mpi-interface.cc + model/null-message-simulator-impl.cc + model/parallel-communication-interface.h + model/remote-channel-bundle-manager.cc + model/remote-channel-bundle.cc +) + +set(header_files model/mpi-interface.h model/mpi-receiver.h model/parallel-communication-interface.h) + +set(libraries_to_link ${libcore} ${libnetwork} ${MPI_CXX_LIBRARIES}) + +set(example_as_test_suite) +if(${NS3_EXAMPLES}) + set(example_as_test_suite test/mpi-test-suite.cc) +endif() + +set(test_sources ${example_as_test_suite}) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/mpi/examples/CMakeLists.txt b/src/mpi/examples/CMakeLists.txt new file mode 100644 index 000000000..7d59033f6 --- /dev/null +++ b/src/mpi/examples/CMakeLists.txt @@ -0,0 +1,40 @@ +include_directories(${MPI_CXX_INCLUDE_DIRS}) +link_libraries(${MPI_CXX_LIBRARIES}) + +set(name simple-distributed) +set(source_files ${name}.cc mpi-test-fixtures.cc) +set(header_files) +set(libraries_to_link ${libmpi} ${libpoint-to-point} ${libinternet} ${libnix-vector-routing} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name third-distributed) +set(source_files ${name}.cc mpi-test-fixtures.cc) +set(header_files) +set(libraries_to_link + ${libmpi} + ${libpoint-to-point} + ${libinternet} + ${libmobility} + ${libwifi} + ${libcsma} + ${libapplications} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name nms-p2p-nix-distributed) +set(source_files ${name}.cc mpi-test-fixtures.cc) +set(header_files) +set(libraries_to_link ${libmpi} ${libpoint-to-point} ${libinternet} ${libnix-vector-routing} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-distributed-empty-node) +set(source_files ${name}.cc mpi-test-fixtures.cc) +set(header_files) +set(libraries_to_link ${libmpi} ${libpoint-to-point} ${libinternet} ${libnix-vector-routing} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-distributed-mpi-comm) +set(source_files ${name}.cc mpi-test-fixtures.cc) +set(header_files) +set(libraries_to_link ${libmpi} ${libpoint-to-point} ${libinternet} ${libnix-vector-routing} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/netanim/CMakeLists.txt b/src/netanim/CMakeLists.txt new file mode 100644 index 000000000..dc19d1e2e --- /dev/null +++ b/src/netanim/CMakeLists.txt @@ -0,0 +1,23 @@ +set(name netanim) + +set(source_files model/animation-interface.cc) + +set(header_files model/animation-interface.h) + +set(libraries_to_link + ${libinternet} + ${libmobility} + ${libwimax} + ${libwifi} + ${libcsma} + ${liblte} + ${libuan} + ${libenergy} + ${liblr-wpan} + ${libwave} + ${libpoint-to-point-layout} +) + +set(test_sources test/netanim-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/netanim/examples/CMakeLists.txt b/src/netanim/examples/CMakeLists.txt new file mode 100644 index 000000000..a21c6bd8a --- /dev/null +++ b/src/netanim/examples/CMakeLists.txt @@ -0,0 +1,49 @@ +set(name dumbbell-animation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetanim} ${libapplications} ${libpoint-to-point-layout}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name grid-animation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetanim} ${libapplications} ${libpoint-to-point-layout}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name star-animation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetanim} ${libapplications} ${libpoint-to-point-layout}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wireless-animation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link + ${libnetanim} + ${libapplications} + ${libpoint-to-point} + ${libcsma} + ${libwifi} + ${libmobility} + ${libnetwork} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name uan-animation) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetanim} ${libinternet} ${libmobility} ${libapplications} ${libuan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name colors-link-description) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetanim} ${libapplications} ${libpoint-to-point-layout}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name resources-counters) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetanim} ${libapplications} ${libpoint-to-point-layout}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt new file mode 100644 index 000000000..d054fb7d2 --- /dev/null +++ b/src/network/CMakeLists.txt @@ -0,0 +1,169 @@ +set(name network) + +set(source_files + helper/application-container.cc + helper/delay-jitter-estimation.cc + helper/net-device-container.cc + helper/node-container.cc + helper/packet-socket-helper.cc + helper/simple-net-device-helper.cc + helper/trace-helper.cc + model/address.cc + model/application.cc + model/buffer.cc + model/byte-tag-list.cc + model/channel-list.cc + model/channel.cc + model/chunk.cc + model/header.cc + model/net-device.cc + model/nix-vector.cc + model/node-list.cc + model/node.cc + model/packet-metadata.cc + model/packet-tag-list.cc + model/packet.cc + model/socket-factory.cc + model/socket.cc + model/tag-buffer.cc + model/tag.cc + model/trailer.cc + utils/address-utils.cc + utils/bit-deserializer.cc + utils/bit-serializer.cc + utils/crc32.cc + utils/data-rate.cc + utils/drop-tail-queue.cc + utils/dynamic-queue-limits.cc + utils/error-channel.cc + utils/error-model.cc + utils/ethernet-header.cc + utils/ethernet-trailer.cc + utils/flow-id-tag.cc + utils/inet-socket-address.cc + utils/inet6-socket-address.cc + utils/ipv4-address.cc + utils/ipv6-address.cc + utils/llc-snap-header.cc + utils/mac16-address.cc + utils/mac48-address.cc + utils/mac64-address.cc + utils/mac8-address.cc + utils/net-device-queue-interface.cc + utils/output-stream-wrapper.cc + utils/packet-burst.cc + utils/packet-data-calculators.cc + utils/packet-probe.cc + utils/packet-socket-address.cc + utils/packet-socket-client.cc + utils/packet-socket-factory.cc + utils/packet-socket-server.cc + utils/packet-socket.cc + utils/packetbb.cc + utils/pcap-file-wrapper.cc + utils/pcap-file.cc + utils/queue-item.cc + utils/queue-limits.cc + utils/queue-size.cc + utils/queue.cc + utils/radiotap-header.cc + utils/simple-channel.cc + utils/simple-net-device.cc + utils/sll-header.cc +) + +set(header_files + helper/application-container.h + helper/delay-jitter-estimation.h + helper/net-device-container.h + helper/node-container.h + helper/packet-socket-helper.h + helper/simple-net-device-helper.h + helper/trace-helper.h + model/address.h + model/application.h + model/buffer.h + model/byte-tag-list.h + model/channel-list.h + model/channel.h + model/chunk.h + model/header.h + model/net-device.h + model/nix-vector.h + model/node-list.h + model/node.h + model/packet-metadata.h + model/packet-tag-list.h + model/packet.h + model/socket-factory.h + model/socket.h + model/tag-buffer.h + model/tag.h + model/trailer.h + utils/address-utils.h + utils/bit-deserializer.h + utils/bit-serializer.h + utils/crc32.h + utils/data-rate.h + utils/drop-tail-queue.h + utils/dynamic-queue-limits.h + utils/error-channel.h + utils/error-model.h + utils/ethernet-header.h + utils/ethernet-trailer.h + utils/flow-id-tag.h + utils/generic-phy.h + utils/inet-socket-address.h + utils/inet6-socket-address.h + utils/ipv4-address.h + utils/ipv6-address.h + utils/llc-snap-header.h + utils/lollipop-counter.h + utils/mac16-address.h + utils/mac48-address.h + utils/mac64-address.h + utils/mac8-address.h + utils/net-device-queue-interface.h + utils/output-stream-wrapper.h + utils/packet-burst.h + utils/packet-data-calculators.h + utils/packet-probe.h + utils/packet-socket-address.h + utils/packet-socket-client.h + utils/packet-socket-factory.h + utils/packet-socket-server.h + utils/packet-socket.h + utils/packetbb.h + utils/pcap-file-wrapper.h + utils/pcap-file.h + utils/pcap-test.h + utils/queue-item.h + utils/queue-limits.h + utils/queue-size.h + utils/queue.h + utils/radiotap-header.h + utils/sequence-number.h + utils/simple-channel.h + utils/simple-net-device.h + utils/sll-header.h +) + +set(libraries_to_link ${libcore} ${libstats}) + +set(test_sources + test/bit-serializer-test.cc + test/buffer-test.cc + test/drop-tail-queue-test-suite.cc + test/error-model-test-suite.cc + test/ipv6-address-test-suite.cc + test/lollipop-counter-test.cc + test/packet-metadata-test.cc + test/packet-socket-apps-test-suite.cc + test/packet-test-suite.cc + test/packetbb-test-suite.cc + test/pcap-file-test-suite.cc + test/sequence-number-test-suite.cc + test/test-data-rate.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/network/examples/CMakeLists.txt b/src/network/examples/CMakeLists.txt new file mode 100644 index 000000000..1c808e5b6 --- /dev/null +++ b/src/network/examples/CMakeLists.txt @@ -0,0 +1,26 @@ +set(header_files) + +set(name bit-serializer) +set(source_files ${name}.cc) +set(libraries_to_link ${libcore} ${libnetwork}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-packet-header) +set(source_files ${name}.cc) +set(libraries_to_link ${libnetwork}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name main-packet-tag) +set(source_files ${name}.cc) +set(libraries_to_link ${libnetwork}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name packet-socket-apps) +set(source_files ${name}.cc) +set(libraries_to_link ${libnetwork} ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name lollipop-comparisions) +set(source_files ${name}.cc) +set(libraries_to_link ${libnetwork} ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/nix-vector-routing/CMakeLists.txt b/src/nix-vector-routing/CMakeLists.txt new file mode 100644 index 000000000..d14c32be6 --- /dev/null +++ b/src/nix-vector-routing/CMakeLists.txt @@ -0,0 +1,13 @@ +set(name nix-vector-routing) + +set(source_files helper/nix-vector-helper.cc model/nix-vector-routing.cc) + +set(header_files helper/nix-vector-helper.h model/nix-vector-routing.h) + +set(deprecated_header_files helper/ipv4-nix-vector-helper.h model/ipv4-nix-vector-routing.h) + +set(libraries_to_link ${libinternet}) + +set(test_sources test/nix-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/nix-vector-routing/examples/CMakeLists.txt b/src/nix-vector-routing/examples/CMakeLists.txt new file mode 100644 index 000000000..c4b16d48a --- /dev/null +++ b/src/nix-vector-routing/examples/CMakeLists.txt @@ -0,0 +1,9 @@ +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libnix-vector-routing}) + +set(nix_examples nix-simple nix-simple-multi-address nms-p2p-nix) + +foreach(example ${nix_examples}) + set(source_files ${example}.cc) + build_lib_example("${example}" "${source_files}" "${header_files}" "${libraries_to_link}") +endforeach() diff --git a/src/olsr/CMakeLists.txt b/src/olsr/CMakeLists.txt new file mode 100644 index 000000000..3a2e5e406 --- /dev/null +++ b/src/olsr/CMakeLists.txt @@ -0,0 +1,15 @@ +set(name olsr) + +set(source_files helper/olsr-helper.cc model/olsr-header.cc model/olsr-routing-protocol.cc model/olsr-state.cc) + +set(header_files helper/olsr-helper.h model/olsr-header.h model/olsr-repositories.h model/olsr-routing-protocol.h + model/olsr-state.h +) + +set(libraries_to_link ${libinternet}) + +set(test_sources test/regression-test-suite.cc test/bug780-test.cc test/hello-regression-test.cc + test/olsr-header-test-suite.cc test/olsr-routing-protocol-test-suite.cc test/tc-regression-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/olsr/examples/CMakeLists.txt b/src/olsr/examples/CMakeLists.txt new file mode 100644 index 000000000..60961ece0 --- /dev/null +++ b/src/olsr/examples/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name olsr-hna) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libwifi} ${libcsma} ${libolsr}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name simple-point-to-point-olsr) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libolsr} ${libapplications} ${libwifi}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/openflow/CMakeLists.txt b/src/openflow/CMakeLists.txt new file mode 100644 index 000000000..bbf9e30a1 --- /dev/null +++ b/src/openflow/CMakeLists.txt @@ -0,0 +1,34 @@ +set(NS3_WITH_OPENFLOW "" CACHE PATH "Build with Openflow support") +set(NS3_OPENFLOW "OFF" CACHE INTERNAL "ON if Openflow is found in NS3_WITH_OPENFLOW") + +if(NOT NS3_WITH_OPENFLOW) + return() +endif() + +find_library(openflow_dep openflow PATHS ${NS3_WITH_OPENFLOW} PATH_SUFFIXES /build /lib /build/lib) +find_file(openflow_header openflow.h HINTS ${NS3_WITH_OPENFLOW} PATH_SUFFIXES /build /include /build/include + /build/include/openflow /include/openflow +) + +if(NOT (openflow_dep AND openflow_header)) + message(STATUS "Openflow was not found in ${NS3_WITH_OPENFLOW}") + return() +endif() + +get_filename_component(openflow_header_include_folder ${openflow_header} DIRECTORY) # include/openflow/ (openflow.h) +get_filename_component(openflow_header_include_folder ${openflow_header_include_folder} DIRECTORY) # include/(openflow) +include_directories(${openflow_header_include_folder}) +add_definitions(-DNS3_OPENFLOW -DENABLE_OPENFLOW) +set(NS3_OPENFLOW "ON" CACHE INTERNAL "ON if Openflow is found in NS3_WITH_OPENFLOW") + +set(name openflow) + +set(source_files helper/openflow-switch-helper.cc model/openflow-interface.cc model/openflow-switch-net-device.cc) + +set(header_files helper/openflow-switch-helper.h model/openflow-interface.h model/openflow-switch-net-device.h) + +set(libraries_to_link ${libinternet} ${openflow_dep}) + +set(test_sources test/openflow-switch-test-suite.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/openflow/examples/CMakeLists.txt b/src/openflow/examples/CMakeLists.txt new file mode 100644 index 000000000..ff2c2836e --- /dev/null +++ b/src/openflow/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name openflow-switch) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libopenflow} ${libinternet} ${libcsma} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/point-to-point-layout/CMakeLists.txt b/src/point-to-point-layout/CMakeLists.txt new file mode 100644 index 000000000..47fda0b46 --- /dev/null +++ b/src/point-to-point-layout/CMakeLists.txt @@ -0,0 +1,9 @@ +set(name point-to-point-layout) + +set(source_files model/point-to-point-dumbbell.cc model/point-to-point-grid.cc model/point-to-point-star.cc) + +set(header_files model/point-to-point-dumbbell.h model/point-to-point-grid.h model/point-to-point-star.h) + +set(libraries_to_link ${libinternet} ${libpoint-to-point} ${libmobility}) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/point-to-point/CMakeLists.txt b/src/point-to-point/CMakeLists.txt new file mode 100644 index 000000000..e20997dd3 --- /dev/null +++ b/src/point-to-point/CMakeLists.txt @@ -0,0 +1,27 @@ +set(name point-to-point) + +set(mpi_sources) +set(mpi_headers) +set(mpi_libraries) +set(mpi_include_directories) + +if(${ENABLE_MPI}) + set(mpi_sources model/point-to-point-remote-channel.cc) + set(mpi_headers model/point-to-point-remote-channel.h) + set(mpi_libraries ${libmpi} ${MPI_CXX_LIBRARIES}) + include_directories(${MPI_CXX_INCLUDE_DIRS}) +endif() + +set(source_files ${mpi_sources} helper/point-to-point-helper.cc model/point-to-point-channel.cc + model/point-to-point-net-device.cc model/ppp-header.cc +) + +set(header_files ${mpi_headers} helper/point-to-point-helper.h model/point-to-point-channel.h + model/point-to-point-net-device.h model/ppp-header.h +) + +set(libraries_to_link ${libnetwork} ${mpi_libraries}) + +set(test_sources test/point-to-point-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/point-to-point/examples/CMakeLists.txt b/src/point-to-point/examples/CMakeLists.txt new file mode 100644 index 000000000..80e18a891 --- /dev/null +++ b/src/point-to-point/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name main-attribute-value) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libpoint-to-point}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/propagation/CMakeLists.txt b/src/propagation/CMakeLists.txt new file mode 100644 index 000000000..831197b3d --- /dev/null +++ b/src/propagation/CMakeLists.txt @@ -0,0 +1,51 @@ +set(name propagation) + +set(source_files + model/channel-condition-model.cc + model/cost231-propagation-loss-model.cc + model/itu-r-1411-los-propagation-loss-model.cc + model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.cc + model/jakes-process.cc + model/jakes-propagation-loss-model.cc + model/kun-2600-mhz-propagation-loss-model.cc + model/okumura-hata-propagation-loss-model.cc + model/probabilistic-v2v-channel-condition-model.cc + model/propagation-delay-model.cc + model/propagation-loss-model.cc + model/three-gpp-propagation-loss-model.cc + model/three-gpp-v2v-propagation-loss-model.cc +) + +set(header_files + model/channel-condition-model.h + model/cost231-propagation-loss-model.h + model/itu-r-1411-los-propagation-loss-model.h + model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h + model/jakes-process.h + model/jakes-propagation-loss-model.h + model/kun-2600-mhz-propagation-loss-model.h + model/okumura-hata-propagation-loss-model.h + model/probabilistic-v2v-channel-condition-model.h + model/propagation-cache.h + model/propagation-delay-model.h + model/propagation-environment.h + model/propagation-loss-model.h + model/three-gpp-propagation-loss-model.h + model/three-gpp-v2v-propagation-loss-model.h +) + +set(libraries_to_link ${libnetwork} ${libmobility}) + +set(test_sources + test/channel-condition-model-test-suite.cc + test/itu-r-1411-los-test-suite.cc + test/itu-r-1411-nlos-over-rooftop-test-suite.cc + test/kun-2600-mhz-test-suite.cc + test/okumura-hata-test-suite.cc + test/probabilistic-v2v-channel-condition-model-test.cc + test/propagation-loss-model-test-suite.cc + test/three-gpp-propagation-loss-model-test-suite.cc + test/three-gpp-propagation-loss-model-test-suite.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/propagation/examples/CMakeLists.txt b/src/propagation/examples/CMakeLists.txt new file mode 100644 index 000000000..24ad92313 --- /dev/null +++ b/src/propagation/examples/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name main-propagation-loss) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpropagation} ${libconfig-store} ${libstats} ${libmobility} ${libbuildings}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name jakes-propagation-model-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libpropagation} ${libbuildings}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/sixlowpan/CMakeLists.txt b/src/sixlowpan/CMakeLists.txt new file mode 100644 index 000000000..65bbb820d --- /dev/null +++ b/src/sixlowpan/CMakeLists.txt @@ -0,0 +1,18 @@ +set(name sixlowpan) + +set(source_files helper/sixlowpan-helper.cc model/sixlowpan-header.cc model/sixlowpan-net-device.cc) + +set(header_files helper/sixlowpan-helper.h model/sixlowpan-header.h model/sixlowpan-net-device.h) + +set(libraries_to_link ${libinternet} ${libinternet} ${libcore}) + +set(example_as_test_suite) +if(${NS3_EXAMPLES}) + set(example_as_test_suite test/sixlowpan-examples-test-suite.cc) +endif() + +set(test_sources ${example_as_test_suite} test/mock-net-device.cc test/sixlowpan-fragmentation-test.cc + test/sixlowpan-hc1-test.cc test/sixlowpan-iphc-stateful-test.cc test/sixlowpan-iphc-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/sixlowpan/examples/CMakeLists.txt b/src/sixlowpan/examples/CMakeLists.txt new file mode 100644 index 000000000..bd28d146a --- /dev/null +++ b/src/sixlowpan/examples/CMakeLists.txt @@ -0,0 +1,23 @@ +set(name example-sixlowpan) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libsixlowpan} ${libinternet} ${libcsma} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name example-ping-lr-wpan) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libsixlowpan} ${libinternet} ${liblr-wpan} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name example-ping-lr-wpan-beacon) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libsixlowpan} ${libinternet} ${liblr-wpan} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name example-ping-lr-wpan-mesh-under) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libsixlowpan} ${libinternet} ${liblr-wpan} ${libinternet-apps} ${libcsma}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/spectrum/CMakeLists.txt b/src/spectrum/CMakeLists.txt new file mode 100644 index 000000000..7c0b4d185 --- /dev/null +++ b/src/spectrum/CMakeLists.txt @@ -0,0 +1,90 @@ +set(name spectrum) + +set(source_files + helper/adhoc-aloha-noack-ideal-phy-helper.cc + helper/spectrum-analyzer-helper.cc + helper/spectrum-helper.cc + helper/tv-spectrum-transmitter-helper.cc + helper/waveform-generator-helper.cc + model/aloha-noack-mac-header.cc + model/aloha-noack-net-device.cc + model/constant-spectrum-propagation-loss.cc + model/friis-spectrum-propagation-loss.cc + model/half-duplex-ideal-phy-signal-parameters.cc + model/half-duplex-ideal-phy.cc + model/matrix-based-channel-model.cc + model/microwave-oven-spectrum-value-helper.cc + model/multi-model-spectrum-channel.cc + model/non-communicating-net-device.cc + model/single-model-spectrum-channel.cc + model/spectrum-analyzer.cc + model/spectrum-channel.cc + model/spectrum-converter.cc + model/spectrum-error-model.cc + model/spectrum-interference.cc + model/spectrum-model-300kHz-300GHz-log.cc + model/spectrum-model-ism2400MHz-res1MHz.cc + model/spectrum-model.cc + model/spectrum-phy.cc + model/spectrum-propagation-loss-model.cc + model/spectrum-signal-parameters.cc + model/spectrum-value.cc + model/three-gpp-channel-model.cc + model/three-gpp-spectrum-propagation-loss-model.cc + model/trace-fading-loss-model.cc + model/tv-spectrum-transmitter.cc + model/waveform-generator.cc + model/wifi-spectrum-value-helper.cc +) + +set(header_files + helper/adhoc-aloha-noack-ideal-phy-helper.h + helper/spectrum-analyzer-helper.h + helper/spectrum-helper.h + helper/tv-spectrum-transmitter-helper.h + helper/waveform-generator-helper.h + model/aloha-noack-mac-header.h + model/aloha-noack-net-device.h + model/constant-spectrum-propagation-loss.h + model/friis-spectrum-propagation-loss.h + model/half-duplex-ideal-phy-signal-parameters.h + model/half-duplex-ideal-phy.h + model/matrix-based-channel-model.h + model/microwave-oven-spectrum-value-helper.h + model/multi-model-spectrum-channel.h + model/non-communicating-net-device.h + model/single-model-spectrum-channel.h + model/spectrum-analyzer.h + model/spectrum-channel.h + model/spectrum-converter.h + model/spectrum-error-model.h + model/spectrum-interference.h + model/spectrum-model-300kHz-300GHz-log.h + model/spectrum-model-ism2400MHz-res1MHz.h + model/spectrum-model.h + model/spectrum-phy.h + model/spectrum-propagation-loss-model.h + model/spectrum-signal-parameters.h + model/spectrum-value.h + model/three-gpp-channel-model.h + model/three-gpp-spectrum-propagation-loss-model.h + model/trace-fading-loss-model.h + model/tv-spectrum-transmitter.h + model/waveform-generator.h + model/wifi-spectrum-value-helper.h + test/spectrum-test.h +) + +set(libraries_to_link ${libpropagation} ${libantenna}) + +set(test_sources + test/spectrum-ideal-phy-test.cc + test/spectrum-interference-test.cc + test/spectrum-value-test.cc + test/spectrum-waveform-generator-test.cc + test/three-gpp-channel-test-suite.cc + test/tv-helper-distribution-test.cc + test/tv-spectrum-transmitter-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/spectrum/examples/CMakeLists.txt b/src/spectrum/examples/CMakeLists.txt new file mode 100644 index 000000000..f845ddfc2 --- /dev/null +++ b/src/spectrum/examples/CMakeLists.txt @@ -0,0 +1,35 @@ +set(name adhoc-aloha-ideal-phy) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libspectrum} ${libmobility} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name adhoc-aloha-ideal-phy-matrix-propagation-loss-model) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libspectrum} ${libmobility} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name adhoc-aloha-ideal-phy-with-microwave-oven) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libspectrum} ${libmobility} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tv-trans-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libspectrum} ${libmobility} ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name tv-trans-regional-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libspectrum} ${libmobility} ${libcore}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name three-gpp-channel-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libspectrum} ${libmobility} ${libcore} ${liblte}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/stats/CMakeLists.txt b/src/stats/CMakeLists.txt new file mode 100644 index 000000000..201121d84 --- /dev/null +++ b/src/stats/CMakeLists.txt @@ -0,0 +1,85 @@ +set(name stats) + +if(${NS3_SQLITE}) + find_package(SQLite3) + check_include_file_cxx(semaphore.h HAVE_SEMAPHORE_H) + if(${SQLite3_FOUND}) + set(sqlite_sources model/sqlite-data-output.cc) + set(sqlite_headers model/sqlite-data-output.h) + + include_directories(${SQLite3_INCLUDE_DIRS}) + set(sqlite_libraries ${SQLite3_LIBRARIES}) + + if(HAVE_SEMAPHORE_H) + list(APPEND sqlite_sources model/sqlite-output.cc) + list(APPEND sqlite_headers model/sqlite-output.h) + endif() + endif() + + if("${SQLite3_FOUND}") + set(ENABLE_SQLITE True CACHE INTERNAL "") + else() + set(ENABLE_SQLITE False CACHE INTERNAL "") + endif() +endif() + +set(source_files + ${sqlite_sources} + helper/file-helper.cc + helper/gnuplot-helper.cc + model/boolean-probe.cc + model/data-calculator.cc + model/data-collection-object.cc + model/data-collector.cc + model/data-output-interface.cc + model/double-probe.cc + model/file-aggregator.cc + model/get-wildcard-matches.cc + model/gnuplot-aggregator.cc + model/gnuplot.cc + model/histogram.cc + model/omnet-data-output.cc + model/probe.cc + model/time-data-calculators.cc + model/time-probe.cc + model/time-series-adaptor.cc + model/uinteger-16-probe.cc + model/uinteger-32-probe.cc + model/uinteger-8-probe.cc +) + +set(header_files + ${sqlite_headers} + helper/file-helper.h + helper/gnuplot-helper.h + model/average.h + model/basic-data-calculators.h + model/boolean-probe.h + model/data-calculator.h + model/data-collection-object.h + model/data-collector.h + model/data-output-interface.h + model/double-probe.h + model/file-aggregator.h + model/get-wildcard-matches.h + model/gnuplot-aggregator.h + model/gnuplot.h + model/histogram.h + model/omnet-data-output.h + model/probe.h + model/stats.h + model/time-data-calculators.h + model/time-probe.h + model/time-series-adaptor.h + model/uinteger-16-probe.h + model/uinteger-32-probe.h + model/uinteger-8-probe.h +) + +set(libraries_to_link ${libcore} ${sqlite_libraries}) + +set(test_sources test/average-test-suite.cc test/basic-data-calculators-test-suite.cc test/double-probe-test-suite.cc + test/histogram-test-suite.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/stats/examples/CMakeLists.txt b/src/stats/examples/CMakeLists.txt new file mode 100644 index 000000000..2b1441f95 --- /dev/null +++ b/src/stats/examples/CMakeLists.txt @@ -0,0 +1,41 @@ +set(name gnuplot-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name double-probe-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name time-probe-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name gnuplot-aggregator-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name gnuplot-helper-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name file-aggregator-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name file-helper-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libnetwork} ${libstats}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/tap-bridge/CMakeLists.txt b/src/tap-bridge/CMakeLists.txt new file mode 100644 index 000000000..d077f9ba2 --- /dev/null +++ b/src/tap-bridge/CMakeLists.txt @@ -0,0 +1,18 @@ +set(name tap-bridge) + +set(source_files helper/tap-bridge-helper.cc model/tap-bridge.cc model/tap-encode-decode.cc) + +set(header_files helper/tap-bridge-helper.h model/tap-bridge.h model/tap-encode-decode.h) + +set(libraries_to_link ${libcore} ${libinternet} ${libnetwork}) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") + +set(tap_creator tap-creator) + +add_definitions(-DTAP_CREATOR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/tap-bridge/${tap_creator}") + +add_executable(tap-creator model/tap-creator.cc model/tap-encode-decode.cc) +set_runtime_outputdirectory(tap-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/tap-bridge/) diff --git a/src/tap-bridge/examples/CMakeLists.txt b/src/tap-bridge/examples/CMakeLists.txt new file mode 100644 index 000000000..24fd68c0b --- /dev/null +++ b/src/tap-bridge/examples/CMakeLists.txt @@ -0,0 +1,26 @@ +if(${NS3_TAP}) + set(name tap-csma) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libcsma} ${libtap-bridge} ${libinternet} ${libwifi}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name tap-csma-virtual-machine) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libcsma} ${libtap-bridge} ${libinternet}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name tap-wifi-virtual-machine) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libcsma} ${libtap-bridge} ${libinternet} ${libwifi} ${libmobility}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + + set(name tap-wifi-dumbbell) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libwifi} ${libcsma} ${libpoint-to-point} ${libtap-bridge} ${libinternet} ${libapplications}) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +endif() diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt new file mode 100644 index 000000000..67e7c4253 --- /dev/null +++ b/src/test/CMakeLists.txt @@ -0,0 +1,64 @@ +set(name test) + +set(nsc_sources) +if(${NS3_NSC}) + set(nsc_sources ns3tcp/ns3tcp-cwnd-test-suite.cc ns3tcp/ns3tcp-interop-test-suite.cc ns3tcp/nsctcp-loss-test-suite.cc) +endif() + +set(csma-layout_sources) +if(csma-layout IN_LIST ns3-all-modules) + set(csma-layout_sources csma-system-test-suite.cc) +endif() + +set(dsr_sources) +if(dsr IN_LIST ns3-all-modules) + set(dsr_sources traced/traced-callback-typedef-test-suite.cc) +endif() + +set(application_sources) +set(wifi_sources) +if(applications IN_LIST ns3-all-modules) + if(point-to-point IN_LIST ns3-all-modules) + set(applications_sources + ns3tcp/ns3tcp-cwnd-test-suite.cc + ns3tcp/ns3tcp-interop-test-suite.cc + ns3tcp/ns3tcp-loss-test-suite.cc + ns3tcp/ns3tcp-no-delay-test-suite.cc + ns3tcp/ns3tcp-socket-test-suite.cc + ns3tcp/ns3tcp-state-test-suite.cc + ns3tcp/nsctcp-loss-test-suite.cc + ) + endif() + if(wifi IN_LIST ns3-all-modules) + set(wifi_sources ns3wifi/wifi-issue-211-test-suite.cc ns3wifi/wifi-ac-mapping-test-suite.cc + ns3wifi/wifi-msdu-aggregator-test-suite.cc + ) + endif() +endif() + +set(internet_sources) +if(internet IN_LIST ns3-all-modules) + set(internet_sources ns3tcp/ns3tcp-socket-writer.cc) + +endif() + +set(traffic-control_sources) +if(traffic-control IN_LIST ns3-all-modules) + set(traffic-control_sources ns3tc/fq-cobalt-queue-disc-test-suite.cc ns3tc/fq-codel-queue-disc-test-suite.cc + ns3tc/fq-pie-queue-disc-test-suite.cc ns3tc/pfifo-fast-queue-disc-test-suite.cc + ) +endif() + +add_library( + ${lib${name}} OBJECT + ${applications_sources} + ${csma-layout_sources} + ${dsr_sources} + ${internet_sources} + ${nsc_sources} + ${traffic-control_sources} + traced/traced-value-callback-typedef-test-suite.cc + ${wifi_sources} +) + +add_dependencies(${libtest} copy_all_headers) diff --git a/src/topology-read/CMakeLists.txt b/src/topology-read/CMakeLists.txt new file mode 100644 index 000000000..a4712c0d0 --- /dev/null +++ b/src/topology-read/CMakeLists.txt @@ -0,0 +1,15 @@ +set(name topology-read) + +set(source_files helper/topology-reader-helper.cc model/inet-topology-reader.cc model/orbis-topology-reader.cc + model/rocketfuel-topology-reader.cc model/topology-reader.cc +) + +set(header_files helper/topology-reader-helper.h model/inet-topology-reader.h model/orbis-topology-reader.h + model/rocketfuel-topology-reader.h model/topology-reader.h +) + +set(libraries_to_link ${libnetwork} ${PCRE_LIBRARIES}) + +set(test_sources test/rocketfuel-topology-reader-test-suite.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/topology-read/examples/CMakeLists.txt b/src/topology-read/examples/CMakeLists.txt new file mode 100644 index 000000000..cef996648 --- /dev/null +++ b/src/topology-read/examples/CMakeLists.txt @@ -0,0 +1,9 @@ +if(PCRE_FOUND) + set(name topology-example-sim) + set(source_files ${name}.cc) + set(header_files) + set(libraries_to_link ${libtopology-read} ${libinternet} ${libnix-vector-routing} ${libpoint-to-point} + ${libapplications} + ) + build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +endif() diff --git a/src/traffic-control/CMakeLists.txt b/src/traffic-control/CMakeLists.txt new file mode 100644 index 000000000..f9dbbb242 --- /dev/null +++ b/src/traffic-control/CMakeLists.txt @@ -0,0 +1,58 @@ +set(name traffic-control) + +set(source_files + helper/queue-disc-container.cc + helper/traffic-control-helper.cc + model/cobalt-queue-disc.cc + model/codel-queue-disc.cc + model/fifo-queue-disc.cc + model/fq-cobalt-queue-disc.cc + model/fq-codel-queue-disc.cc + model/fq-pie-queue-disc.cc + model/mq-queue-disc.cc + model/packet-filter.cc + model/pfifo-fast-queue-disc.cc + model/pie-queue-disc.cc + model/prio-queue-disc.cc + model/queue-disc.cc + model/red-queue-disc.cc + model/tbf-queue-disc.cc + model/traffic-control-layer.cc +) + +set(header_files + helper/queue-disc-container.h + helper/traffic-control-helper.h + model/cobalt-queue-disc.h + model/codel-queue-disc.h + model/fifo-queue-disc.h + model/fq-cobalt-queue-disc.h + model/fq-codel-queue-disc.h + model/fq-pie-queue-disc.h + model/mq-queue-disc.h + model/packet-filter.h + model/pfifo-fast-queue-disc.h + model/pie-queue-disc.h + model/prio-queue-disc.h + model/queue-disc.h + model/red-queue-disc.h + model/tbf-queue-disc.h + model/traffic-control-layer.h +) + +set(libraries_to_link ${libnetwork} ${libcore} ${libconfig-store}) + +set(test_sources + test/adaptive-red-queue-disc-test-suite.cc + test/cobalt-queue-disc-test-suite.cc + test/codel-queue-disc-test-suite.cc + test/fifo-queue-disc-test-suite.cc + test/pie-queue-disc-test-suite.cc + test/prio-queue-disc-test-suite.cc + test/queue-disc-traces-test-suite.cc + test/red-queue-disc-test-suite.cc + test/tbf-queue-disc-test-suite.cc + test/tc-flow-control-test-suite.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/traffic-control/examples/CMakeLists.txt b/src/traffic-control/examples/CMakeLists.txt new file mode 100644 index 000000000..d42ff7509 --- /dev/null +++ b/src/traffic-control/examples/CMakeLists.txt @@ -0,0 +1,53 @@ +set(name red-tests) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor} ${libtraffic-control}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name red-vs-ared) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libpoint-to-point-layout} ${libinternet} ${libapplications} + ${libtraffic-control} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name adaptive-red-tests) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor} ${libtraffic-control}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name pfifo-vs-red) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libpoint-to-point-layout} ${libinternet} ${libapplications} + ${libtraffic-control} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name codel-vs-pfifo-basic-test) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libnetwork} ${libinternet} ${libapplications} ${libtraffic-control}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name codel-vs-pfifo-asymmetric) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libnetwork} ${libinternet} ${libapplications} ${libtraffic-control}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name pie-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libflow-monitor} ${libtraffic-control}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name fqcodel-l4s-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libinternet-apps} ${libapplications} ${libflow-monitor} + ${libtraffic-control} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/uan/CMakeLists.txt b/src/uan/CMakeLists.txt new file mode 100644 index 000000000..e8e95aeb8 --- /dev/null +++ b/src/uan/CMakeLists.txt @@ -0,0 +1,59 @@ +set(name uan) + +set(source_files + helper/acoustic-modem-energy-model-helper.cc + helper/uan-helper.cc + model/acoustic-modem-energy-model.cc + model/uan-channel.cc + model/uan-header-common.cc + model/uan-header-rc.cc + model/uan-mac-aloha.cc + model/uan-mac-cw.cc + model/uan-mac-rc-gw.cc + model/uan-mac-rc.cc + model/uan-mac.cc + model/uan-net-device.cc + model/uan-noise-model-default.cc + model/uan-noise-model.cc + model/uan-phy-dual.cc + model/uan-phy-gen.cc + model/uan-phy.cc + model/uan-prop-model-ideal.cc + model/uan-prop-model-thorp.cc + model/uan-prop-model.cc + model/uan-transducer-hd.cc + model/uan-transducer.cc + model/uan-tx-mode.cc +) + +set(header_files + helper/acoustic-modem-energy-model-helper.h + helper/uan-helper.h + model/acoustic-modem-energy-model.h + model/uan-channel.h + model/uan-header-common.h + model/uan-header-rc.h + model/uan-mac-aloha.h + model/uan-mac-cw.h + model/uan-mac-rc-gw.h + model/uan-mac-rc.h + model/uan-mac.h + model/uan-net-device.h + model/uan-noise-model-default.h + model/uan-noise-model.h + model/uan-phy-dual.h + model/uan-phy-gen.h + model/uan-phy.h + model/uan-prop-model-ideal.h + model/uan-prop-model-thorp.h + model/uan-prop-model.h + model/uan-transducer-hd.h + model/uan-transducer.h + model/uan-tx-mode.h +) + +set(libraries_to_link ${libnetwork} ${libmobility} ${libenergy}) + +set(test_sources test/uan-energy-model-test.cc test/uan-test.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/uan/examples/CMakeLists.txt b/src/uan/examples/CMakeLists.txt new file mode 100644 index 000000000..21b9e4d10 --- /dev/null +++ b/src/uan/examples/CMakeLists.txt @@ -0,0 +1,29 @@ +set(name uan-cw-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libmobility} ${libstats} ${libapplications} ${libuan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name uan-rc-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libmobility} ${libstats} ${libapplications} ${libuan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name uan-6lowpan-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libmobility} ${libstats} ${libapplications} ${libuan} ${libsixlowpan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name uan-ipv4-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libmobility} ${libstats} ${libapplications} ${libuan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name uan-raw-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libinternet} ${libmobility} ${libstats} ${libapplications} ${libuan}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/virtual-net-device/CMakeLists.txt b/src/virtual-net-device/CMakeLists.txt new file mode 100644 index 000000000..df85a2363 --- /dev/null +++ b/src/virtual-net-device/CMakeLists.txt @@ -0,0 +1,11 @@ +set(name virtual-net-device) + +set(source_files model/virtual-net-device.cc) + +set(header_files model/virtual-net-device.h) + +set(libraries_to_link ${libnetwork}) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/virtual-net-device/examples/CMakeLists.txt b/src/virtual-net-device/examples/CMakeLists.txt new file mode 100644 index 000000000..f4579cb12 --- /dev/null +++ b/src/virtual-net-device/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +set(name virtual-net-device) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libvirtual-net-device} ${libpoint-to-point} ${libinternet} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/visualizer/CMakeLists.txt b/src/visualizer/CMakeLists.txt new file mode 100644 index 000000000..09bdf8817 --- /dev/null +++ b/src/visualizer/CMakeLists.txt @@ -0,0 +1,27 @@ +set(name visualizer) + +set(source_files model/pyviz.cc model/visual-simulator-impl.cc) + +set(header_files model/pyviz.h model/visual-simulator-impl.h) + +include_directories(${Python3_INCLUDE_DIRS}) + +set(libraries_to_link + ${Python3_LIBRARIES} + ${libcore} + ${libinternet} + ${libwifi} + ${libpoint-to-point} + ${libcsma} + ${libbridge} + ${libwimax} + ${liblte} + ${libmesh} +) + +set(test_sources) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") + +# move visualizer folder to build/bindings/python, which allows us to add only PYTHONPATH=ns-3-dev/build/bindings/python +file(COPY visualizer DESTINATION ${CMAKE_OUTPUT_DIRECTORY}/bindings/python/) diff --git a/src/visualizer/examples/CMakeLists.txt b/src/visualizer/examples/CMakeLists.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/visualizer/examples/CMakeLists.txt @@ -0,0 +1 @@ + diff --git a/src/wave/CMakeLists.txt b/src/wave/CMakeLists.txt new file mode 100644 index 000000000..d60c3e773 --- /dev/null +++ b/src/wave/CMakeLists.txt @@ -0,0 +1,45 @@ +set(name wave) + +set(source_files + helper/wave-bsm-helper.cc + helper/wave-bsm-stats.cc + helper/wave-helper.cc + helper/wave-mac-helper.cc + helper/wifi-80211p-helper.cc + model/bsm-application.cc + model/channel-coordinator.cc + model/channel-manager.cc + model/channel-scheduler.cc + model/default-channel-scheduler.cc + model/higher-tx-tag.cc + model/ocb-wifi-mac.cc + model/vendor-specific-action.cc + model/vsa-manager.cc + model/wave-frame-exchange-manager.cc + model/wave-net-device.cc +) + +set(header_files + helper/wave-bsm-helper.h + helper/wave-bsm-stats.h + helper/wave-helper.h + helper/wave-mac-helper.h + helper/wifi-80211p-helper.h + model/bsm-application.h + model/channel-coordinator.h + model/channel-manager.h + model/channel-scheduler.h + model/default-channel-scheduler.h + model/higher-tx-tag.h + model/ocb-wifi-mac.h + model/vendor-specific-action.h + model/vsa-manager.h + model/wave-frame-exchange-manager.h + model/wave-net-device.h +) + +set(libraries_to_link ${libcore} ${libpropagation} ${libwifi} ${libinternet}) + +set(test_sources test/mac-extension-test-suite.cc test/ocb-test-suite.cc) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/wave/examples/CMakeLists.txt b/src/wave/examples/CMakeLists.txt new file mode 100644 index 000000000..dfae74682 --- /dev/null +++ b/src/wave/examples/CMakeLists.txt @@ -0,0 +1,30 @@ +set(name wave-simple-80211p) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libapplications} ${libmobility} ${libnetwork} ${libwifi} ${libwave}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wave-simple-device) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libapplications} ${libmobility} ${libnetwork} ${libwifi} ${libwave}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name vanet-routing-compare) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link + ${libcore} + ${libaodv} + ${libapplications} + ${libdsr} + ${libdsdv} + ${libflow-monitor} + ${libmobility} + ${libnetwork} + ${libolsr} + ${libpropagation} + ${libwifi} + ${libwave} +) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt new file mode 100644 index 000000000..a8fa23c98 --- /dev/null +++ b/src/wifi/CMakeLists.txt @@ -0,0 +1,301 @@ +set(name wifi) + +set(source_files + helper/athstats-helper.cc + helper/spectrum-wifi-helper.cc + helper/wifi-helper.cc + helper/wifi-mac-helper.cc + helper/wifi-radio-energy-model-helper.cc + helper/yans-wifi-helper.cc + model/adhoc-wifi-mac.cc + model/ampdu-subframe-header.cc + model/ampdu-tag.cc + model/amsdu-subframe-header.cc + model/ap-wifi-mac.cc + model/block-ack-agreement.cc + model/block-ack-manager.cc + model/block-ack-type.cc + model/block-ack-window.cc + model/capability-information.cc + model/channel-access-manager.cc + model/ctrl-headers.cc + model/edca-parameter-set.cc + model/error-rate-model.cc + model/extended-capabilities.cc + model/frame-capture-model.cc + model/frame-exchange-manager.cc + model/he/constant-obss-pd-algorithm.cc + model/he/he-capabilities.cc + model/he/he-configuration.cc + model/he/he-frame-exchange-manager.cc + model/he/he-operation.cc + model/he/he-phy.cc + model/he/he-ppdu.cc + model/he/he-ru.cc + model/he/mu-edca-parameter-set.cc + model/he/mu-snr-tag.cc + model/he/multi-user-scheduler.cc + model/he/obss-pd-algorithm.cc + model/he/rr-multi-user-scheduler.cc + model/ht/ht-capabilities.cc + model/ht/ht-configuration.cc + model/ht/ht-frame-exchange-manager.cc + model/ht/ht-operation.cc + model/ht/ht-phy.cc + model/ht/ht-ppdu.cc + model/interference-helper.cc + model/mac-rx-middle.cc + model/mac-tx-middle.cc + model/mgt-headers.cc + model/mpdu-aggregator.cc + model/msdu-aggregator.cc + model/nist-error-rate-model.cc + model/non-ht/dsss-error-rate-model.cc + model/non-ht/dsss-parameter-set.cc + model/non-ht/dsss-phy.cc + model/non-ht/dsss-ppdu.cc + model/non-ht/erp-information.cc + model/non-ht/erp-ofdm-phy.cc + model/non-ht/erp-ofdm-ppdu.cc + model/non-ht/ofdm-phy.cc + model/non-ht/ofdm-ppdu.cc + model/originator-block-ack-agreement.cc + model/phy-entity.cc + model/preamble-detection-model.cc + model/qos-blocked-destinations.cc + model/qos-frame-exchange-manager.cc + model/qos-txop.cc + model/qos-utils.cc + model/rate-control/aarf-wifi-manager.cc + model/rate-control/aarfcd-wifi-manager.cc + model/rate-control/amrr-wifi-manager.cc + model/rate-control/aparf-wifi-manager.cc + model/rate-control/arf-wifi-manager.cc + model/rate-control/cara-wifi-manager.cc + model/rate-control/constant-rate-wifi-manager.cc + model/rate-control/ideal-wifi-manager.cc + model/rate-control/minstrel-ht-wifi-manager.cc + model/rate-control/minstrel-wifi-manager.cc + model/rate-control/onoe-wifi-manager.cc + model/rate-control/parf-wifi-manager.cc + model/rate-control/rraa-wifi-manager.cc + model/rate-control/rrpaa-wifi-manager.cc + model/rate-control/thompson-sampling-wifi-manager.cc + model/recipient-block-ack-agreement.cc + model/regular-wifi-mac.cc + model/simple-frame-capture-model.cc + model/snr-tag.cc + model/spectrum-wifi-phy.cc + model/ssid.cc + model/sta-wifi-mac.cc + model/status-code.cc + model/supported-rates.cc + model/table-based-error-rate-model.cc + model/threshold-preamble-detection-model.cc + model/txop.cc + model/vht/vht-capabilities.cc + model/vht/vht-configuration.cc + model/vht/vht-frame-exchange-manager.cc + model/vht/vht-operation.cc + model/vht/vht-phy.cc + model/vht/vht-ppdu.cc + model/wifi-ack-manager.cc + model/wifi-acknowledgment.cc + model/wifi-default-ack-manager.cc + model/wifi-default-protection-manager.cc + model/wifi-information-element-vector.cc + model/wifi-information-element.cc + model/wifi-mac-header.cc + model/wifi-mac-queue-item.cc + model/wifi-mac-queue.cc + model/wifi-mac-trailer.cc + model/wifi-mac.cc + model/wifi-mode.cc + model/wifi-net-device.cc + model/wifi-phy.cc + model/wifi-phy-common.cc + model/wifi-phy-operating-channel.cc + model/wifi-phy-state-helper.cc + model/wifi-ppdu.cc + model/wifi-protection-manager.cc + model/wifi-protection.cc + model/wifi-psdu.cc + model/wifi-radio-energy-model.cc + model/wifi-remote-station-info.cc + model/wifi-remote-station-manager.cc + model/wifi-spectrum-phy-interface.cc + model/wifi-spectrum-signal-parameters.cc + model/wifi-tx-current-model.cc + model/wifi-tx-parameters.cc + model/wifi-tx-timer.cc + model/wifi-tx-vector.cc + model/wifi-utils.cc + model/yans-error-rate-model.cc + model/yans-wifi-channel.cc + model/yans-wifi-phy.cc +) + +set(header_files + helper/athstats-helper.h + helper/spectrum-wifi-helper.h + helper/wifi-helper.h + helper/wifi-mac-helper.h + helper/wifi-radio-energy-model-helper.h + helper/yans-wifi-helper.h + model/adhoc-wifi-mac.h + model/ampdu-subframe-header.h + model/ampdu-tag.h + model/amsdu-subframe-header.h + model/ap-wifi-mac.h + model/block-ack-agreement.h + model/block-ack-manager.h + model/block-ack-type.h + model/block-ack-window.h + model/capability-information.h + model/channel-access-manager.h + model/ctrl-headers.h + model/edca-parameter-set.h + model/error-rate-model.h + model/extended-capabilities.h + model/frame-capture-model.h + model/frame-exchange-manager.h + model/he/constant-obss-pd-algorithm.h + model/he/he-capabilities.h + model/he/he-configuration.h + model/he/he-frame-exchange-manager.h + model/he/he-operation.h + model/he/he-phy.h + model/he/he-ppdu.h + model/he/he-ru.h + model/he/mu-edca-parameter-set.h + model/he/mu-snr-tag.h + model/he/multi-user-scheduler.h + model/he/obss-pd-algorithm.h + model/he/rr-multi-user-scheduler.h + model/ht/ht-capabilities.h + model/ht/ht-configuration.h + model/ht/ht-frame-exchange-manager.h + model/ht/ht-operation.h + model/ht/ht-phy.h + model/ht/ht-ppdu.h + model/interference-helper.h + model/mac-rx-middle.h + model/mac-tx-middle.h + model/mgt-headers.h + model/mpdu-aggregator.h + model/msdu-aggregator.h + model/nist-error-rate-model.h + model/non-ht/dsss-error-rate-model.h + model/non-ht/dsss-parameter-set.h + model/non-ht/dsss-phy.h + model/non-ht/dsss-ppdu.h + model/non-ht/erp-information.h + model/non-ht/erp-ofdm-phy.h + model/non-ht/erp-ofdm-ppdu.h + model/non-ht/ofdm-phy.h + model/non-ht/ofdm-ppdu.h + model/originator-block-ack-agreement.h + model/phy-entity.h + model/preamble-detection-model.h + model/qos-blocked-destinations.h + model/qos-frame-exchange-manager.h + model/qos-txop.h + model/qos-utils.h + model/rate-control/aarf-wifi-manager.h + model/rate-control/aarfcd-wifi-manager.h + model/rate-control/amrr-wifi-manager.h + model/rate-control/aparf-wifi-manager.h + model/rate-control/arf-wifi-manager.h + model/rate-control/cara-wifi-manager.h + model/rate-control/constant-rate-wifi-manager.h + model/rate-control/ideal-wifi-manager.h + model/rate-control/minstrel-ht-wifi-manager.h + model/rate-control/minstrel-wifi-manager.h + model/rate-control/onoe-wifi-manager.h + model/rate-control/parf-wifi-manager.h + model/rate-control/rraa-wifi-manager.h + model/rate-control/rrpaa-wifi-manager.h + model/rate-control/thompson-sampling-wifi-manager.h + model/recipient-block-ack-agreement.h + model/reference/error-rate-tables.h + model/regular-wifi-mac.h + model/simple-frame-capture-model.h + model/snr-tag.h + model/spectrum-wifi-phy.h + model/ssid.h + model/sta-wifi-mac.h + model/status-code.h + model/supported-rates.h + model/table-based-error-rate-model.h + model/threshold-preamble-detection-model.h + model/txop.h + model/vht/vht-capabilities.h + model/vht/vht-configuration.h + model/vht/vht-frame-exchange-manager.h + model/vht/vht-operation.h + model/vht/vht-phy.h + model/vht/vht-ppdu.h + model/wifi-ack-manager.h + model/wifi-acknowledgment.h + model/wifi-default-ack-manager.h + model/wifi-default-protection-manager.h + model/wifi-information-element-vector.h + model/wifi-information-element.h + model/wifi-mac-header.h + model/wifi-mac-queue-item.h + model/wifi-mac-queue.h + model/wifi-mac-trailer.h + model/wifi-mac.h + model/wifi-mode.h + model/wifi-mpdu-type.h + model/wifi-net-device.h + model/wifi-phy-band.h + model/wifi-phy-common.h + model/wifi-phy-listener.h + model/wifi-phy-operating-channel.h + model/wifi-phy-state-helper.h + model/wifi-phy-state.h + model/wifi-phy.h + model/wifi-ppdu.h + model/wifi-protection-manager.h + model/wifi-protection.h + model/wifi-psdu.h + model/wifi-radio-energy-model.h + model/wifi-remote-station-info.h + model/wifi-remote-station-manager.h + model/wifi-spectrum-phy-interface.h + model/wifi-spectrum-signal-parameters.h + model/wifi-standards.h + model/wifi-tx-current-model.h + model/wifi-tx-parameters.h + model/wifi-tx-timer.h + model/wifi-tx-vector.h + model/wifi-utils.h + model/yans-error-rate-model.h + model/yans-wifi-channel.h + model/yans-wifi-phy.h +) + +set(libraries_to_link ${libnetwork} ${libpropagation} ${libenergy} ${libspectrum} ${libantenna} ${libmobility}) + +set(test_sources + test/block-ack-test-suite.cc + test/channel-access-manager-test.cc + test/inter-bss-test-suite.cc + test/power-rate-adaptation-test.cc + test/spectrum-wifi-phy-test.cc + test/tx-duration-test.cc + test/wifi-aggregation-test.cc + test/wifi-error-rate-models-test.cc + test/wifi-mac-ofdma-test.cc + test/wifi-mac-queue-test.cc + test/wifi-phy-ofdma-test.cc + test/wifi-phy-reception-test.cc + test/wifi-phy-thresholds-test.cc + test/wifi-primary-channels-test.cc + test/wifi-test.cc + test/wifi-transmit-mask-test.cc + test/wifi-txop-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/wifi/examples/CMakeLists.txt b/src/wifi/examples/CMakeLists.txt new file mode 100644 index 000000000..8b4474397 --- /dev/null +++ b/src/wifi/examples/CMakeLists.txt @@ -0,0 +1,35 @@ +set(name wifi-phy-test) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libnetwork} ${libwifi}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-test-interference-helper) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libmobility} ${libnetwork} ${libwifi}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-manager-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libnetwork} ${libwifi} ${libstats} ${libmobility} ${libpropagation}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-trans-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libcore} ${libnetwork} ${libwifi} ${libstats} ${libmobility} ${libpropagation}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-phy-configuration) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libconfig-store}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wifi-bianchi) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwifi} ${libapplications} ${libinternet-apps}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/wimax/CMakeLists.txt b/src/wimax/CMakeLists.txt new file mode 100644 index 000000000..f2ef29698 --- /dev/null +++ b/src/wimax/CMakeLists.txt @@ -0,0 +1,113 @@ +set(name wimax) + +set(source_files + helper/wimax-helper.cc + model/cid.cc + model/cid-factory.cc + model/wimax-net-device.cc + model/bs-net-device.cc + model/ss-net-device.cc + model/wimax-mac-header.cc + model/wimax-phy.cc + model/wimax-channel.cc + model/ofdm-downlink-frame-prefix.cc + model/wimax-connection.cc + model/ss-record.cc + model/mac-messages.cc + model/dl-mac-messages.cc + model/ul-mac-messages.cc + model/simple-ofdm-wimax-phy.cc + model/simple-ofdm-wimax-channel.cc + model/send-params.cc + model/ss-manager.cc + model/connection-manager.cc + model/bs-uplink-scheduler.cc + model/bs-uplink-scheduler-simple.cc + model/bs-uplink-scheduler-mbqos.cc + model/bs-uplink-scheduler-rtps.cc + model/bs-scheduler.cc + model/bs-scheduler-simple.cc + model/bs-scheduler-rtps.cc + model/wimax-mac-queue.cc + model/burst-profile-manager.cc + model/ss-scheduler.cc + model/service-flow.cc + model/service-flow-manager.cc + model/service-flow-record.cc + model/ss-link-manager.cc + model/bs-link-manager.cc + model/bandwidth-manager.cc + model/crc8.cc + model/ul-job.cc + model/snr-to-block-error-rate-record.cc + model/snr-to-block-error-rate-manager.cc + model/simple-ofdm-send-param.cc + model/ss-service-flow-manager.cc + model/bs-service-flow-manager.cc + model/ipcs-classifier.cc + model/ipcs-classifier-record.cc + model/wimax-tlv.cc + model/cs-parameters.cc + model/wimax-mac-to-mac-header.cc +) + +set(header_files + helper/wimax-helper.h + model/wimax-channel.h + model/wimax-net-device.h + model/bs-net-device.h + model/ss-net-device.h + model/cid.h + model/cid-factory.h + model/ofdm-downlink-frame-prefix.h + model/wimax-connection.h + model/ss-record.h + model/mac-messages.h + model/dl-mac-messages.h + model/ul-mac-messages.h + model/wimax-phy.h + model/simple-ofdm-wimax-phy.h + model/simple-ofdm-wimax-channel.h + model/send-params.h + model/service-flow.h + model/ss-manager.h + model/connection-manager.h + model/wimax-mac-header.h + model/wimax-mac-queue.h + model/crc8.h + model/service-flow-manager.h + model/bs-uplink-scheduler.h + model/bs-uplink-scheduler-simple.h + model/bs-uplink-scheduler-mbqos.h + model/bs-uplink-scheduler-rtps.h + model/ul-job.h + model/bs-scheduler.h + model/bs-scheduler-simple.h + model/bs-scheduler-rtps.h + model/service-flow-record.h + model/snr-to-block-error-rate-record.h + model/snr-to-block-error-rate-manager.h + model/simple-ofdm-send-param.h + model/ss-service-flow-manager.h + model/bs-service-flow-manager.h + model/cs-parameters.h + model/ipcs-classifier-record.h + model/wimax-tlv.h + model/ipcs-classifier.h + model/bvec.h + model/wimax-mac-to-mac-header.h +) + +set(libraries_to_link ${libnetwork} ${libinternet} ${libpropagation} ${libmobility}) + +set(test_sources + test/mac-messages-test.cc + test/phy-test.cc + test/qos-test.cc + test/ss-mac-test.cc + test/wimax-fragmentation-test.cc + test/wimax-service-flow-test.cc + test/wimax-tlv-test.cc +) + +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") diff --git a/src/wimax/examples/CMakeLists.txt b/src/wimax/examples/CMakeLists.txt new file mode 100644 index 000000000..8dfa9c1d8 --- /dev/null +++ b/src/wimax/examples/CMakeLists.txt @@ -0,0 +1,17 @@ +set(name wimax-ipv4) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwimax} ${libinternet} ${libmobility} ${libcsma} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wimax-multicast) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwimax} ${libinternet} ${libcsma} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + +set(name wimax-simple) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link ${libwimax} ${libinternet} ${libmobility} ${libapplications}) +build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 000000000..a028c4f90 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,30 @@ +if(${NS3_TESTS}) + add_executable(test-runner $ test-runner.cc) + + if(${NS3_MONOLIB}) + target_link_libraries( + test-runner ${LIB_AS_NEEDED_PRE} ${ns3-libs-tests} ${LIB_AS_NEEDED_POST} ${lib-ns3-monolib} ${ns3-contrib-libs} + ) + else() + target_link_libraries( + test-runner ${LIB_AS_NEEDED_PRE} ${ns3-libs-tests} ${LIB_AS_NEEDED_POST} ${ns3-libs} ${ns3-contrib-libs} + ) + endif() + set_runtime_outputdirectory(test-runner ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/utils/) + if(${NS3_TESTS}) + add_dependencies(all-test-targets test-runner) + endif() + + add_executable(bench-simulator bench-simulator.cc) + target_link_libraries(bench-simulator ${libcore}) + set_runtime_outputdirectory(bench-simulator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/utils/) + + add_executable(bench-packets bench-packets.cc) + target_link_libraries(bench-packets ${libnetwork}) + set_runtime_outputdirectory(bench-packets ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/utils/) + + add_executable(print-introspected-doxygen print-introspected-doxygen.cc) + target_link_libraries(print-introspected-doxygen ${ns3-libs}) + set_runtime_outputdirectory(print-introspected-doxygen ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/utils/) + +endif() diff --git a/utils/create-module.py b/utils/create-module.py index 417fd110e..5d4efa400 100755 --- a/utils/create-module.py +++ b/utils/create-module.py @@ -7,47 +7,44 @@ import shutil from pathlib import Path -WSCRIPT_TEMPLATE = '''# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +CMAKELISTS_TEMPLATE = '''\ +check_include_file_cxx(stdint.h HAVE_STDINT_H) +if(HAVE_STDINT_H) + add_definitions(-DHAVE_STDINT_H) +endif() -# def options(opt): -# pass +set(name {MODULE}) -# def configure(conf): -# conf.check_nonfatal(header_name='stdint.h', define_name='HAVE_STDINT_H') +set(source_files + model/{MODULE}.cc + helper/{MODULE}-helper.cc + ) + +set(header_files + model/{MODULE}.h + helper/{MODULE}-helper.h + ) -def build(bld): - module = bld.create_ns3_module({MODULE!r}, ['core']) - module.source = [ - 'model/{MODULE}.cc', - 'helper/{MODULE}-helper.cc', - ] +set(libraries_to_link + ${{libcore}} + ) - module_test = bld.create_ns3_module_test_library('{MODULE}') - module_test.source = [ - 'test/{MODULE}-test-suite.cc', - ] - # Tests encapsulating example programs should be listed here - if (bld.env['ENABLE_EXAMPLES']): - module_test.source.extend([ - # 'test/{MODULE}-examples-test-suite.cc', - ]) +if(${{NS3_EXAMPLES}}) + set(examples_as_tests_sources + #test/{MODULE}-examples-test-suite.cc + ) +endif() - headers = bld(features='ns3header') - headers.module = {MODULE!r} - headers.source = [ - 'model/{MODULE}.h', - 'helper/{MODULE}-helper.h', - ] - - if bld.env.ENABLE_EXAMPLES: - bld.recurse('examples') - - # bld.ns3_python_bindings() +set(test_sources + test/{MODULE}-test-suite.cc + ${{examples_as_tests_sources}} + ) +{BUILD_LIB_MACRO}("${{name}}" "${{source_files}}" "${{header_files}}" "${{libraries_to_link}}" "${{test_sources}}") + ''' - MODEL_CC_TEMPLATE = '''/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "{MODULE}.h" @@ -111,11 +108,12 @@ namespace ns3 {{ ''' -EXAMPLES_WSCRIPT_TEMPLATE = '''# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- - -def build(bld): - obj = bld.create_ns3_program('{MODULE}-example', [{MODULE!r}]) - obj.source = '{MODULE}-example.cc' +EXAMPLES_CMAKELISTS_TEMPLATE = '''\ +set(name {MODULE}-example) +set(source_files ${{name}}.cc) +set(header_files) +set(libraries_to_link ${{lib{MODULE}}}) +{BUILD_EXAMPLE_MACRO}("${{name}}" "${{source_files}}" "${{header_files}}" "${{libraries_to_link}}") ''' @@ -326,12 +324,15 @@ def create_file(path, template, **kwargs): with artifact_path.open("wt") as f: f.write(template.format(**kwargs)) -def make_wscript(moduledir, modname): - path = Path(moduledir, 'wscript') - create_file(path, WSCRIPT_TEMPLATE, MODULE=modname) + +def make_cmakelists(moduledir, modname): + path = Path(moduledir, 'CMakeLists.txt') + macro = "build_lib" if "contrib" not in str(path) else "build_contrib_lib" + create_file(path, CMAKELISTS_TEMPLATE, MODULE=modname, BUILD_LIB_MACRO=macro) return True + def make_model(moduledir, modname): modelpath = Path(moduledir, "model") modelpath.mkdir(parents=True) @@ -379,8 +380,9 @@ def make_examples(moduledir, modname): examplespath = Path(moduledir, "examples") examplespath.mkdir(parents=True) - wscriptpath = Path(examplespath, 'wscript') - create_file(wscriptpath, EXAMPLES_WSCRIPT_TEMPLATE, MODULE=modname) + cmakelistspath = Path(examplespath, 'CMakeLists.txt') + macro = "build_lib_example" if "contrib" not in str(moduledir) else "build_contrib_example" + create_file(cmakelistspath, EXAMPLES_CMAKELISTS_TEMPLATE, MODULE=modname, BUILD_EXAMPLE_MACRO=macro) examplesfile_path = examplespath.joinpath(modname+'-example').with_suffix('.cc') create_file(examplesfile_path, EXAMPLE_CC_TEMPLATE, MODULE=modname) @@ -398,11 +400,11 @@ def make_doc(moduledir, modname): file_name = '{}.rst'.format(modname) file_path = Path(docpath, file_name) - create_file(file_path, DOC_RST_TEMPLATE, MODULE=modname, - MODULE_DIR=mod_relpath) + create_file(file_path, DOC_RST_TEMPLATE, MODULE=modname, MODULE_DIR=mod_relpath) return True + def make_module(modpath, modname): modulepath = Path(modpath, modname) @@ -412,7 +414,7 @@ def make_module(modpath, modname): print("Creating module {}".format(modulepath)) - functions = (make_wscript, make_model, make_test, + functions = (make_cmakelists, make_model, make_test, make_helper, make_examples, make_doc) try: @@ -443,12 +445,12 @@ to integrate them into the ns-3 build system. The following directory structure is generated under the contrib directory: - |-- wscript + |-- CMakeLists.txt |-- doc |-- .rst |-- examples |-- -example.cc - |-- wscript + |-- CMakeLists.txt |-- helper |-- -helper.cc |-- -helper.h