diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b1e02b59..2d3f46aac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ -# ###################################################################################################################### +# ############################################################################## # Required CMake version # -# ###################################################################################################################### -cmake_minimum_required(VERSION 3.10) +# ############################################################################## +cmake_minimum_required(VERSION 3.10..3.10) # Use ccache if available +mark_as_advanced(CCACHE_FOUND) find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) @@ -11,17 +12,18 @@ if(CCACHE_FOUND) message(STATUS "CCache is enabled") # Configure ccache for pch headers - execute_process(COMMAND ${CCACHE_FOUND} --set-config=sloppiness=pch_defines,time_macros,include_file_mtime) + execute_process( + COMMAND ${CCACHE_FOUND} + --set-config=sloppiness=pch_defines,time_macros,include_file_mtime + ) endif() -# ###################################################################################################################### +# ############################################################################## # Project name # -# ###################################################################################################################### +# ############################################################################## project(NS3 CXX C) -include(buildsupport/macros_and_definitions.cmake) - -set(NS3_VER 3-dev) +file(STRINGS VERSION NS3_VER) # common options option(NS3_ASSERT "Enable assert on failure" OFF) @@ -38,12 +40,22 @@ option(NS3_TAP "Build with Tap support" ON) # maintenance and documentation option(NS3_CLANG_FORMAT "Enforce cody style with clang-format" OFF) option(NS3_CLANG_TIDY "Use clang-tidy static analysis" OFF) -option(NS3_CLANG_TIMETRACE "Collect compilation statistics to analyze the build process" OFF) -option(NS3_COVERAGE "Enable code coverage measurements and report generation" OFF) -option(NS3_COVERAGE_ZERO_COUNTERS "Zero lcov counters before running. Requires NS3_COVERAGE=ON" OFF) +option(NS3_CLANG_TIMETRACE + "Collect compilation statistics to analyze the build process" OFF +) +option(NS3_COVERAGE "Enable code coverage measurements and report generation" + OFF +) +option(NS3_COVERAGE_ZERO_COUNTERS + "Zero lcov counters before running. Requires NS3_COVERAGE=ON" OFF +) option(NS3_DOCS "Generate documentation" OFF) -option(NS3_INCLUDE_WHAT_YOU_USE "Use IWYU to determine unnecessary headers included" OFF) -option(NS3_LINK_WHAT_YOU_USE "Use LWYU to determine unnecessary linked libraries" OFF) +option(NS3_INCLUDE_WHAT_YOU_USE + "Use IWYU to determine unnecessary headers included" OFF +) +option(NS3_LINK_WHAT_YOU_USE + "Use LWYU to determine unnecessary linked libraries" OFF +) option(NS3_SANITIZE "Build with address, leak and undefined sanitizers" OFF) option(NS3_SANITIZE_MEMORY "Build with memory sanitizer" OFF) option(NS3_SCAN_PYTHON_BINDINGS "Scan python bindings" OFF) @@ -57,23 +69,39 @@ option(NS3_GNUPLOT "Build with Gnuplot support" OFF) option(NS3_GSL "Build with GSL support" ON) option(NS3_GTK3 "Build with GTK3 support" ON) option(NS3_LINK_TIME_OPTIMIZATION "Build with link-time optimization" OFF) -option(NS3_MONOLIB "Build a single shared ns-3 library and link it against executables" OFF) +option(NS3_MONOLIB + "Build a single shared ns-3 library and link it against executables" OFF +) option(NS3_MPI "Build with MPI support" ON) option(NS3_NATIVE_OPTIMIZATIONS "Build with -march=native -mtune=native" OFF) option(NS3_NSC "Build with NSC support" OFF) # currently not supported -option(NS3_PRECOMPILE_HEADERS "Precompile module headers to speed up compilation" ON) +set(NS3_OUTPUT_DIRECTORY "" CACHE STRING "Directory to store built artifacts") +option(NS3_PRECOMPILE_HEADERS + "Precompile module headers to speed up compilation" ON +) option(NS3_PTHREAD "Build with pthread support" ON) option(NS3_PYTHON_BINDINGS "Build ns-3 python bindings" OFF) option(NS3_REALTIME "Build with realtime support" ON) option(NS3_SQLITE "Build with SQLite support" ON) -option(NS3_STATIC "Build a static ns-3 library and link it against executables" OFF) +option(NS3_STATIC "Build a static ns-3 library and link it against executables" + OFF +) option(NS3_VISUALIZER "Build visualizer module" OFF) option(NS3_WARNINGS "Enable compiler warnings" ON) -option(NS3_WARNINGS_AS_ERRORS "Treat warnings as errors. Requires NS3_WARNINGS=ON" ON) +option(NS3_WARNINGS_AS_ERRORS + "Treat warnings as errors. Requires NS3_WARNINGS=ON" ON +) # Options that either select which modules will get built or disable modules -set(NS3_ENABLED_MODULES "" CACHE STRING "List of modules to enable (e.g. core;network;internet)") -set(NS3_DISABLED_MODULES "" CACHE STRING "List of modules to disable (e.g. lte;wimax;wave)") +set(NS3_ENABLED_MODULES "" + CACHE STRING "List of modules to enable (e.g. core;network;internet)" +) +set(NS3_DISABLED_MODULES "" + CACHE STRING "List of modules to disable (e.g. lte;wimax;wave)" +) + +# Include macros used below +include(buildsupport/macros_and_definitions.cmake) # Scan module libraries subdirlist(libs_to_build ${CMAKE_SOURCE_DIR}/src) @@ -81,17 +109,23 @@ subdirlist(libs_to_build ${CMAKE_SOURCE_DIR}/src) # Scan contribution libraries subdirlist(contrib_libs_to_build ${CMAKE_SOURCE_DIR}/contrib) -# After scanning modules, we can filter enabled and disabled ones -filter_enabled_and_disabled_modules(libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES) +# Before filtering, we need to load settings from .ns3rc +parse_ns3rc(ns3rc_enabled_modules ns3rc_examples_enabled ns3rc_tests_enabled) -# ###################################################################################################################### +# After scanning modules, we can filter enabled and disabled ones +filter_enabled_and_disabled_modules( + libs_to_build contrib_libs_to_build NS3_ENABLED_MODULES NS3_DISABLED_MODULES + ns3rc_enabled_modules +) + +# ############################################################################## # Process options # -# ###################################################################################################################### +# ############################################################################## process_options() -# ###################################################################################################################### +# ############################################################################## # Add subdirectories # -# ###################################################################################################################### +# ############################################################################## # Build NS3 library core add_subdirectory(src) diff --git a/buildsupport/3rd_party/FindGTK3.cmake b/buildsupport/3rd_party/FindGTK3.cmake index 7c83c9403..b3ecac89b 100644 --- a/buildsupport/3rd_party/FindGTK3.cmake +++ b/buildsupport/3rd_party/FindGTK3.cmake @@ -1,24 +1,28 @@ -# * FindGTK3.cmake This module can find the GTK3 widget libraries and several of its other optional components like -# gtkmm, glade, and glademm. +# * 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. +# 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_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 +# 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 +# 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: @@ -27,36 +31,49 @@ # # 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() +# 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 +# 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. +# 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. +# 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.) +# (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.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 +# _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_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_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" + "\\1" ${_OUT_minor} "${_contents}" + ) - string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_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() @@ -76,13 +93,15 @@ function(_GTK3_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr) endfunction() # ============================================================= -# _GTK3_FIND_INCLUDE_DIR Internal function to find the GTK include directories _var = variable to set _hdr = header file -# to look for +# _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} )") + message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK3_FIND_INCLUDE_DIR( ${_var} ${_hdr} )" + ) endif() set(_relatives @@ -115,12 +134,15 @@ function(_GTK3_FIND_INCLUDE_DIR _var _hdr) endforeach() if(GTK3_DEBUG) - message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " "include suffixes = ${_suffixes}") + 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. + 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 @@ -154,18 +176,22 @@ function(_GTK3_FIND_INCLUDE_DIR _var _hdr) endfunction() # ============================================================= -# _GTK3_FIND_LIBRARY Internal function to find libraries packaged with GTK3 _var = library variable to create +# _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} )" + 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) + # 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 @@ -231,12 +257,15 @@ function(_GTK3_FIND_LIBRARY _var _lib _expand_vc _append_version) endif() if(GTK3_DEBUG) - message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " - "library list = ${_lib_list} and library debug list = ${_libd_list}" + 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 + # 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) @@ -256,23 +285,28 @@ function(_GTK3_FIND_LIBRARY _var _lib _expand_vc _append_version) endif() if(GTK3_DEBUG) - message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " - "While searching for ${_var}, our proposed library list is ${_lib_list}" + 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] + 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}" + message( + STATUS + "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "While searching for ${_var}_DEBUG our proposed library list is ${_libd_list}" ) endif() @@ -288,7 +322,9 @@ function(_GTK3_FIND_LIBRARY _var _lib _expand_vc _append_version) 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} optimized ${${_var}} debug + ${${_var}_DEBUG} + ) set(GTK3_LIBRARIES ${GTK3_LIBRARIES} PARENT_SCOPE) endif() else() @@ -327,18 +363,27 @@ if(GTK3_FIND_VERSION) endif() set(GTK3_FAILED_VERSION_CHECK true) if(GTK3_DEBUG) - message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] " "Searching for version ${GTK3_FIND_VERSION}") + 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}) + _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) + if(GTK3_VERSION VERSION_EQUAL GTK3_FIND_VERSION + OR GTK3_VERSION VERSION_GREATER GTK3_FIND_VERSION + ) set(GTK3_FAILED_VERSION_CHECK false) endif() endif() @@ -403,17 +448,21 @@ foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) _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. + # ********* 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. + # ********* 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) + # ********* 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) @@ -485,8 +534,13 @@ 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}) + _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() @@ -532,11 +586,13 @@ foreach(_GTK3_component ${GTK3_FIND_COMPONENTS}) ) 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 + 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_${_COMPONENT_UPPER} "The glademm library was not found." + GTK3_GLADEMM_LIBRARY GTK3_GLADEMM_INCLUDE_DIR GTK3_GLADEMMCONFIG_INCLUDE_DIR ) endif() diff --git a/buildsupport/3rd_party/FindHarfBuzz.cmake b/buildsupport/3rd_party/FindHarfBuzz.cmake index b1bf64582..534aff5a4 100644 --- a/buildsupport/3rd_party/FindHarfBuzz.cmake +++ b/buildsupport/3rd_party/FindHarfBuzz.cmake @@ -1,27 +1,34 @@ -# Copyright (c) 2012, Intel Corporation Copyright (c) 2019 Sony Interactive Entertainment Inc. +# 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: +# 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. +# * 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 +# 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 +# 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 @@ -69,20 +76,27 @@ find_path( PATH_SUFFIXES harfbuzz ) -find_library(HarfBuzz_LIBRARY NAMES ${HarfBuzz_NAMES} harfbuzz HINTS ${PC_HARFBUZZ_LIBDIR} ${PC_HARFBUZZ_LIBRARY_DIRS}) +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}") + 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} ")" + message( + FATAL_ERROR "Required version (" ${HarfBuzz_FIND_VERSION} + ") is higher than found version (" ${HarfBuzz_VERSION} ")" ) endif() @@ -107,8 +121,8 @@ if("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) ) find_library( - HarfBuzz_ICU_LIBRARY NAMES ${HarfBuzz_ICU_NAMES} harfbuzz-icu HINTS ${PC_HARFBUZZ_ICU_LIBDIR} - ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} + HarfBuzz_ICU_LIBRARY NAMES ${HarfBuzz_ICU_NAMES} harfbuzz-icu + HINTS ${PC_HARFBUZZ_ICU_LIBDIR} ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} ) if(HarfBuzz_ICU_LIBRARY) @@ -146,7 +160,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args( HarfBuzz FOUND_VAR HarfBuzz_FOUND - REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND + REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY + _HarfBuzz_REQUIRED_LIBS_FOUND VERSION_VAR HarfBuzz_VERSION ) @@ -154,7 +169,8 @@ 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}" + PROPERTIES IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" ) endif() @@ -163,12 +179,16 @@ 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}" + 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) +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}) diff --git a/buildsupport/3rd_party/FindInt128.cmake b/buildsupport/3rd_party/FindInt128.cmake index c41db2513..5e9b918cc 100644 --- a/buildsupport/3rd_party/FindInt128.cmake +++ b/buildsupport/3rd_party/FindInt128.cmake @@ -1,48 +1,57 @@ # # COPYRIGHT # -# All contributions by Emanuele Ruffaldi Copyright (c) 2016-2019, E All rights reserved. +# 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. +# 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. +# 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: +# 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 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. +# * 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. +# * 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 +# 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 +# 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. +# * 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}.") + # message("Testing for presence of 128 bit unsigned integer hash function for + # ${VAR_NAME}.") check_cxx_source_compiles( " @@ -70,7 +79,8 @@ macro(CHECK_INT128 INT128_NAME VARIABLE DEFINE_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}.") + # 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}") @@ -84,11 +94,13 @@ endmacro() macro(CHECK_UINT128 UINT128_NAME VARIABLE DEFINE_NAME) if(NOT UINT128_FOUND) - # message("Testing for 128 bit unsigned integer support with ${UINT128_NAME}.") + # 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}.") + # 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}") @@ -131,8 +143,9 @@ macro(FIND_INT128_TYPES) 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 + # 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() diff --git a/buildsupport/3rd_party/FindSphinx.cmake b/buildsupport/3rd_party/FindSphinx.cmake index b7e88ca4a..486eafab4 100644 --- a/buildsupport/3rd_party/FindSphinx.cmake +++ b/buildsupport/3rd_party/FindSphinx.cmake @@ -1,19 +1,29 @@ -# CMake find_package() Module for Sphinx documentation generator http://sphinx-doc.org/ +# 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 +# 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") +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 +# 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) +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) +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 index 50dae9593..05e59d21e 100644 --- a/buildsupport/3rd_party/netanim_cmakelists.cmake +++ b/buildsupport/3rd_party/netanim_cmakelists.cmake @@ -1,13 +1,17 @@ # 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 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. +# 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 +# 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 @@ -178,8 +182,10 @@ 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) + 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) +set_runtime_outputdirectory(netanim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin "") diff --git a/buildsupport/.cmake-format.txt b/buildsupport/cmake-format.txt similarity index 59% rename from buildsupport/.cmake-format.txt rename to buildsupport/cmake-format.txt index 9fee199c7..5d3fdd48c 100644 --- a/buildsupport/.cmake-format.txt +++ b/buildsupport/cmake-format.txt @@ -1,6 +1,6 @@ format: tab_size: 2 - line_width: 120 + line_width: 80 dangle_parens: true autosort: true max_subgroups_hwrap: 3 \ No newline at end of file diff --git a/buildsupport/custom_modules/ns3_cmake_package.cmake b/buildsupport/custom_modules/ns3_cmake_package.cmake index 4109d61fd..812e532c7 100644 --- a/buildsupport/custom_modules/ns3_cmake_package.cmake +++ b/buildsupport/custom_modules/ns3_cmake_package.cmake @@ -1,48 +1,64 @@ # 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 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. +# 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 +# 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) + 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 + "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 + ${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" + 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}) + 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 + # 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) + 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 + 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 index 93dc42e2f..1e9d3587b 100644 --- a/buildsupport/custom_modules/ns3_contributions.cmake +++ b/buildsupport/custom_modules/ns3_contributions.cmake @@ -1,13 +1,17 @@ # 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 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. +# 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 +# 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 @@ -21,7 +25,14 @@ macro(process_contribution contribution_list) # Add contribution folders to be built foreach(contribname ${contribution_list}) - add_subdirectory("contrib/${contribname}") + set(folder "contrib/${contribname}") + if(EXISTS ${PROJECT_SOURCE_DIR}/${folder}/CMakeLists.txt) + add_subdirectory(${folder}) + else() + message( + STATUS "Skipping ${folder} : it does not contain a CMakeLists.txt file" + ) + endif() endforeach() endmacro() @@ -35,12 +46,16 @@ macro( ) # cmake-format: on build_lib_example_impl( - "contrib/${contribname}" "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + "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) +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}" + "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 index d72eabb32..55b19094b 100644 --- a/buildsupport/custom_modules/ns3_coverage.cmake +++ b/buildsupport/custom_modules/ns3_coverage.cmake @@ -1,13 +1,17 @@ # 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 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. +# 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 +# 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 @@ -27,8 +31,9 @@ if(${NS3_COVERAGE}) 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} + # 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) diff --git a/buildsupport/custom_modules/ns3_module_macros.cmake b/buildsupport/custom_modules/ns3_module_macros.cmake index ebcffabf3..9ed41887d 100644 --- a/buildsupport/custom_modules/ns3_module_macros.cmake +++ b/buildsupport/custom_modules/ns3_module_macros.cmake @@ -1,13 +1,17 @@ # 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 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. +# 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 +# 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 @@ -44,26 +48,33 @@ macro( # 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") + 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") + 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 + # 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})) + if(${PRECOMPILE_HEADERS_ENABLED} 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) + # 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 + # 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})) + if(${PRECOMPILE_HEADERS_ENABLED} AND (NOT ${ignore_pch})) target_precompile_headers(${lib${libname}} REUSE_FROM stdlib_pch) endif() endif() @@ -79,7 +90,7 @@ macro( 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) + if(${module_name} IN_LIST ns3-all-enabled-modules) list(APPEND ns_libraries_to_link ${library}) else() list(APPEND non_ns_libraries_to_link ${library}) @@ -87,23 +98,36 @@ macro( 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 + # ns-3 libraries are linked publicly, to make sure other modules can find each + # other without being directly linked target_link_libraries( - ${lib${libname}} PRIVATE ${LIB_AS_NEEDED_PRE} "${non_ns_libraries_to_link}" ${LIB_AS_NEEDED_POST} + ${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}) + set_target_properties( + ${lib${libname}} PROPERTIES OUTPUT_NAME + ns${NS3_VER}-${libname}${build_profile_suffix} + ) + 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" + ) 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" + 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() @@ -111,49 +135,66 @@ macro( 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) + 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 + ${libname} ${CMAKE_HEADER_OUTPUT_DIRECTORY} "${deprecated_header_files}" + deprecated ) endif() # Build tests if requested - if(${NS3_TESTS}) + if(${TESTS_ENABLED}) 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") + set(test${libname} lib${libname}-test 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}) + 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} + ${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} + ${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_compile_definitions( + ${test${libname}} PRIVATE NS_TEST_SOURCEDIR="${folder}/${libname}/test" + ) + if(${PRECOMPILE_HEADERS_ENABLED} 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) + if(${EXAMPLES_ENABLED}) + if((EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples) + AND (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt) + ) add_subdirectory(examples) endif() - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/example) + if((EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/example) + AND (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/example/CMakeLists.txt) + ) add_subdirectory(example) endif() endif() @@ -167,27 +208,41 @@ macro( 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) + 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) + 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 + # 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;... -> + # 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}") + # 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" + # 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) @@ -197,25 +252,30 @@ macro( add_custom_target( apiscan-${lib${libname}} - COMMAND ${modulescan_modular_command} ${CMAKE_OUTPUT_DIRECTORY} ${libname} ${header_map} ${module_api} - ${arch_flag} + 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 + # 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) + 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) + 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 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 _) @@ -225,14 +285,20 @@ macro( endif() # Run modulegen-modular to generate the bindings sources - if((NOT EXISTS ${module_hdr}) OR (NOT EXISTS ${module_src})) # OR TRUE) # to force reprocessing + 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 + 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} + 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} @@ -241,8 +307,9 @@ macro( ) 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)." + 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}) @@ -253,44 +320,63 @@ macro( # 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 + 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}) + 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}") + # 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 + 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} + ${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 ) - 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 + ${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}" + 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 + # 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}) + install( + TARGETS ${lib${name}} + EXPORT ns3ExportTargets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) endmacro() # cmake-format: off @@ -316,7 +402,7 @@ macro( set(missing_dependencies FALSE) foreach(lib ${libraries_to_link}) string(REPLACE "lib" "" lib ${lib}) - if(NOT (${lib} IN_LIST ns3-all-modules)) + if(NOT (${lib} IN_LIST ns3-all-enabled-modules)) set(missing_dependencies TRUE) endif() endforeach() @@ -326,27 +412,34 @@ macro( add_executable(${name} "${source_files}" "${header_files}") if(${NS3_STATIC}) - target_link_libraries(${name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-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}) + 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} + ${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})) + if(${PRECOMPILE_HEADERS_ENABLED} AND (NOT ${ignore_pch})) target_precompile_headers(${name} REUSE_FROM stdlib_pch_exec) endif() - set_runtime_outputdirectory(${name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${folder}/examples/) + 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;" +# 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}) diff --git a/buildsupport/custom_modules/ns3_versioning.cmake b/buildsupport/custom_modules/ns3_versioning.cmake index a2207b608..51a4c3a51 100644 --- a/buildsupport/custom_modules/ns3_versioning.cmake +++ b/buildsupport/custom_modules/ns3_versioning.cmake @@ -1,12 +1,18 @@ # 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* +# 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) + 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) + 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) @@ -19,11 +25,18 @@ function(check_git_repo_has_ns3_tags HAS_TAGS GIT_VERSION_TAG) 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) +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) + 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 @@ -21,8 +25,11 @@ function(generate_buildstatus) endforeach() string(APPEND buildstatus_contents "]\n\n") - string(APPEND buildstatus_contents "ns3_runnable_scripts = [") # missing support + 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}") + 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 index b8c2500fa..c83ba1fc3 100644 --- a/buildsupport/custom_modules/waf_workaround_c4cache.cmake +++ b/buildsupport/custom_modules/waf_workaround_c4cache.cmake @@ -1,21 +1,29 @@ # 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 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. +# 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 +# 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) + set(${output_string} "${${output_string}}${cache_entry} = True\n" + PARENT_SCOPE + ) else() - set(${output_string} "${${output_string}}${cache_entry} = False\n" PARENT_SCOPE) + set(${output_string} "${${output_string}}${cache_entry} = False\n" + PARENT_SCOPE + ) endif() endfunction(cache_cmake_flag) @@ -26,7 +34,8 @@ function(generate_c4che_cachepy) 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(REPLACE "lib" "" module_name ${module_library}) # lib${libname} into + # libname string(APPEND cache_contents "ns3-${module_name}', ") endforeach() string(APPEND cache_contents "]\n") @@ -34,21 +43,24 @@ function(generate_c4che_cachepy) 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(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" + 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(EXAMPLES_ENABLED "ENABLE_EXAMPLES" cache_contents) + cache_cmake_flag(TESTS_ENABLED "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) @@ -65,6 +77,7 @@ function(generate_c4che_cachepy) string(APPEND cache_contents "VERSION = '3-dev' \n") string(APPEND cache_contents "PYTHON = ['${Python3_EXECUTABLE}']\n") + mark_as_advanced(VALGRIND) find_program(VALGRIND valgrind) if("${VALGRIND}" STREQUAL "VALGRIND-NOTFOUND") string(APPEND cache_contents "VALGRIND_FOUND = False \n") diff --git a/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake b/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake index 1057e92b3..341c61a10 100644 --- a/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake +++ b/buildsupport/custom_modules/waf_workaround_fakeconfig.cmake @@ -32,6 +32,28 @@ # Use sudo to set suid bit : not enabled (option --enable-sudo not selected) # XmlIo : enabled # +# +# And now a sample after build +# +# Modules built: +# antenna aodv applications +# bridge buildings config-store +# core csma csma-layout +# dsdv dsr energy +# fd-net-device flow-monitor internet +# internet-apps lr-wpan lte +# mesh mobility netanim +# network nix-vector-routing olsr +# point-to-point point-to-point-layout propagation +# sixlowpan spectrum stats +# tap-bridge test (no Python) topology-read +# traffic-control uan virtual-net-device +# wave wifi wimax +# +# Modules not built (see ns-3 tutorial for explanation): +# brite click dpdk-net-device +# mpi openflow visualizer +# # cmake-format: on # Now the CMake part @@ -48,10 +70,44 @@ macro(check_on_or_off user_config_switch confirmation_flag) endif() endmacro() +function(print_formatted_table_with_modules table_name modules output) + set(temp) + string(APPEND temp "${table_name}:\n") + set(count 0) # Variable to count number of columns + set(width 26) # Variable with column width + string(REPLACE "lib" "" modules_to_print "${modules}") + list(SORT modules_to_print) # Sort for nice output + foreach(module ${modules_to_print}) + # Get the size of the module string name + string(LENGTH ${module} module_name_length) + + # Calculate trailing spaces to fill the column + math(EXPR num_trailing_spaces "${width} - ${module_name_length}") + + # Get a string with spaces + string(RANDOM LENGTH ${num_trailing_spaces} ALPHABET " " trailing_spaces) + + # Append module name and spaces to output + string(APPEND temp "${module}${trailing_spaces}") + math(EXPR count "${count} + 1") # Count number of column + + # When counter hits the 3rd column, wrap to the nextline + if(${count} EQUAL 3) + string(APPEND temp "\n") + set(count 0) + endif() + endforeach() + string(APPEND temp "\n") + # Save the table outer scope out variable + set(${output} ${${output}}${temp} PARENT_SCOPE) +endfunction() + 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 + "Build directory : ${CMAKE_OUTPUT_DIRECTORY}\n" + ) string(APPEND out "BRITE Integration : ") check_on_or_off("ON" "${NS3_BRITE}") @@ -62,15 +118,15 @@ macro(write_fakewaf_config) string(APPEND out "Emulation FdNetDevice : ") check_on_or_off("${NS3_EMU}" "${ENABLE_EMU}") - string(APPEND out "Examples : ${NS3_EXAMPLES}\n") + string(APPEND out "Examples : ${EXAMPLES_ENABLED}\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 "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}") @@ -87,10 +143,19 @@ macro(write_fakewaf_config) 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 + "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 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}") @@ -102,12 +167,30 @@ macro(write_fakewaf_config) string(APPEND out "Tap FdNetDevice : ") check_on_or_off("${NS3_TAP}" "${ENABLE_TAP}") - string(APPEND out "Tests : ${NS3_TESTS}\n") + string(APPEND out "Tests : ${TESTS_ENABLED}\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 + # string(APPEND out "Use sudo to set suid bit : not enabled (option + # --enable-sudo not selected) string(APPEND out "XmlIo : enabled + string(APPEND out "\n\n") + + set(really-enabled-modules ${ns3-libs};${ns3-contrib-libs}) + print_formatted_table_with_modules( + "Modules that can be built" "${really-enabled-modules}" "out" + ) + string(APPEND out "\n") + + set(disabled-modules) + foreach(module ${ns3-all-enabled-modules}) + if(NOT (lib${module} IN_LIST really-enabled-modules)) + list(APPEND disabled-modules ${module}) + endif() + endforeach() + print_formatted_table_with_modules( + "Modules that cannot be built" "${disabled-modules}" "out" + ) + string(APPEND out "\n") file(WRITE ${PROJECT_BINARY_DIR}/ns3wafconfig.txt ${out}) message(STATUS ${out}) diff --git a/buildsupport/custom_modules/waf_workaround_lock.cmake b/buildsupport/custom_modules/waf_workaround_lock.cmake index 822f2d100..b9a5c0015 100644 --- a/buildsupport/custom_modules/waf_workaround_lock.cmake +++ b/buildsupport/custom_modules/waf_workaround_lock.cmake @@ -1,13 +1,17 @@ # 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 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. +# 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 +# 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 @@ -27,5 +31,7 @@ function(generate_fakewaflock) message(FATAL_ERROR "Platform not supported") endif() - file(WRITE ${PROJECT_SOURCE_DIR}/${fakewaflock_filename} ${fakewaflock_contents}) + file(WRITE ${PROJECT_SOURCE_DIR}/${fakewaflock_filename} + ${fakewaflock_contents} + ) endfunction(generate_fakewaflock) diff --git a/buildsupport/macros_and_definitions.cmake b/buildsupport/macros_and_definitions.cmake index 6215f04f8..79c032c18 100644 --- a/buildsupport/macros_and_definitions.cmake +++ b/buildsupport/macros_and_definitions.cmake @@ -1,13 +1,17 @@ # 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 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. +# 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 +# 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 @@ -54,24 +58,67 @@ include(ProcessorCount) ProcessorCount(NumThreads) # Output folders -set(CMAKE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build) +if("${NS3_OUTPUT_DIRECTORY}" STREQUAL "") + message(STATUS "Using default output directory ${PROJECT_SOURCE_DIR}/build") + set(CMAKE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build) # default output + # folder +else() + # Check if we can create that directory + if(NOT (EXISTS ${NS3_OUTPUT_DIRECTORY})) + message( + STATUS + "User-defined output directory \"${NS3_OUTPUT_DIRECTORY}\" doesn't exist. Trying to create it" + ) + file(MAKE_DIRECTORY ${NS3_OUTPUT_DIRECTORY}) + if(NOT (EXISTS ${NS3_OUTPUT_DIRECTORY})) + message( + FATAL_ERROR + "User-defined output directory \"${NS3_OUTPUT_DIRECTORY}\" could not be created. " + "Try changing the value of NS3_OUTPUT_DIRECTORY" + ) + endif() + + # If this directory is not inside the ns-3-dev folder, alert users tests may + # break + if(NOT ("${NS3_OUTPUT_DIRECTORY}" MATCHES "${PROJECT_SOURCE_DIR}")) + message( + WARNING + "User-defined output directory \"${NS3_OUTPUT_DIRECTORY}\" is outside " + " of the ns-3 directory ${PROJECT_SOURCE_DIR}, which will break some tests" + ) + endif() + endif() + message( + STATUS + "User-defined output directory \"${NS3_OUTPUT_DIRECTORY}\" will be used" + ) + set(CMAKE_OUTPUT_DIRECTORY ${NS3_OUTPUT_DIRECTORY}) +endif() 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 +# 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? + # 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}) + 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() @@ -89,7 +136,8 @@ 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 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) @@ -136,6 +184,18 @@ macro(clear_global_cached_variables) unset(ns3-libs CACHE) unset(ns3-libs-tests CACHE) unset(ns3-python-bindings-modules CACHE) + mark_as_advanced( + build_profile + build_profile_suffix + lib-ns3-static-objs + ns3-contrib-libs + ns3-example-folders + ns3-execs + ns3-external-libs + ns3-libs + ns3-libs-tests + ns3-python-bindings-modules + ) endmacro() # process all options passed in main cmakeLists @@ -158,6 +218,20 @@ macro(process_options) add_definitions(-DNS3_BUILD_PROFILE_OPTIMIZED) endif() + # Enable examples if activated via command line (NS3_EXAMPLES) or ns3rc config + # file + set(EXAMPLES_ENABLED OFF) + if(${NS3_EXAMPLES} OR ${ns3rc_examples_enabled}) + set(EXAMPLES_ENABLED ON) + endif() + + # Enable examples if activated via command line (NS3_TESTS) or ns3rc config + # file + set(TESTS_ENABLED OFF) + if(${NS3_TESTS} OR ${ns3rc_tests_enabled}) + set(TESTS_ENABLED ON) + endif() + set(profiles_without_suffixes release) set(build_profile_suffix "" CACHE INTERNAL "") if(NOT (${build_profile} IN_LIST profiles_without_suffixes)) @@ -165,15 +239,15 @@ macro(process_options) endif() # Set warning level and warning as errors - if (${NS3_WARNINGS}) - if (MSVC) + if(${NS3_WARNINGS}) + if(MSVC) add_compile_options(/W3) # /W4 = -Wall + -Wextra - if (${NS3_WARNINGS_AS_ERRORS}) + if(${NS3_WARNINGS_AS_ERRORS}) add_compile_options(/WX) endif() else() add_compile_options(-Wall) # -Wextra - if (${NS3_WARNINGS_AS_ERRORS}) + if(${NS3_WARNINGS_AS_ERRORS}) add_compile_options(-Werror) endif() endif() @@ -191,14 +265,19 @@ macro(process_options) 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.") + 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 + 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]): + # 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) @@ -231,7 +310,10 @@ macro(process_options) # Set set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) - configure_file(buildsupport/version-defines-template.h ${CMAKE_HEADER_OUTPUT_DIRECTORY}/version-defines.h) + configure_file( + buildsupport/version-defines-template.h + ${CMAKE_HEADER_OUTPUT_DIRECTORY}/version-defines.h + ) endif() if(${NS3_CLANG_FORMAT}) @@ -249,7 +331,10 @@ macro(process_options) scratch/*.cc scratch/*.h ) - add_custom_target(clang-format COMMAND clang-format -style=file -i ${ALL_CXX_SOURCE_FILES}) + 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") @@ -273,30 +358,41 @@ macro(process_options) ClangBuildAnalyzer GIT_REPOSITORY "https://github.com/aras-p/ClangBuildAnalyzer.git" GIT_TAG "5d40542c5b2080637206e9d51e2957d0017ba8b3" - INSTALL_COMMAND cmake -E copy_if_different ClangBuildAnalyzer ${PROJECT_BINARY_DIR} + 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 + 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.") + message( + FATAL_ERROR + "TimeTrace is a Clang feature, but you're using a different compiler." + ) endif() endif() + mark_as_advanced(CMAKE_FORMAT_PROGRAM) 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} + cmake-format + COMMAND + ${CMAKE_FORMAT_PROGRAM} -c + ${PROJECT_SOURCE_DIR}/buildsupport/cmake-format.txt -i + ${ALL_CMAKE_FILES} ) unset(ALL_CMAKE_FILES) endif() @@ -309,8 +405,10 @@ macro(process_options) # 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}." + message( + FATAL_ERROR + "You're trying to use the unsupported C++ ${CMAKE_CXX_STANDARD}.\n" + "Try -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD_MINIMUM}." ) endif() @@ -319,7 +417,10 @@ macro(process_options) 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.") + message( + FATAL_ERROR + "The memory sanitizer can't be used with other sanitizers. Disable one of them." + ) endif() if(${NS3_SANITIZE}) @@ -330,17 +431,20 @@ macro(process_options) 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}") + 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." + 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) @@ -359,9 +463,11 @@ macro(process_options) check_ipo_supported(RESULT LTO_AVAILABLE OUTPUT output) if(LTO_AVAILABLE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) - message(STATUS "Link-tiem optimization (LTO) is supported.") + message(STATUS "Link-time optimization (LTO) is supported.") else() - message(STATUS "Link-time optimization (LTO) is not supported: ${output}.") + message( + STATUS "Link-time optimization (LTO) is not supported: ${output}." + ) endif() endif() @@ -372,15 +478,18 @@ macro(process_options) 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. + # 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}) + 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() @@ -388,8 +497,10 @@ macro(process_options) 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" + 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) @@ -405,10 +516,13 @@ macro(process_options) 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/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 + # 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}) @@ -426,12 +540,14 @@ macro(process_options) endif() if(${NS3_STATIC}) - # Warn users that they may be using shared libraries, which won't produce a standalone static library + # 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." + 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) @@ -443,9 +559,12 @@ macro(process_options) endif() # LibRT + mark_as_advanced(LIBRT) if(${NS3_REALTIME}) if(APPLE) - message(STATUS "Lib RT is not supported on Mac OS X. Continuing without it.") + message( + STATUS "Lib RT is not supported on Mac OS X. Continuing without it." + ) else() find_library(LIBRT rt QUIET) if(NOT ${LIBRT_FOUND}) @@ -491,33 +610,40 @@ macro(process_options) endif() if(${NS3_SCAN_PYTHON_BINDINGS}) - # empty scan target that will depend on other module scan targets to scan all of them + # 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" + if(${NS3_COVERAGE} AND (NOT ${TESTS_ENABLED} OR NOT ${EXAMPLES_ENABLED})) + message( + FATAL_ERROR + "Code coverage requires examples and tests.\n" + "Try reconfiguring CMake with -DNS3_TESTS=ON -DNS3_EXAMPLES=ON" ) endif() - if(${NS3_TESTS}) + if(${TESTS_ENABLED}) add_custom_target(all-test-targets) - # Create a custom target to run test.py --nowaf Target is also used to produce code coverage output + # 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}) + if(${EXAMPLES_ENABLED}) 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) + configure_file( + buildsupport/config-store-config-template.h + ${CMAKE_HEADER_OUTPUT_DIRECTORY}/config-store-config.h + ) set(ENABLE_MPI FALSE) if(${NS3_MPI}) @@ -539,11 +665,9 @@ macro(process_options) 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.") + mark_as_advanced(Boost_INCLUDE_DIR) + find_package(Boost) + if(${Boost_FOUND}) include_directories(${Boost_INCLUDE_DIRS}) set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS}) endif() @@ -558,7 +682,8 @@ macro(process_options) endif() if(${NS3_GNUPLOT}) - find_package(Gnuplot-ios) # Not sure what package would contain the correct header/library + 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() @@ -569,26 +694,33 @@ macro(process_options) endif() if(${NS3_DOCS}) - find_package(Doxygen REQUIRED) - find_program(DOT dot) - find_program(DIA dia) + mark_as_advanced(DOXYGEN DOT DIA) + find_program(DOXYGEN doxygen REQUIRED) + find_program(DOT dot REQUIRED) + find_program(DIA dia REQUIRED) 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" + 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 + COMMAND + ${CMAKE_OUTPUT_DIRECTORY}/utils/ns${NS3_VER}-print-introspected-doxygen${build_profile_suffix} + 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 + 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 + DEPENDS all-test-targets # all-test-targets only exists if TESTS_ENABLED + # is set to ON ) file( @@ -605,18 +737,34 @@ CommandLine configuration in those files instead. # 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 + 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 + COMMAND ${DOXYGEN} ${PROJECT_SOURCE_DIR}/doc/doxygen.conf WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} DEPENDS run-print-introspected-doxygen assemble-introspected-command-line ) + add_custom_target( + doxygen-no-build COMMAND ${DOXYGEN} ${PROJECT_SOURCE_DIR}/doc/doxygen.conf + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + + mark_as_advanced( + SPHINX_EXECUTABLE + SPHINX_OUTPUT_HTML + SPHINX_OUTPUT_MAN + SPHINX_WARNINGS_AS_ERRORS + EPSTOPDF + PDFLATEX + LATEXMK + CONVERT + DVIPNG + ) find_package(Sphinx REQUIRED) find_program(EPSTOPDF epstopdf) find_program(PDFLATEX pdflatex) @@ -641,7 +789,8 @@ CommandLine configuration in those files instead. function(sphinx_target targetname) add_custom_target( - sphinx_${targetname} COMMAND make SPHINXOPTS=-N -k html singlehtml latexpdf + sphinx_${targetname} COMMAND make SPHINXOPTS=-N -k html singlehtml + latexpdf WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doc/${targetname} ) add_dependencies(sphinx sphinx_${targetname}) @@ -669,14 +818,16 @@ CommandLine configuration in those files instead. 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 + # 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." + STATUS + "Long double has the wrong size: LD ${SIZEOF_LONG_DOUBLE} vs D ${SIZEOF_DOUBLE}. Falling back to CAIRO." ) set(INT64X64 "CAIRO") else() @@ -687,7 +838,8 @@ CommandLine configuration in those files instead. include(CheckIncludeFileCXX) include(CheckFunctionExists) - # Check for required headers and functions, set flags if they're found or warn if they're not found + # 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") @@ -698,31 +850,40 @@ CommandLine configuration in those files instead. 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) + 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 + # 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 + # 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}) + if(${EXAMPLES_ENABLED}) 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 + # 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}") + message( + STATUS + "${PLATFORM_UNSUPPORTED_PRE} TAP and EMU ${PLATFORM_UNSUPPORTED_POST}" + ) endif() if(NOT ${ENABLE_MPI}) @@ -737,9 +898,10 @@ CommandLine configuration in those files instead. 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 + # 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-all-enabled-modules) set(ns3-libs-tests) set(ns3-contrib-libs) set(lib-ns3-static-objs) @@ -750,6 +912,7 @@ CommandLine configuration in those files instead. foreach(libname ${scanned_modules}) # Create libname of output library of module library_target_name(${libname} targetname) + mark_as_advanced(lib${libname} lib${libname}-obj) set(lib${libname} ${targetname} CACHE INTERNAL "") set(lib${libname}-obj ${targetname}-obj CACHE INTERNAL "") endforeach() @@ -759,7 +922,20 @@ CommandLine configuration in those files instead. set(optional_visualizer_lib ${libvisualizer}) endif() + set(PRECOMPILE_HEADERS_ENABLED OFF) if(${NS3_PRECOMPILE_HEADERS}) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0") + set(PRECOMPILE_HEADERS_ENABLED ON) + message(STATUS "Precompiled headers were enabled") + else() + message( + STATUS + "CMake ${CMAKE_VERSION} does not support precompiled headers. Continuing without them" + ) + endif() + endif() + + if(${PRECOMPILE_HEADERS_ENABLED}) set(precompiled_header_libraries @@ -780,11 +956,17 @@ CommandLine configuration in those files instead. ) add_library(stdlib_pch OBJECT ${PROJECT_SOURCE_DIR}/buildsupport/empty.cc) - target_precompile_headers(stdlib_pch PUBLIC "${precompiled_header_libraries}") + 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}) + 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 @@ -793,45 +975,58 @@ CommandLine configuration in those files instead. # 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} + # 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_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) + 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) +function(set_runtime_outputdirectory target_name output_directory target_prefix) 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(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} + ${target_prefix}${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? + # 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} + ${target_prefix}${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}) + if(${TESTS_ENABLED}) + add_dependencies(all-test-targets ${target_prefix}${target_name}) endif() if(${NS3_CLANG_TIMETRACE}) - add_dependencies(timeTraceReport ${target_name}) + add_dependencies(timeTraceReport ${target_prefix}${target_name}) endif() endfunction(set_runtime_outputdirectory) @@ -842,8 +1037,9 @@ function(copy_headers_before_building_lib libname outputdir headers visibility) 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} + TARGET ${copy_headers_target} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/${header} ${outputdir}/${header_name} ) endforeach() @@ -852,7 +1048,9 @@ function(copy_headers_before_building_lib libname outputdir headers visibility) # 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 + 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() @@ -861,12 +1059,20 @@ 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}") +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}") + build_lib_example_impl( + "src/${libname}" "${name}" "${source_files}" "${header_files}" + "${libraries_to_link}" + ) endmacro() # Contrib modules counterparts of macros above @@ -877,7 +1083,7 @@ 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)) + if(NOT (${lib} IN_LIST ns3-all-enabled-modules)) set(missing_dependencies TRUE) endif() endforeach() @@ -887,28 +1093,35 @@ macro(build_example name source_files header_files libraries_to_link) add_executable(${name} "${source_files}" "${header_files}") if(${NS3_STATIC}) - target_link_libraries(${name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-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}) + 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} + ${name} ${LIB_AS_NEEDED_PRE} ${libraries_to_link} + ${optional_visualizer_lib} ${LIB_AS_NEEDED_POST} ) endif() - if(${NS3_PRECOMPILE_HEADERS}) + if(${PRECOMPILE_HEADERS_ENABLED}) target_precompile_headers(${name} REUSE_FROM stdlib_pch_exec) endif() - set_runtime_outputdirectory(${name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/examples/${examplefolder}/) + 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 ${${}} + # 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}) @@ -948,7 +1161,9 @@ 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_cmakelist + ${PROJECT_SOURCE_DIR}/contrib/${module_name}/CMakeLists.txt + ) set(contrib FALSE) if(EXISTS ${src_cmakelist}) file(READ ${src_cmakelist} cmakelists_content) @@ -956,23 +1171,29 @@ function(recursive_dependency module_name) file(READ ${contrib_cmakelist} cmakelists_content) set(contrib TRUE) else() - message(STATUS "The CMakeLists.txt file for module ${module_name} was not found.") + 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(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(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}) + #if(${EXAMPLES_ENABLED}) # string(REPLACE "${module_name}" "${module_name}/examples" examples_cmakelist ${examples_cmakelist}) # if(EXISTS ${examples_cmakelist}) # file(READ ${examples_cmakelist} cmakelists_content) @@ -984,22 +1205,35 @@ function(recursive_dependency module_name) # 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))) + 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 +macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build + NS3_ENABLED_MODULES NS3_DISABLED_MODULES ns3rc_enabled_modules +) + mark_as_advanced(ns3-all-enabled-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) + # 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} OR ${ns3rc_enabled_modules}) + # List of enabled modules passed by the command line overwrites list read + # from ns3rc + if(NS3_ENABLED_MODULES) + set(ns3rc_enabled_modules ${${NS3_ENABLED_MODULES}}) + endif() + # Filter enabled modules - filter_modules(NS3_ENABLED_MODULES libs_to_build "") - filter_modules(NS3_ENABLED_MODULES contrib_libs_to_build "") + filter_modules(ns3rc_enabled_modules libs_to_build "") + filter_modules(ns3rc_enabled_modules contrib_libs_to_build "") # Recursively build a list of module dependendencies foreach(lib ${${contrib_libs_to_build}}) @@ -1018,8 +1252,9 @@ macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build NS unset(contrib_dependencies) endforeach() - if(${NS3_TESTS}) - list(APPEND ${libs_to_build} test) # force enable test module if NS3_TESTS is enabled + if(${TESTS_ENABLED}) + list(APPEND ${libs_to_build} test) # force enable test module if + # TESTS_ENABLED is enabled endif() endif() @@ -1028,14 +1263,67 @@ macro(filter_enabled_and_disabled_modules libs_to_build contrib_libs_to_build NS filter_modules(NS3_DISABLED_MODULES contrib_libs_to_build "NOT") endif() + # Older CMake versions require this workaround for empty lists + if(NOT ${contrib_libs_to_build}) + set(${contrib_libs_to_build} "") + 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") + # Export list with all enabled modules (used to separate ns libraries from + # non-ns libraries in ns3_module_macros) + set(ns3-all-enabled-modules "${${libs_to_build}};${${contrib_libs_to_build}}" + CACHE INTERNAL "list with all enabled modules" + ) endmacro() +# Parse .ns3rc +function(parse_ns3rc enabled_modules examples_enabled tests_enabled) + set(ns3rc ${PROJECT_SOURCE_DIR}/.ns3rc) + # Set parent scope variables with default values (all modules, no examples nor + # tests) + set(${enabled_modules} "" PARENT_SCOPE) + set(${examples_enabled} "FALSE" PARENT_SCOPE) + set(${tests_enabled} "FALSE" PARENT_SCOPE) + if(EXISTS ${ns3rc}) + # If ns3rc exists in ns-3-dev, read it + file(READ ${ns3rc} ns3rc_contents) + + # Match modules_enabled list + if(ns3rc_contents MATCHES "modules_enabled.*\\[(.*).*\\]") + set(${enabled_modules} ${CMAKE_MATCH_1}) + if(${enabled_modules} MATCHES "all_modules") + # If all modules, just clean the filter and all modules will get built + # by default + set(${enabled_modules}) + else() + # If modules are listed, remove quotes and replace commas with + # semicollons transforming a string into a cmake list + string(REPLACE "," ";" ${enabled_modules} "${${enabled_modules}}") + string(REPLACE "'" "" ${enabled_modules} "${${enabled_modules}}") + string(REPLACE "\"" "" ${enabled_modules} "${${enabled_modules}}") + string(REPLACE " " "" ${enabled_modules} "${${enabled_modules}}") + endif() + endif() + # Match examples_enabled flag + if(ns3rc_contents MATCHES "examples_enabled = (True|False)") + set(${examples_enabled} ${CMAKE_MATCH_1}) + endif() + + # Match tests_enabled flag + if(ns3rc_contents MATCHES "tests_enabled = (True|False)") + set(${tests_enabled} ${CMAKE_MATCH_1}) + endif() + + # Save variables to parent scope + set(${enabled_modules} "${${enabled_modules}}" PARENT_SCOPE) + set(${examples_enabled} "${${examples_enabled}}" PARENT_SCOPE) + set(${tests_enabled} "${${tests_enabled}}" PARENT_SCOPE) + endif() +endfunction(parse_ns3rc) + # Waf workaround scripts include(buildsupport/custom_modules/waf_workaround_c4cache.cmake) include(buildsupport/custom_modules/waf_workaround_buildstatus.cmake) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6867a30c3..afbf712cc 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,10 +1,12 @@ -if(${NS3_EXAMPLES}) +if(${EXAMPLES_ENABLED}) 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") + 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 index 01c07c6ed..77a1abcb2 100644 --- a/examples/channel-models/CMakeLists.txt +++ b/examples/channel-models/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index 5d58a2ca9..bee0591f3 100644 --- a/examples/energy/CMakeLists.txt +++ b/examples/energy/CMakeLists.txt @@ -1,11 +1,19 @@ 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(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}") +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 index 5bba18d2f..42dc2089f 100644 --- a/examples/error-model/CMakeLists.txt +++ b/examples/error-model/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/examples/ipv6/CMakeLists.txt b/examples/ipv6/CMakeLists.txt index 07bb18990..d9aed784b 100644 --- a/examples/ipv6/CMakeLists.txt +++ b/examples/ipv6/CMakeLists.txt @@ -2,52 +2,72 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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 index 38710e58a..45367e340 100644 --- a/examples/matrix-topology/CMakeLists.txt +++ b/examples/matrix-topology/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index 973612f79..b2712091e 100644 --- a/examples/naming/CMakeLists.txt +++ b/examples/naming/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/examples/realtime/CMakeLists.txt b/examples/realtime/CMakeLists.txt index b9a3e4996..3216d86ff 100644 --- a/examples/realtime/CMakeLists.txt +++ b/examples/realtime/CMakeLists.txt @@ -3,5 +3,7 @@ if(${ENABLE_REALTIME}) 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}") + build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + ) endif() diff --git a/examples/routing/CMakeLists.txt b/examples/routing/CMakeLists.txt index 786bb6715..b484a3def 100644 --- a/examples/routing/CMakeLists.txt +++ b/examples/routing/CMakeLists.txt @@ -1,50 +1,78 @@ 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(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(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(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(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(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}") +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(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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) set(name manet-routing-compare) set(source_files ${name}.cc) @@ -58,19 +86,25 @@ set(libraries_to_link ${libinternet} ${libapplications} ) -build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +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}") +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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) set(name global-routing-multi-switch-plus-router) set(source_files ${name}.cc) @@ -86,10 +120,16 @@ set(libraries_to_link ${libcsma} ${libinternet} ) -build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +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}") +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 index 4fcd6fff4..bec0ab70c 100644 --- a/examples/socket/CMakeLists.txt +++ b/examples/socket/CMakeLists.txt @@ -1,23 +1,39 @@ 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(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(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(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}") +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 index 1daa94e9f..9384d909c 100644 --- a/examples/stats/CMakeLists.txt +++ b/examples/stats/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/examples/tcp/CMakeLists.txt b/examples/tcp/CMakeLists.txt index 251fd387a..6fd059bec 100644 --- a/examples/tcp/CMakeLists.txt +++ b/examples/tcp/CMakeLists.txt @@ -2,33 +2,50 @@ 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}") + 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}") + 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}") + 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}") +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}") +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(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) @@ -41,43 +58,66 @@ set(libraries_to_link ${libinternet-apps} ${libflow-monitor} ) -build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +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}") +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}") +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(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(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(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} +set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} + ${libtraffic-control} ${libnetwork} ${libinternet-apps} +) +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" ) -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} +set(libraries_to_link + ${libcore} ${libnetwork} ${libinternet} ${libpoint-to-point} + ${libapplications} ${libtraffic-control} +) +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" ) -build_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/examples/traffic-control/CMakeLists.txt b/examples/traffic-control/CMakeLists.txt index b2d882309..059eeb8bd 100644 --- a/examples/traffic-control/CMakeLists.txt +++ b/examples/traffic-control/CMakeLists.txt @@ -1,41 +1,62 @@ 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(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} +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}" ) -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} +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}" ) -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} +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}" ) -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(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}") +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 index 0182612c2..8c500e3f7 100644 --- a/examples/tutorial/CMakeLists.txt +++ b/examples/tutorial/CMakeLists.txt @@ -2,46 +2,74 @@ 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}") +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(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(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(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}") +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(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(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}") +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 index 27c61efa2..05a942f1b 100644 --- a/examples/udp-client-server/CMakeLists.txt +++ b/examples/udp-client-server/CMakeLists.txt @@ -2,10 +2,14 @@ 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}") +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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/examples/udp/CMakeLists.txt b/examples/udp/CMakeLists.txt index c28d3bca0..0475df2a8 100644 --- a/examples/udp/CMakeLists.txt +++ b/examples/udp/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/examples/wireless/CMakeLists.txt b/examples/wireless/CMakeLists.txt index a6d9e543a..5e9333f26 100644 --- a/examples/wireless/CMakeLists.txt +++ b/examples/wireless/CMakeLists.txt @@ -2,232 +2,314 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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(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}") +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}") +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}") +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(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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +build_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/ns3 b/ns3 index f23778951..65bccb029 100755 --- a/ns3 +++ b/ns3 @@ -10,6 +10,11 @@ import sys from utils import read_config_file +out_dir = "" +build_separator = "" +ns3_path = os.path.dirname(os.path.abspath(__file__)) +lock_file = os.sep.join([ns3_path, ".lock-waf_%s_build" % sys.platform]) + def on_off_argument(parser, option_name, help_on, help_off=None): parser.add_argument('--enable-%s' % option_name, @@ -35,10 +40,11 @@ def on_off_condition(args, cmake_flag, option_name): def parse_args(argv): - parser = argparse.ArgumentParser("ns-3 wrapper for the CMake build system") + parser = argparse.ArgumentParser(description="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 = sub_parser.add_parser('configure', + help='Try "./ns3 configure --help" for more configuration options') parser_configure.add_argument('configure', nargs='?', action='store', default=True) @@ -72,6 +78,7 @@ def parse_args(argv): 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 = on_off_argument(parser_configure, "documentation", "documentation targets") parser_configure.add_argument('--enable-modules', help='List of modules to build (e.g. core;network;internet)', @@ -89,6 +96,10 @@ def parse_args(argv): 'when generating repeated lcov reports)'), action="store_true", default=None) + parser_configure.add_argument('--out', '--output-directory', + help=('Use BRITE integration support, given by the indicated path,' + ' to allow the use of the BRITE topology generator'), + type=str, default=None, dest="output_directory") 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'), @@ -104,17 +115,21 @@ def parse_args(argv): 'the cache and reconfiguring the project', action="store_true", default=None) - parser_build = sub_parser.add_parser('build', help='build --help') + parser_build = sub_parser.add_parser('build', + help='Accepts a list of targets to build, or builds the entire project if no target is given') 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 = sub_parser.add_parser('clean', help='Removes files created by waf and ns3') parser_clean.add_argument('clean', nargs="?", action="store", default=True) - parser.add_argument('--verbose', + parser.add_argument('--dry-run', + help="Do not execute the commands", + action="store_true", default=None) + parser.add_argument('-v', '--verbose', help="Print underlying commands", action="store_true", default=None) parser.add_argument('--check-config', @@ -134,7 +149,7 @@ def parse_args(argv): type=str, default='') parser.add_argument('--run-no-build', help=( - 'Run a locally built program without rebuilding the project;' + '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', @@ -162,6 +177,9 @@ def parse_args(argv): 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('-j', '--jobs', + help='Set number of parallel jobs', + action='store', type=int, dest="jobs", default=max(1, os.cpu_count() - 1)) # parser.add_argument('--shell', # help=('DEPRECATED (run ./waf shell)'), # action="store_true", default=None) @@ -174,10 +192,13 @@ def parse_args(argv): 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('--doxygen', + help='Run doxygen to generate html documentation from source comments.', + 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.' @@ -188,36 +209,45 @@ def parse_args(argv): return parser.parse_args(argv) -def check_build_profile(ns3_path): +def check_build_profile(output_directory): # 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"]) + c4che_path = os.sep.join([output_directory, "c4che", "_cache.py"]) build_profile = None ns3_version = None ns3_modules = None - if os.path.exists(c4che_path): + ns3_modules_tests = [] + if output_directory and 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 + ns3_modules_tests = [x + "-test" for x in ns3_modules] + return build_profile, ns3_version, ns3_modules + ns3_modules_tests if ns3_modules else None -def clean_cmake_artifacts(ns3_path, verbose=False): +def clean_cmake_artifacts(verbose=False, dry_run=False): if verbose: - print("rm -R %s/build" % ns3_path) + print("rm -R %s" % out_dir) - shutil.rmtree(ns3_path + os.sep + "build", ignore_errors=True) - cmake_cache_files = glob.glob("./**/CMakeCache.txt", recursive=True) + if not dry_run: + shutil.rmtree(out_dir, ignore_errors=True) + cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, 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) + if not dry_run: + shutil.rmtree(dirname, ignore_errors=True) + + if os.path.exists(lock_file): + if verbose: + print("rm %s" % lock_file) + os.remove(lock_file) -def search_cmake_cache(ns3_path, build_profile): +def search_cmake_cache(build_profile): # Search for the CMake cache cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True) current_cmake_cache_folder = None @@ -274,6 +304,8 @@ def search_cmake_cache(ns3_path, build_profile): def check_config(current_cmake_cache_folder): + if current_cmake_cache_folder is None: + raise Exception("Project was not configured") 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") @@ -281,7 +313,8 @@ def check_config(current_cmake_cache_folder): print(f.read()) -def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_generator, output, verbose=False): +def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_generator, output, verbose=False, + dry_run=False): # Aggregate all flags to configure CMake cmake_args = [cmake] @@ -325,7 +358,8 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener ("MPI", "mpi"), ("GTK3", "gtk"), ("WARNINGS", "warnings"), - ("WARNINGS_AS_ERRORS", "werror") + ("WARNINGS_AS_ERRORS", "werror"), + ("DOCS", "documentation") ) for (cmake_flag, option_name) in options: arg = on_off_condition(args, cmake_flag, option_name) @@ -335,7 +369,10 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener if args.lcov_zerocounters is not None: cmake_args.append("-DNS3_COVERAGE_ZERO_COUNTERS=%s" % on_off(args.lcov_zerocounters)) - # Brite, Click and Openflow + # Output, Brite, Click and Openflow directories + if args.output_directory is not None: + cmake_args.append("-DNS3_OUTPUT_DIRECTORY=%s" % args.output_directory) + if args.with_brite is not None: cmake_args.append("-DNS3_WITH_BRITE=%s" % args.with_brite) @@ -373,13 +410,14 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener print("cd %s; %s" % (current_cmake_cache_folder, " ".join(cmake_args))) # Run cmake - subprocess.run(cmake_args, cwd=current_cmake_cache_folder, stdout=output) + if not dry_run: + 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"]) +def get_program_shortcuts(build_profile, ns3_version): + build_status_file = os.sep.join([out_dir, "build-status.py"]) # Import programs from build-status.py programs_dict = {} @@ -387,10 +425,11 @@ def get_program_shortcuts(ns3_path, build_profile, ns3_version): # We can now build a map to simplify things for users (at this point we could remove versioning prefix/suffix) ns3_program_map = {} + out_dir_name = os.path.basename(out_dir) for program in programs_dict["ns3_runnable_programs"]: if "pch_exec" in program: continue - temp_path = program.split("build")[-1].split(os.sep) + temp_path = program.split(out_dir_name)[-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 + "-", "") @@ -411,11 +450,21 @@ def get_program_shortcuts(ns3_path, build_profile, ns3_version): 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 "") +def cmake_build(current_cmake_cache_folder, output, jobs, target=None, verbose=False, dry_run=False): + # Check CMake version + cmake = shutil.which("cmake") + if not cmake: + raise Exception("CMake was not found") + version = re.findall("version (.*)\n", subprocess.check_output([cmake, "--version"]).decode("utf-8"))[0] + + # Older CMake versions do not accept the number of jobs directly + jobs_part = ("-j %d" % jobs) if version >= "3.12.0" else "" + target_part = (" --target %s" % target) if target else "" + cmake_build_command = "cmake --build . %s%s" % (jobs_part, target_part) 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) + if not dry_run: + subprocess.run(cmake_build_command.split(), cwd=current_cmake_cache_folder, stdout=output) def extract_cmakecache_settings(current_cmake_cache_folder): @@ -431,7 +480,7 @@ def extract_cmakecache_settings(current_cmake_cache_folder): return dict(current_settings) -def reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output, verbose=False): +def reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output, verbose=False, dry_run=False): import json settings_bak_file = "settings.json" @@ -445,8 +494,9 @@ def reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output # 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) + if not dry_run: + 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: @@ -464,43 +514,32 @@ def reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output 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 not dry_run: + 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) + # 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): +def get_target_to_build(program_path, 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] + program_name = "".join(*re.findall("(.*)ns%s-(.*)%s" % (ns3_version, build_profile_suffix), program_path)) + + if "scratch" in program_path: + # Get the path to the program and replace slashes with underlines + # to get unique targets for CMake, preventing collisions with modules examples + return program_name.split(out_dir + "/")[1].replace("/", "_") + else: + # Other programs just use their normal names (without version prefix and build_profile suffix) as targets + return program_name.split("/")[-1] -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): +def configuration_step(current_cmake_cache_folder, current_cmake_generator, args, run_only, configure_and_run, + output, dry_run=False): # 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) @@ -511,12 +550,13 @@ def configuration_step(ns3_path, current_cmake_cache_folder, current_cmake_gener 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 + current_cmake_cache_folder = os.sep.join([ns3_path, "cmake_cache"]) 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) + if not dry_run: + 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") @@ -527,7 +567,7 @@ def configuration_step(ns3_path, current_cmake_cache_folder, current_cmake_gener # 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) + reconfigure_cmake_to_force_refresh(cmake, current_cmake_cache_folder, output, args.verbose, dry_run) exit(0) # Call cmake to configure/reconfigure/refresh the project @@ -536,7 +576,8 @@ def configuration_step(ns3_path, current_cmake_cache_folder, current_cmake_gener current_cmake_cache_folder, current_cmake_generator, output, - args.verbose + args.verbose, + dry_run ) # If manually configuring, we end the script earlier @@ -557,53 +598,81 @@ def build_step(args, 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) + cmake_build(current_cmake_cache_folder, + jobs=args.jobs, + output=output, + verbose=args.verbose, + dry_run=args.dry_run + ) 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: + non_executable_targets = ["doxygen", "doxygen-no-build"] # 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) + elif target not in non_executable_targets: + target = get_target_to_build(target, ns3_version, build_profile) + cmake_build(current_cmake_cache_folder, + jobs=args.jobs, + target=target, + output=output, + verbose=args.verbose, + dry_run=args.dry_run) # 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), + jobs=args.jobs, + target=get_target_to_build(target_to_run, ns3_version, build_profile), output=output, - verbose=args.verbose + verbose=args.verbose, + dry_run=args.dry_run ) def main(): + global out_dir # 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) + # If Dry-run, do not execute the commands, only print the underlying commands from --verbose + if args.dry_run: + args.verbose = True + + # Read contents from lock (output directory is important) + if os.path.exists(lock_file): + exec(open(lock_file).read(), globals()) + else: + out_dir = os.sep.join([ns3_path, "build"]) # Clean project if needed if "clean" in args and args.clean: - clean_cmake_artifacts(ns3_path, verbose=args.verbose) + clean_cmake_artifacts(verbose=args.verbose, dry_run=args.dry_run) # We end things earlier when cleaning return + # Doxygen-no-build requires print-introspected-doxygen, but it has no explicit dependencies, + # differently from the doxygen target + if args.doxygen: + args.build = ['doxygen'] + + if args.doxygen_no_build: + args.build = ['doxygen-no-build'] + # Get build profile - build_profile, ns3_version, ns3_modules = check_build_profile(ns3_path) + build_profile, ns3_version, ns3_modules = check_build_profile(out_dir) # Check if running something or reconfiguring ns-3 run_only = args.run_no_build or args.pyrun_no_build @@ -612,37 +681,43 @@ def main(): 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: + # While testing a weird case appeared where the target to run is between quotes, + # so we remove in case they exist + if target_to_run[0] in ["\"", "'"] and target_to_run[-1] in ["\"", "'"]: + target_to_run = target_to_run[1:-1] 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) + current_cmake_cache_folder, current_cmake_generator = search_cmake_cache(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 + first_run, current_cmake_cache_folder = configuration_step(current_cmake_cache_folder=current_cmake_cache_folder, + current_cmake_generator=current_cmake_generator, + args=args, + run_only=run_only, + configure_and_run=configure_and_run, + output=output, + dry_run=args.dry_run ) + # re-read contents from lock (output directory is important) # 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) + exec(open(lock_file).read(), globals()) + build_profile, ns3_version, ns3_modules = check_build_profile(out_dir) # 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) + ns3_programs = get_program_shortcuts(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: @@ -651,6 +726,13 @@ def main(): else: raise Exception("Couldn't find the specified program: %s" % target_to_run) + if "build" in args: + complete_targets = [] + for target in args.build: + complete_targets.append(ns3_programs[target] if target in ns3_programs else target) + args.build = complete_targets + del complete_targets + build_step(args, configure_and_run, target_to_run, @@ -661,6 +743,15 @@ def main(): output ) + # To determine if we are being called to run-no-build a waf build, + # we can just check if the out_dir matches the base folder from the target_to_run + if out_dir.split(os.sep)[-1] == target_to_run.split(os.sep)[0]: + target_to_run = target_to_run.replace(out_dir.split(os.sep)[-1] + os.sep, "") + # Waf doesn't add version prefix and build type suffix to scratches, so we remove them + if "scratch" in target_to_run and run_only: + target_to_run = target_to_run.replace(os.path.basename(target_to_run), run_only) + target_to_run = os.sep.join([out_dir, target_to_run]) + # 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") @@ -668,9 +759,9 @@ def main(): # 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, + paths_to_add = path_sep.join([out_dir, + "%s/lib" % out_dir, + "%s/bindings/python" % out_dir, ]) proc_env = {"PATH": os.getenv("PATH") + path_sep + paths_to_add, "LD_LIBRARY_PATH": paths_to_add, @@ -695,8 +786,8 @@ def main(): # running test.py/check? if args.check: - target_to_run = ns3_path + os.sep + "test.py" - target_args = ["--nowaf"] + target_to_run = os.sep.join([ns3_path, "test.py"]) + target_args = ["--nowaf", "--jobs=%d" % args.jobs] # running with command template? if args.command_template: @@ -712,10 +803,11 @@ def main(): 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") + if not args.dry_run: + try: + subprocess.run(program_arguments, env=proc_env, cwd=working_dir) + except KeyboardInterrupt: + print("Process was interrupted by the user") return 0 diff --git a/scratch/CMakeLists.txt b/scratch/CMakeLists.txt index eb7520812..182b34d94 100644 --- a/scratch/CMakeLists.txt +++ b/scratch/CMakeLists.txt @@ -1,6 +1,7 @@ file(GLOB_RECURSE scratches ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) set(DONT_BUILD) +set(target_prefix scratch_) foreach(scratch_src ${scratches}) # Get source filename without path or extension @@ -9,17 +10,27 @@ foreach(scratch_src ${scratches}) # 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}) + string(REPLACE "${PROJECT_SOURCE_DIR}" "${CMAKE_OUTPUT_DIRECTORY}" + 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}") + add_executable(${target_prefix}${scratch_name} "${scratch_src}") if(${NS3_STATIC}) - target_link_libraries(${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-ns3-static}) + target_link_libraries( + ${target_prefix}${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC} + ${lib-ns3-static} + ) else() - target_link_libraries(${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}") + target_link_libraries( + ${target_prefix}${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}" + "${ns3-external-libs}" + ) endif() - set_runtime_outputdirectory(${scratch_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/scratch/${scratch_directory}/) + set_runtime_outputdirectory( + ${scratch_name} ${scratch_directory}/ ${target_prefix} + ) endif() endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5b8f2715..0376862e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,14 +8,25 @@ endif() # Process subdirectories foreach(libname ${libs}) - add_subdirectory(${libname}) + if(EXISTS ${PROJECT_SOURCE_DIR}/src/${libname}/CMakeLists.txt) + add_subdirectory(${libname}) + else() + message( + STATUS + "Skipping src/${libname} : it does not contain a CMakeLists.txt file" + ) + endif() 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}") + 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 + # 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")) @@ -26,7 +37,9 @@ if(${NS3_STATIC}) if(EXISTS ${output}) list(APPEND ns3-external-static-libs ${output}) else() - message(FATAL_ERROR "Static library version of ${sharedlib} was not found") + message( + FATAL_ERROR "Static library version of ${sharedlib} was not found" + ) endif() endforeach() @@ -44,11 +57,20 @@ if(${NS3_STATIC}) endif() endif() -# Build the lib-ns3-static (ns3.x-monolib-buildtype.dll/.dylib/.so) with all sublibraries +# 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}) + 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() diff --git a/src/antenna/CMakeLists.txt b/src/antenna/CMakeLists.txt index 9d96bb800..ccdbb22f1 100644 --- a/src/antenna/CMakeLists.txt +++ b/src/antenna/CMakeLists.txt @@ -25,8 +25,12 @@ set(header_files # 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 +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}") +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + "${test_sources}" +) diff --git a/src/aodv/CMakeLists.txt b/src/aodv/CMakeLists.txt index 71b2a6876..bf183d17a 100644 --- a/src/aodv/CMakeLists.txt +++ b/src/aodv/CMakeLists.txt @@ -25,8 +25,10 @@ set(header_files # 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 +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}") +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 index bae72d1f8..1a47b4f23 100644 --- a/src/aodv/examples/CMakeLists.txt +++ b/src/aodv/examples/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/applications/CMakeLists.txt b/src/applications/CMakeLists.txt index 285c05ca9..68c56345e 100644 --- a/src/applications/CMakeLists.txt +++ b/src/applications/CMakeLists.txt @@ -55,8 +55,11 @@ set(header_files # 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 +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}") +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 index 86b48826a..4e6d4acb9 100644 --- a/src/applications/examples/CMakeLists.txt +++ b/src/applications/examples/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index bc14d81d7..5c0da35bf 100644 --- a/src/bridge/CMakeLists.txt +++ b/src/bridge/CMakeLists.txt @@ -1,12 +1,18 @@ set(name bridge) -set(source_files helper/bridge-helper.cc model/bridge-channel.cc model/bridge-net-device.cc) +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) +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}") +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 index 57195d969..dd210ef4e 100644 --- a/src/bridge/examples/CMakeLists.txt +++ b/src/bridge/examples/CMakeLists.txt @@ -2,10 +2,14 @@ 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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/brite/CMakeLists.txt b/src/brite/CMakeLists.txt index 80d9fd8bb..89b98950a 100644 --- a/src/brite/CMakeLists.txt +++ b/src/brite/CMakeLists.txt @@ -4,8 +4,12 @@ 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) +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}") @@ -24,8 +28,12 @@ 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(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}") +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 index 88eb547a9..4d891963c 100644 --- a/src/brite/examples/CMakeLists.txt +++ b/src/brite/examples/CMakeLists.txt @@ -1,8 +1,12 @@ 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}") +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) @@ -17,6 +21,8 @@ if(${ENABLE_MPI}) ${libmpi} ${MPI_CXX_LIBRARIES} ) - build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + 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 index e7f516ecd..2d17aa2cf 100644 --- a/src/buildings/CMakeLists.txt +++ b/src/buildings/CMakeLists.txt @@ -46,4 +46,6 @@ set(test_sources test/three-gpp-v2v-channel-condition-model-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 8d8412e2f..c45b5ed8e 100644 --- a/src/buildings/examples/CMakeLists.txt +++ b/src/buildings/examples/CMakeLists.txt @@ -1,17 +1,25 @@ 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(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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/click/CMakeLists.txt b/src/click/CMakeLists.txt index 1ee0bb7a5..a14f1eb1b 100644 --- a/src/click/CMakeLists.txt +++ b/src/click/CMakeLists.txt @@ -5,9 +5,12 @@ 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 +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)) @@ -15,25 +18,36 @@ if(NOT (click_dep AND click_header)) 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) +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(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(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}") +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 +# 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 index 677cb1281..2afa61ae3 100644 --- a/src/click/examples/CMakeLists.txt +++ b/src/click/examples/CMakeLists.txt @@ -4,34 +4,46 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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 index 1d8e90bee..17bd967e6 100644 --- a/src/config-store/CMakeLists.txt +++ b/src/config-store/CMakeLists.txt @@ -1,8 +1,8 @@ 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_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) @@ -28,8 +28,12 @@ set(source_files set(header_files ${gtk3_headers} model/file-config.h model/config-store.h) -set(libraries_to_link ${libcore} ${libnetwork} ${xml2_libraries} ${gtk_libraries}) +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}") +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 index 195d65239..98d23921a 100644 --- a/src/config-store/examples/CMakeLists.txt +++ b/src/config-store/examples/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2da4fa866..164e8e20e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -8,7 +8,9 @@ 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) + set(gsl_test_sources test/rng-test-suite.cc + test/random-variable-stream-test-suite.cc + ) endif() # Check for dependencies and add sources accordingly @@ -18,13 +20,17 @@ 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." + 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_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}) @@ -54,17 +60,20 @@ 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_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(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}) +if(${EXAMPLES_ENABLED}) 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) @@ -84,7 +93,6 @@ set(source_files ${osclock_sources} ${int64x64_sources} ${thread_sources} - ${valgrind_sources} ${example_as_test_sources} ${embedded_version_sources} helper/csv-reader.cc @@ -289,4 +297,6 @@ set(test_sources ) # Build core lib -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 2e46f29bd..f4ece67be 100644 --- a/src/core/examples/CMakeLists.txt +++ b/src/core/examples/CMakeLists.txt @@ -2,80 +2,106 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") + build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + ) endif() if(${ENABLE_REALTIME}) @@ -83,23 +109,31 @@ if(${ENABLE_REALTIME}) set(source_files ${name}.cc) set(header_files) set(libraries_to_link ${libnetwork}) - build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") + 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}") +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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/csma-layout/CMakeLists.txt b/src/csma-layout/CMakeLists.txt index 5ed1bc6e3..08c02b4d3 100644 --- a/src/csma-layout/CMakeLists.txt +++ b/src/csma-layout/CMakeLists.txt @@ -4,8 +4,12 @@ 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(libraries_to_link ${libnetwork} ${libinternet} ${libcsma} + ${libpoint-to-point} +) set(test_sources) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${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 index c5e268c2f..e2f878d76 100644 --- a/src/csma-layout/examples/CMakeLists.txt +++ b/src/csma-layout/examples/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index 819c23f9c..c400fadee 100644 --- a/src/csma/CMakeLists.txt +++ b/src/csma/CMakeLists.txt @@ -1,8 +1,12 @@ set(name csma) -set(source_files helper/csma-helper.cc model/backoff.cc model/csma-channel.cc model/csma-net-device.cc) +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(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}) @@ -10,4 +14,6 @@ set(libraries_to_link ${libnetwork}) set(test_sources) # Build csma lib -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 5235b8eb5..5bb54c3fe 100644 --- a/src/csma/examples/CMakeLists.txt +++ b/src/csma/examples/CMakeLists.txt @@ -2,34 +2,50 @@ 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}") +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}") +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}") +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}") +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(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}") +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 index 623e99a15..4effbe6c5 100644 --- a/src/dsdv/CMakeLists.txt +++ b/src/dsdv/CMakeLists.txt @@ -1,15 +1,19 @@ 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(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(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}") +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 index 228ba5a1b..e94ddd182 100644 --- a/src/dsdv/examples/CMakeLists.txt +++ b/src/dsdv/examples/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/dsr/CMakeLists.txt b/src/dsr/CMakeLists.txt index bf9177288..7e9309fb1 100644 --- a/src/dsr/CMakeLists.txt +++ b/src/dsr/CMakeLists.txt @@ -37,4 +37,6 @@ 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}") +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 index 0a41942b6..ced605834 100644 --- a/src/dsr/examples/CMakeLists.txt +++ b/src/dsr/examples/CMakeLists.txt @@ -11,4 +11,6 @@ set(libraries_to_link ${libwifi} ${libdsr} ) -build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/energy/CMakeLists.txt b/src/energy/CMakeLists.txt index 9a325b2aa..c19ae0af5 100644 --- a/src/energy/CMakeLists.txt +++ b/src/energy/CMakeLists.txt @@ -42,6 +42,10 @@ set(header_files set(libraries_to_link ${libnetwork}) -set(test_sources test/basic-energy-harvester-test.cc test/li-ion-energy-source-test.cc) +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}") +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 index 3f54e99c6..4df1dd42f 100644 --- a/src/energy/examples/CMakeLists.txt +++ b/src/energy/examples/CMakeLists.txt @@ -2,16 +2,22 @@ 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}") +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}") +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}") +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 index 60caa4fc0..413d7ea7f 100644 --- a/src/fd-net-device/CMakeLists.txt +++ b/src/fd-net-device/CMakeLists.txt @@ -1,5 +1,6 @@ set(name fd-net-device) +mark_as_advanced(ENABLE_THREADING) set(ENABLE_THREADING ${HAVE_PTHREAD_H}) check_include_file_cxx(net/ethernet.h HAVE_NET_ETHERNET_H) @@ -14,6 +15,9 @@ if(PKG_CONFIG_FOUND) pkg_check_modules(DPDK libdpdk) endif() +mark_as_advanced( + ENABLE_FDNETDEV ENABLE_DPDKDEVNET ENABLE_TAP ENABLE_EMU ENABLE_NETMAP_EMU +) set(ENABLE_FDNETDEV False CACHE INTERNAL "") set(ENABLE_DPDKDEVNET False CACHE INTERNAL "") set(ENABLE_TAP False CACHE INTERNAL "") @@ -53,18 +57,20 @@ 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/) + 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}/src/fd-net-device/ns${NS3_VER}-raw-sock-creator${build_profile_suffix}" + ) + set_runtime_outputdirectory( + raw-sock-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/ "" + ) list(APPEND fd-net-device_creators raw-sock-creator) endif() @@ -73,10 +79,17 @@ if(${ENABLE_FDNETDEV}) 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/) + 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/ns${NS3_VER}-tap-device-creator${build_profile_suffix}" + ) + set_runtime_outputdirectory( + tap-device-creator ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/ + "" + ) list(APPEND fd-net-device_creators tap-device-creator) endif() @@ -85,27 +98,41 @@ if(${ENABLE_FDNETDEV}) 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 + 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}/src/fd-net-device/ns${NS3_VER}-device_planetlab-tap-creator${build_profile_suffix}" ) - 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/) + 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 + 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 + ) + + 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}/src/fd-net-device/ns${NS3_VER}-netmap-device-creator${build_profile_suffix}" + ) + set_runtime_outputdirectory( + netmap-device-creator + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/fd-net-device/ "" ) - 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() @@ -128,18 +155,25 @@ if(${ENABLE_FDNETDEV}) 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(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(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}") + 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_include_directories( + ${libfd-net-device-obj} PRIVATE ${DPDK_INCLUDE_DIRS} + ) target_compile_options(${libfd-net-device-obj} PRIVATE ${DPDK_CFLAGS}) endif() diff --git a/src/fd-net-device/examples/CMakeLists.txt b/src/fd-net-device/examples/CMakeLists.txt index b9275d978..cf5601590 100644 --- a/src/fd-net-device/examples/CMakeLists.txt +++ b/src/fd-net-device/examples/CMakeLists.txt @@ -4,26 +4,34 @@ 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}") +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}") +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}") + 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}") + build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + ) endif() if(${ENABLE_EMU}) @@ -31,31 +39,45 @@ if(${ENABLE_EMU}) 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}") + 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}") + 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}") + 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(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}") + 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}) @@ -63,13 +85,19 @@ if(${ENABLE_TAP}) 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}") + 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}") + 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}) @@ -77,5 +105,7 @@ if(${NS3_PLANETLAB}) 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}") + 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 index dff89e78f..ba1dd5a31 100644 --- a/src/flow-monitor/CMakeLists.txt +++ b/src/flow-monitor/CMakeLists.txt @@ -26,4 +26,6 @@ set(libraries_to_link ${libinternet} ${libconfig-store}) set(test_sources) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + "${test_sources}" +) diff --git a/src/internet-apps/CMakeLists.txt b/src/internet-apps/CMakeLists.txt index 66286bbac..6e6143c55 100644 --- a/src/internet-apps/CMakeLists.txt +++ b/src/internet-apps/CMakeLists.txt @@ -38,4 +38,6 @@ 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}") +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 index 4ecbcc6bc..2732ac2df 100644 --- a/src/internet-apps/examples/CMakeLists.txt +++ b/src/internet-apps/examples/CMakeLists.txt @@ -1,5 +1,25 @@ 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}") +set(libraries_to_link ${libinternet} ${libinternet-apps} ${libcsma} + ${libpoint-to-point} ${libapplications} +) +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) + +set(name traceroute-example) +set(source_files ${name}.cc) +set(header_files) +set(libraries_to_link + ${libaodv} + ${libcore} + ${libnetwork} + ${libinternet} + ${libpoint-to-point} + ${libwifi} + ${libinternet-apps} +) +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt index c10ba9130..453dd2700 100644 --- a/src/internet/CMakeLists.txt +++ b/src/internet/CMakeLists.txt @@ -3,8 +3,12 @@ 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) + 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 @@ -264,7 +268,9 @@ set(header_files model/windowed-filter.h ) -set(libraries_to_link ${libnetwork} ${libcore} ${libbridge} ${libtraffic-control}) +set(libraries_to_link ${libnetwork} ${libcore} ${libbridge} + ${libtraffic-control} +) set(test_sources test/global-route-manager-impl-test-suite.cc @@ -341,4 +347,6 @@ set(test_sources test/udp-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 79f660dbb..4def95a29 100644 --- a/src/internet/examples/CMakeLists.txt +++ b/src/internet/examples/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +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 index 79c46588a..728ee4360 100644 --- a/src/lr-wpan/CMakeLists.txt +++ b/src/lr-wpan/CMakeLists.txt @@ -34,7 +34,9 @@ set(header_files model/lr-wpan-spectrum-value-helper.h ) -set(libraries_to_link ${libnetwork} ${libcore} ${libmobility} ${libspectrum} ${libpropagation}) +set(libraries_to_link ${libnetwork} ${libcore} ${libmobility} ${libspectrum} + ${libpropagation} +) set(test_sources test/lr-wpan-ack-test.cc @@ -49,4 +51,6 @@ set(test_sources test/lr-wpan-slotted-csmaca-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 60f46c3a3..0341722f5 100644 --- a/src/lr-wpan/examples/CMakeLists.txt +++ b/src/lr-wpan/examples/CMakeLists.txt @@ -2,28 +2,38 @@ 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}") +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}") +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}") +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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/lte/CMakeLists.txt b/src/lte/CMakeLists.txt index 08e06e563..6f22d2373 100644 --- a/src/lte/CMakeLists.txt +++ b/src/lte/CMakeLists.txt @@ -342,4 +342,6 @@ set(test_sources test/test-lte-x2-handover.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 5aebbc185..d69c41db5 100644 --- a/src/lte/examples/CMakeLists.txt +++ b/src/lte/examples/CMakeLists.txt @@ -2,132 +2,176 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") +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}") + build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + ) endif() diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index fdd2f121d..a611f0a87 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -85,4 +85,6 @@ set(test_sources test/mesh-information-element-vector-test-suite.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 9ba81dce0..247bbb1c5 100644 --- a/src/mesh/examples/CMakeLists.txt +++ b/src/mesh/examples/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index c970cd381..a574ab364 100644 --- a/src/mobility/CMakeLists.txt +++ b/src/mobility/CMakeLists.txt @@ -59,4 +59,6 @@ set(test_sources test/waypoint-mobility-model-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 7f7080636..91a5e5a0c 100644 --- a/src/mobility/examples/CMakeLists.txt +++ b/src/mobility/examples/CMakeLists.txt @@ -2,40 +2,54 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/mpi/CMakeLists.txt b/src/mpi/CMakeLists.txt index a4b66b1d4..9a3632755 100644 --- a/src/mpi/CMakeLists.txt +++ b/src/mpi/CMakeLists.txt @@ -14,15 +14,19 @@ set(source_files model/remote-channel-bundle.cc ) -set(header_files model/mpi-interface.h model/mpi-receiver.h model/parallel-communication-interface.h) +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}) +if(${EXAMPLES_ENABLED}) 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}") +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 index 7d59033f6..cbc0650f3 100644 --- a/src/mpi/examples/CMakeLists.txt +++ b/src/mpi/examples/CMakeLists.txt @@ -4,8 +4,12 @@ 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(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) @@ -19,22 +23,36 @@ set(libraries_to_link ${libcsma} ${libapplications} ) -build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +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(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(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}") +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 index dc19d1e2e..1f082ddf0 100644 --- a/src/netanim/CMakeLists.txt +++ b/src/netanim/CMakeLists.txt @@ -20,4 +20,6 @@ set(libraries_to_link set(test_sources test/netanim-test.cc) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index a21c6bd8a..0901676d3 100644 --- a/src/netanim/examples/CMakeLists.txt +++ b/src/netanim/examples/CMakeLists.txt @@ -1,20 +1,32 @@ 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(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(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(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) @@ -28,22 +40,36 @@ set(libraries_to_link ${libmobility} ${libnetwork} ) -build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +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(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(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}") +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 index d054fb7d2..6e0941560 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -166,4 +166,6 @@ set(test_sources test/test-data-rate.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 1c808e5b6..2bf821ef2 100644 --- a/src/network/examples/CMakeLists.txt +++ b/src/network/examples/CMakeLists.txt @@ -3,24 +3,34 @@ 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}") +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}") +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}") +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}") +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}") +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 index d14c32be6..cb12649bf 100644 --- a/src/nix-vector-routing/CMakeLists.txt +++ b/src/nix-vector-routing/CMakeLists.txt @@ -4,10 +4,14 @@ 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(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}") +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 index c4b16d48a..8bdda7ee0 100644 --- a/src/nix-vector-routing/examples/CMakeLists.txt +++ b/src/nix-vector-routing/examples/CMakeLists.txt @@ -1,9 +1,13 @@ set(header_files) -set(libraries_to_link ${libpoint-to-point} ${libinternet} ${libapplications} ${libnix-vector-routing}) +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}") + build_lib_example( + "${example}" "${source_files}" "${header_files}" "${libraries_to_link}" + ) endforeach() diff --git a/src/olsr/CMakeLists.txt b/src/olsr/CMakeLists.txt index 3a2e5e406..1cf18ce1c 100644 --- a/src/olsr/CMakeLists.txt +++ b/src/olsr/CMakeLists.txt @@ -1,15 +1,22 @@ set(name olsr) -set(source_files helper/olsr-helper.cc model/olsr-header.cc model/olsr-routing-protocol.cc model/olsr-state.cc) +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(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 +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}") +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 index 60961ece0..313a89335 100644 --- a/src/olsr/examples/CMakeLists.txt +++ b/src/olsr/examples/CMakeLists.txt @@ -1,11 +1,19 @@ 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(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}") +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 index bbf9e30a1..306a08381 100644 --- a/src/openflow/CMakeLists.txt +++ b/src/openflow/CMakeLists.txt @@ -1,13 +1,19 @@ 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") +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 +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)) @@ -15,20 +21,32 @@ if(NOT (openflow_dep AND openflow_header)) 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) +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(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(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(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}") +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 index ff2c2836e..17da8b408 100644 --- a/src/openflow/examples/CMakeLists.txt +++ b/src/openflow/examples/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index 47fda0b46..6785c5e32 100644 --- a/src/point-to-point-layout/CMakeLists.txt +++ b/src/point-to-point-layout/CMakeLists.txt @@ -1,9 +1,15 @@ 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(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(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}") +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 index e20997dd3..3bc85acdd 100644 --- a/src/point-to-point/CMakeLists.txt +++ b/src/point-to-point/CMakeLists.txt @@ -12,16 +12,22 @@ if(${ENABLE_MPI}) 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(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(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}") +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 index 80e18a891..73650b990 100644 --- a/src/point-to-point/examples/CMakeLists.txt +++ b/src/point-to-point/examples/CMakeLists.txt @@ -2,4 +2,6 @@ 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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/propagation/CMakeLists.txt b/src/propagation/CMakeLists.txt index 831197b3d..6fdb2059c 100644 --- a/src/propagation/CMakeLists.txt +++ b/src/propagation/CMakeLists.txt @@ -48,4 +48,6 @@ set(test_sources test/three-gpp-propagation-loss-model-test-suite.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 24ad92313..b01c3a25a 100644 --- a/src/propagation/examples/CMakeLists.txt +++ b/src/propagation/examples/CMakeLists.txt @@ -1,11 +1,17 @@ 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(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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/sixlowpan/CMakeLists.txt b/src/sixlowpan/CMakeLists.txt index 65bbb820d..8784fdde9 100644 --- a/src/sixlowpan/CMakeLists.txt +++ b/src/sixlowpan/CMakeLists.txt @@ -1,18 +1,26 @@ set(name sixlowpan) -set(source_files helper/sixlowpan-helper.cc model/sixlowpan-header.cc model/sixlowpan-net-device.cc) +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(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}) +if(${EXAMPLES_ENABLED}) 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 +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}") +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 index bd28d146a..47a8275c0 100644 --- a/src/sixlowpan/examples/CMakeLists.txt +++ b/src/sixlowpan/examples/CMakeLists.txt @@ -1,23 +1,39 @@ 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(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(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(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}") +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 index 7c0b4d185..072952b12 100644 --- a/src/spectrum/CMakeLists.txt +++ b/src/spectrum/CMakeLists.txt @@ -87,4 +87,6 @@ set(test_sources test/tv-spectrum-transmitter-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index f845ddfc2..b5de10236 100644 --- a/src/spectrum/examples/CMakeLists.txt +++ b/src/spectrum/examples/CMakeLists.txt @@ -1,35 +1,53 @@ 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(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(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(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}") +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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/stats/CMakeLists.txt b/src/stats/CMakeLists.txt index 201121d84..67ec15ae3 100644 --- a/src/stats/CMakeLists.txt +++ b/src/stats/CMakeLists.txt @@ -16,6 +16,7 @@ if(${NS3_SQLITE}) endif() endif() + mark_as_advanced(ENABLE_SQLITE) if("${SQLite3_FOUND}") set(ENABLE_SQLITE True CACHE INTERNAL "") else() @@ -78,8 +79,11 @@ set(header_files 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 +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}") +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 index 2b1441f95..613064e39 100644 --- a/src/stats/examples/CMakeLists.txt +++ b/src/stats/examples/CMakeLists.txt @@ -2,40 +2,54 @@ 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}") +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}") +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}") +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}") +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}") +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}") +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}") +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 index d077f9ba2..533d8e0a8 100644 --- a/src/tap-bridge/CMakeLists.txt +++ b/src/tap-bridge/CMakeLists.txt @@ -1,18 +1,25 @@ set(name tap-bridge) -set(source_files helper/tap-bridge-helper.cc model/tap-bridge.cc model/tap-encode-decode.cc) +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(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}") +build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" + "${test_sources}" +) +add_definitions( + -DTAP_CREATOR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/src/tap-bridge/ns${NS3_VER}-tap-creator${build_profile_suffix}" +) 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/) +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 index 24fd68c0b..35fc835c8 100644 --- a/src/tap-bridge/examples/CMakeLists.txt +++ b/src/tap-bridge/examples/CMakeLists.txt @@ -3,24 +3,36 @@ if(${NS3_TAP}) 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}") + 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}") + 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(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}") + 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 index 67e7c4253..d5356ad8b 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -2,23 +2,26 @@ 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) + 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) +if(csma-layout IN_LIST ns3-all-enabled-modules) set(csma-layout_sources csma-system-test-suite.cc) endif() set(dsr_sources) -if(dsr IN_LIST ns3-all-modules) +if(dsr IN_LIST ns3-all-enabled-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) +if(applications IN_LIST ns3-all-enabled-modules) + if(point-to-point IN_LIST ns3-all-enabled-modules) set(applications_sources ns3tcp/ns3tcp-cwnd-test-suite.cc ns3tcp/ns3tcp-interop-test-suite.cc @@ -29,23 +32,28 @@ if(applications IN_LIST ns3-all-modules) 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 + if(wifi IN_LIST ns3-all-enabled-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) +if(internet IN_LIST ns3-all-enabled-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 +if(traffic-control IN_LIST ns3-all-enabled-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() diff --git a/src/topology-read/CMakeLists.txt b/src/topology-read/CMakeLists.txt index a4712c0d0..8ccb699a4 100644 --- a/src/topology-read/CMakeLists.txt +++ b/src/topology-read/CMakeLists.txt @@ -1,15 +1,21 @@ 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(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(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}") +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 index cef996648..2d1e8e80e 100644 --- a/src/topology-read/examples/CMakeLists.txt +++ b/src/topology-read/examples/CMakeLists.txt @@ -2,8 +2,11 @@ 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} + 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}" ) - 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 index f9dbbb242..700204181 100644 --- a/src/traffic-control/CMakeLists.txt +++ b/src/traffic-control/CMakeLists.txt @@ -55,4 +55,6 @@ set(test_sources test/tc-flow-control-test-suite.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index d42ff7509..9cac848c5 100644 --- a/src/traffic-control/examples/CMakeLists.txt +++ b/src/traffic-control/examples/CMakeLists.txt @@ -1,53 +1,80 @@ 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(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} +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}" ) -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(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} +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}" ) -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(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(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(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} +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}" ) -build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") diff --git a/src/uan/CMakeLists.txt b/src/uan/CMakeLists.txt index e8e95aeb8..00280180c 100644 --- a/src/uan/CMakeLists.txt +++ b/src/uan/CMakeLists.txt @@ -56,4 +56,6 @@ 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}") +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 index 21b9e4d10..d3a5d37f6 100644 --- a/src/uan/examples/CMakeLists.txt +++ b/src/uan/examples/CMakeLists.txt @@ -1,29 +1,49 @@ 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(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(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(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(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}") +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 index df85a2363..428d5c410 100644 --- a/src/virtual-net-device/CMakeLists.txt +++ b/src/virtual-net-device/CMakeLists.txt @@ -8,4 +8,6 @@ set(libraries_to_link ${libnetwork}) set(test_sources) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${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 index f4579cb12..2420da27e 100644 --- a/src/virtual-net-device/examples/CMakeLists.txt +++ b/src/virtual-net-device/examples/CMakeLists.txt @@ -1,5 +1,9 @@ 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}") +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 index 09bdf8817..fb4d5f40a 100644 --- a/src/visualizer/CMakeLists.txt +++ b/src/visualizer/CMakeLists.txt @@ -21,7 +21,10 @@ set(libraries_to_link set(test_sources) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${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 +# 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/wave/CMakeLists.txt b/src/wave/CMakeLists.txt index d60c3e773..01421f37f 100644 --- a/src/wave/CMakeLists.txt +++ b/src/wave/CMakeLists.txt @@ -42,4 +42,6 @@ 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}") +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 index dfae74682..4e287365f 100644 --- a/src/wave/examples/CMakeLists.txt +++ b/src/wave/examples/CMakeLists.txt @@ -1,14 +1,22 @@ 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(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(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) @@ -27,4 +35,6 @@ set(libraries_to_link ${libwifi} ${libwave} ) -build_lib_example("${name}" "${source_files}" "${header_files}" "${libraries_to_link}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index a8fa23c98..00c9cfcad 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -276,7 +276,9 @@ set(header_files model/yans-wifi-phy.h ) -set(libraries_to_link ${libnetwork} ${libpropagation} ${libenergy} ${libspectrum} ${libantenna} ${libmobility}) +set(libraries_to_link ${libnetwork} ${libpropagation} ${libenergy} + ${libspectrum} ${libantenna} ${libmobility} +) set(test_sources test/block-ack-test-suite.cc @@ -298,4 +300,6 @@ set(test_sources test/wifi-txop-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 8b4474397..0ea2fc72d 100644 --- a/src/wifi/examples/CMakeLists.txt +++ b/src/wifi/examples/CMakeLists.txt @@ -2,34 +2,50 @@ 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}") +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}") +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(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(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}") +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}") +build_lib_example( + "${name}" "${source_files}" "${header_files}" "${libraries_to_link}" +) diff --git a/src/wimax/CMakeLists.txt b/src/wimax/CMakeLists.txt index f2ef29698..d83d64af4 100644 --- a/src/wimax/CMakeLists.txt +++ b/src/wimax/CMakeLists.txt @@ -98,7 +98,9 @@ set(header_files model/wimax-mac-to-mac-header.h ) -set(libraries_to_link ${libnetwork} ${libinternet} ${libpropagation} ${libmobility}) +set(libraries_to_link ${libnetwork} ${libinternet} ${libpropagation} + ${libmobility} +) set(test_sources test/mac-messages-test.cc @@ -110,4 +112,6 @@ set(test_sources test/wimax-tlv-test.cc ) -build_lib("${name}" "${source_files}" "${header_files}" "${libraries_to_link}" "${test_sources}") +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 index 8dfa9c1d8..ab5f58843 100644 --- a/src/wimax/examples/CMakeLists.txt +++ b/src/wimax/examples/CMakeLists.txt @@ -1,17 +1,27 @@ 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(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}") +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}") +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 index a028c4f90..ac905b10f 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,30 +1,37 @@ -if(${NS3_TESTS}) +if(${TESTS_ENABLED} AND (test IN_LIST libs_to_build)) 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} + 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} + 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/) - + set_runtime_outputdirectory( + test-runner ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/utils/ "" + ) + 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/ "" +) diff --git a/utils/create-module.py b/utils/create-module.py index 5d4efa400..f66511149 100755 --- a/utils/create-module.py +++ b/utils/create-module.py @@ -29,7 +29,7 @@ set(libraries_to_link ${{libcore}} ) -if(${{NS3_EXAMPLES}}) +if(${{EXAMPLES_ENABLED}}) set(examples_as_tests_sources #test/{MODULE}-examples-test-suite.cc ) diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py new file mode 100644 index 000000000..0ab504222 --- /dev/null +++ b/utils/tests/test-ns3.py @@ -0,0 +1,580 @@ +#! /usr/bin/env python3 +# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +# +# Copyright (c) 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 + +import itertools +import shutil +from functools import partial +import sys +import unittest +import os +import subprocess +import re +import glob + +# Get path containing ns3 +ns3_path = os.path.dirname(os.path.abspath(os.sep.join([__file__, "../../"]))) +ns3_script = os.sep.join([ns3_path, "ns3"]) +ns3rc_script = os.sep.join([ns3_path, ".ns3rc"]) +build_status_script = os.sep.join([ns3_path, "build", "build-status.py"]) +c4che_script = os.sep.join([ns3_path, "build", "c4che", "_cache.py"]) + +# Move the current working directory to the ns-3-dev/utils/tests folder +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +# Cmake commands +cmake_refresh_cache_command = "cd {ns3_path}/cmake_cache; /usr/bin/cmake ..".format(ns3_path=ns3_path) +cmake_build_project_command = "cd {ns3_path}/cmake_cache; cmake --build . -j".format(ns3_path=ns3_path) +cmake_build_target_command = partial("cd {ns3_path}/cmake_cache; cmake --build . -j {jobs} --target {target}".format, + ns3_path=ns3_path, + jobs=max(1, os.cpu_count() - 1) + ) + + +def run_ns3(args): + return run_program(ns3_script, args, True) + + +# Adapted from https://github.com/metabrainz/picard/blob/master/picard/util/__init__.py +def run_program(program, args, python=False): + if type(args) != str: + raise Exception("args should be a string") + + # Include python interpreter if running a python script + if python: + arguments = [sys.executable, program] + else: + arguments = [program] + + if args != "": + arguments.extend(re.findall("(?:\".*?\"|\S)+", args)) + + # Call program with arguments + ret = subprocess.run( + arguments, + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=None, + cwd=ns3_path # run process from the ns-3-dev path + ) + + # Return (error code, stdout and stderr) + return ret.returncode, ret.stdout.decode(sys.stdout.encoding), ret.stderr.decode(sys.stderr.encoding) + + +def get_programs_list(): + values = {} + with open(build_status_script) as f: + exec(f.read(), globals(), values) + return values["ns3_runnable_programs"] + + +def read_c4che_entry(entry): + values = {} + with open(c4che_script) as f: + exec(f.read(), globals(), values) + return values[entry] + + +def get_test_enabled(): + return read_c4che_entry("ENABLE_TESTS") + + +def get_enabled_modules(): + return read_c4che_entry("NS3_ENABLED_MODULES") + + +class NS3RunWafTargets(unittest.TestCase): + + cleaned_once = False + + def setUp(self): + if not NS3RunWafTargets.cleaned_once: + NS3RunWafTargets.cleaned_once = True + run_ns3("clean") + return_code, stdout, stderr = run_program("waf", "configure --enable-examples --enable-tests", python=True) + self.assertEqual(return_code, 0) + self.assertIn("finished successfully", stdout) + + return_code, stdout, stderr = run_program("waf", "build", python=True) + self.assertEqual(return_code, 0) + self.assertIn("finished successfully", stdout) + + def test_01_loadExecutables(self): + # Check if build-status.py exists, then read to get list of executables + self.assertTrue(os.path.exists(build_status_script)) + self.ns3_executables = get_programs_list() + self.assertGreater(len(self.ns3_executables), 0) + + def test_02_loadModules(self): + # Check if c4che.py exists than read to get the list of enabled modules + self.assertTrue(os.path.exists(c4che_script)) + self.ns3_modules = get_enabled_modules() + self.assertGreater(len(self.ns3_modules), 0) + + def test_03_runNobuildScratchSim(self): + return_code, stdout, stderr = run_ns3("--run-no-build scratch-simulator") + self.assertEqual(return_code, 0) + self.assertIn("Scratch Simulator", stderr) + + def test_04_runNobuildExample(self): + return_code, stdout, stderr = run_ns3("--run-no-build command-line-example") + self.assertEqual(return_code, 0) + self.assertIn("command-line-example", stdout) + + def test_05_runTestCaseCoreExampleSimulator(self): + return_code, stdout, stderr = run_program("test.py", "--nowaf -s core-example-simulator", True) + self.assertEqual(return_code, 0) + self.assertIn("PASS", stdout) + + def test_06_runTestCaseExamplesAsTestsTestSuite(self): + return_code, stdout, stderr = run_program("test.py", "--nowaf -s examples-as-tests-test-suite", True) + self.assertEqual(return_code, 0) + self.assertIn("PASS", stdout) + + +class NS3CommonSettingsTestCase(unittest.TestCase): + def setUp(self): + super().setUp() + # No special setup for common test cases other than making sure we are working on a clean directory + run_ns3("clean") + + def test_01_NoOption(self): + return_code, stdout, stderr = run_ns3("") + self.assertEqual(return_code, 0) + self.assertIn("You need to configure ns-3 first: try ./ns3 configure", stdout) + + def test_02_Verbose(self): + return_code, stdout, stderr = run_ns3("--verbose") + self.assertEqual(return_code, 0) + self.assertIn("You need to configure ns-3 first: try ./ns3 configure", stdout) + + def test_03_NoTaskLines(self): + return_code, stdout, stderr = run_ns3("--no-task-lines") + self.assertEqual(return_code, 0) + self.assertIn("You need to configure ns-3 first: try ./ns3 configure", stdout) + + def test_04_CheckConfig(self): + return_code, stdout, stderr = run_ns3("--check-config") + self.assertEqual(return_code, 1) + self.assertIn("Project was not configured", stderr) + + +class NS3ConfigureBuildProfileTestCase(unittest.TestCase): + def setUp(self): + super().setUp() + # No special setup for common test cases other than making sure we are working on a clean directory + run_ns3("clean") + + def test_01_Debug(self): + return_code, stdout, stderr = run_ns3("configure -d debug") + self.assertEqual(return_code, 0) + self.assertIn("Build profile : debug", stdout) + self.assertIn("Build files have been written to", stdout) + + # Build core to check if profile suffixes match the expected + return_code, stdout, stderr = run_ns3("build core") + self.assertEqual(return_code, 0) + self.assertIn("Built target libcore", stdout) + + libcore = glob.glob(os.sep.join([ns3_path, "build", "lib"]) + '/*', recursive=True) + self.assertGreater(len(libcore), 0) + self.assertIn("core-debug", libcore[0]) + + def test_02_Release(self): + return_code, stdout, stderr = run_ns3("configure -d release") + self.assertEqual(return_code, 0) + self.assertIn("Build profile : release", stdout) + self.assertIn("Build files have been written to", stdout) + + def test_03_Optimized(self): + return_code, stdout, stderr = run_ns3("configure -d optimized") + self.assertEqual(return_code, 0) + self.assertIn("Build profile : optimized", stdout) + self.assertIn("Build files have been written to", stdout) + + # Build core to check if profile suffixes match the expected + return_code, stdout, stderr = run_ns3("build core") + self.assertEqual(return_code, 0) + self.assertIn("Built target libcore", stdout) + + libcore = glob.glob(os.sep.join([ns3_path, "build", "lib"]) + '/*', recursive=True) + self.assertGreater(len(libcore), 0) + self.assertIn("core-optimized", libcore[0]) + + def test_04_Typo(self): + return_code, stdout, stderr = run_ns3("configure -d Optimized") + self.assertEqual(return_code, 2) + self.assertIn("invalid choice: 'Optimized'", stderr) + + def test_05_TYPO(self): + return_code, stdout, stderr = run_ns3("configure -d OPTIMIZED") + self.assertEqual(return_code, 2) + self.assertIn("invalid choice: 'OPTIMIZED'", stderr) + + +class NS3BaseTestCase(unittest.TestCase): + + cleaned_once = False + + def config_ok(self, return_code, stdout): + self.assertEqual(return_code, 0) + self.assertIn("Build profile : release", stdout) + self.assertIn("Build files have been written to", stdout) + + def setUp(self): + super().setUp() + + if os.path.exists(ns3rc_script): + os.remove(ns3rc_script) + + # We only clear it once and then update the settings by changing flags or consuming ns3rc + if not NS3BaseTestCase.cleaned_once: + NS3BaseTestCase.cleaned_once = True + run_ns3("clean") + return_code, stdout, stderr = run_ns3("configure -d release") + self.config_ok(return_code, stdout) + + # Check if build-status.py exists, then read to get list of executables + self.assertTrue(os.path.exists(build_status_script)) + self.ns3_executables = get_programs_list() + + # Check if c4che.py exists than read to get the list of enabled modules + self.assertTrue(os.path.exists(c4che_script)) + self.ns3_modules = get_enabled_modules() + + +class NS3ConfigureTestCase(NS3BaseTestCase): + + cleaned_once = False + + def setUp(self): + if not NS3ConfigureTestCase.cleaned_once: + NS3ConfigureTestCase.cleaned_once = True + NS3BaseTestCase.cleaned_once = False + super().setUp() + + def test_01_Examples(self): + return_code, stdout, stderr = run_ns3("configure --enable-examples") + + # This just tests if we didn't break anything, not that we actually have enabled anything + self.config_ok(return_code, stdout) + + # If nothing went wrong, we should have more executables in the list after enabling the examples + self.assertGreater(len(get_programs_list()), len(self.ns3_executables)) + + # Now we disabled them back + return_code, stdout, stderr = run_ns3("configure --disable-examples") + + # This just tests if we didn't break anything, not that we actually have enabled anything + self.config_ok(return_code, stdout) + + # And check if they went back to the original list + self.assertEqual(len(get_programs_list()), len(self.ns3_executables)) + + def test_02_Tests(self): + # Try enabling tests + return_code, stdout, stderr = run_ns3("configure --enable-tests") + self.config_ok(return_code, stdout) + + # Then try building the libcore test + return_code, stdout, stderr = run_ns3("build core-test") + + # If nothing went wrong, this should have worked + self.assertEqual(return_code, 0) + self.assertIn("Built target libcore-test", stdout) + + # Now we disabled the tests + return_code, stdout, stderr = run_ns3("configure --disable-tests") + self.config_ok(return_code, stdout) + + # Now building the library test should fail + return_code, stdout, stderr = run_ns3("build core-test") + + # And check if they went back to the original list + self.assertGreater(len(stderr), 0) + + def test_03_EnableModules(self): + # Try filtering enabled modules to network+wifi and their dependencies + return_code, stdout, stderr = run_ns3("configure --enable-modules='network;wifi'") + self.config_ok(return_code, stdout) + + # At this point we should have fewer modules + enabled_modules = get_enabled_modules() + self.assertLess(len(get_enabled_modules()), len(self.ns3_modules)) + self.assertIn("ns3-network", enabled_modules) + self.assertIn("ns3-wifi", enabled_modules) + + # Try cleaning the list of enabled modules to reset to the normal configuration + return_code, stdout, stderr = run_ns3("configure --enable-modules=''") + self.config_ok(return_code, stdout) + + # At this point we should have the same amount of modules that we had when we started + self.assertEqual(len(get_enabled_modules()), len(self.ns3_modules)) + + def test_04_DisableModules(self): + # Try filtering disabled modules to disable lte and modules that depend on it + return_code, stdout, stderr = run_ns3("configure --disable-modules='lte;mpi'") + self.config_ok(return_code, stdout) + + # At this point we should have fewer modules + enabled_modules = get_enabled_modules() + self.assertLess(len(enabled_modules), len(self.ns3_modules)) + self.assertNotIn("ns3-lte", enabled_modules) + self.assertNotIn("ns3-mpi", enabled_modules) + + # Try cleaning the list of enabled modules to reset to the normal configuration + return_code, stdout, stderr = run_ns3("configure --disable-modules=''") + self.config_ok(return_code, stdout) + + # At this point we should have the same amount of modules that we had when we started + self.assertEqual(len(get_enabled_modules()), len(self.ns3_modules)) + + def test_05_Ns3rc(self): + ns3rc_template = "# ! /usr/bin/env python\ + \ + # A list of the modules that will be enabled when ns-3 is run.\ + # Modules that depend on the listed modules will be enabled also.\ + #\ + # All modules can be enabled by choosing 'all_modules'.\ + modules_enabled = [{modules}]\ + \ + # Set this equal to true if you want examples to be run.\ + examples_enabled = {examples}\ + \ + # Set this equal to true if you want tests to be run.\ + tests_enabled = {tests}\ + " + + # Now we repeat the command line tests but with the ns3rc file + with open(ns3rc_script, "w") as f: + f.write(ns3rc_template.format(modules="'lte'", examples="False", tests="True")) + + # Reconfigure + return_code, stdout, stderr = run_ns3("configure") + self.config_ok(return_code, stdout) + + # Check + enabled_modules = get_enabled_modules() + self.assertLess(len(get_enabled_modules()), len(self.ns3_modules)) + self.assertIn("ns3-lte", enabled_modules) + self.assertTrue(get_test_enabled()) + self.assertEqual(len(get_programs_list()) + 1, len(self.ns3_executables)) # the +1 is due to test-runner + + # Replace the ns3rc file + with open(ns3rc_script, "w") as f: + f.write(ns3rc_template.format(modules="'wifi'", examples="True", tests="False")) + + # Reconfigure + return_code, stdout, stderr = run_ns3("configure") + self.config_ok(return_code, stdout) + + # Check + enabled_modules = get_enabled_modules() + self.assertLess(len(get_enabled_modules()), len(self.ns3_modules)) + self.assertIn("ns3-wifi", enabled_modules) + self.assertFalse(get_test_enabled()) + self.assertGreater(len(get_programs_list()), len(self.ns3_executables)) + + # Then we roll back by removing the ns3rc config file + os.remove(ns3rc_script) + + # Reconfigure + return_code, stdout, stderr = run_ns3("configure") + self.config_ok(return_code, stdout) + + # Check + self.assertEqual(len(get_enabled_modules()), len(self.ns3_modules)) + self.assertFalse(get_test_enabled()) + self.assertEqual(len(get_programs_list()), len(self.ns3_executables)) + + def test_06_DryRun(self): + # todo: collect commands from CMake and test them + pass + + +class NS3BuildBaseTestCase(NS3BaseTestCase): + cleaned_once = False + + def setUp(self): + if not NS3BuildBaseTestCase.cleaned_once: + NS3BuildBaseTestCase.cleaned_once = True + NS3BaseTestCase.cleaned_once = False + super().setUp() + + def test_01_BuildExistingTargets(self): + return_code, stdout, stderr = run_ns3("build core") + self.assertEqual(return_code, 0) + self.assertIn("Built target libcore", stdout) + + def test_02_BuildNonExistingTargets(self): + # tests are not enable, so the target isn't available + return_code, stdout, stderr = run_ns3("build core-test") + self.assertGreater(len(stderr), 0) + + def test_03_BuildProject(self): + return_code, stdout, stderr = run_ns3("build") + self.assertEqual(return_code, 0) + self.assertIn("Built target", stdout) + for program in get_programs_list(): + self.assertTrue(os.path.exists(program)) + + def test_04_BuildProjectVerbose(self): + return_code, stdout, stderr = run_ns3("--verbose build") + self.assertEqual(return_code, 0) + self.assertIn("Built target", stdout) + for program in get_programs_list(): + self.assertTrue(os.path.exists(program)) + self.assertIn(cmake_refresh_cache_command, stdout) + self.assertIn(cmake_build_project_command, stdout) + + def test_05_BuildProjectNoTaskLines(self): + return_code, stdout, stderr = run_ns3("--no-task-lines build") + self.assertEqual(return_code, 0) + self.assertEqual(len(stderr), 0) + self.assertEqual(len(stdout), 0) + + def test_06_BuildProjectVerboseAndNoTaskLines(self): + return_code, stdout, stderr = run_ns3("--no-task-lines --verbose build") + self.assertEqual(return_code, 0) + self.assertIn(cmake_refresh_cache_command, stdout) + self.assertIn(cmake_build_project_command, stdout) + + +class NS3ExpectedUseTestCase(NS3BaseTestCase): + cleaned_once = False + + def setUp(self): + if not NS3ExpectedUseTestCase.cleaned_once: + NS3ExpectedUseTestCase.cleaned_once = True + NS3BaseTestCase.cleaned_once = False + super().setUp() + + # On top of the release build configured by NS3ConfigureTestCase, also enable examples, tests and docs + return_code, stdout, stderr = run_ns3("configure --enable-examples --enable-tests --enable-documentation") + self.config_ok(return_code, stdout) + + # Check if build-status.py exists, then read to get list of executables + self.assertTrue(os.path.exists(build_status_script)) + self.ns3_executables = get_programs_list() + + # Check if c4che.py exists than read to get the list of enabled modules + self.assertTrue(os.path.exists(c4che_script)) + self.ns3_modules = get_enabled_modules() + + def test_01_BuildProjectVerbose(self): + return_code, stdout, stderr = run_ns3("--verbose build") + self.assertEqual(return_code, 0) + self.assertIn("Built target", stdout) + for program in get_programs_list(): + self.assertTrue(os.path.exists(program)) + libraries = ";".join(glob.glob(os.sep.join([ns3_path, "build", "lib"]) + '/*', recursive=True)) + for module in get_enabled_modules(): + self.assertIn(module.replace("ns3-", ""), libraries) + self.assertIn(cmake_refresh_cache_command, stdout) + self.assertIn(cmake_build_project_command, stdout) + + def test_02_BuildAndRunExistingExecutableTarget(self): + return_code, stdout, stderr = run_ns3('--verbose --run "test-runner --list"') + self.assertEqual(return_code, 0) + self.assertIn("Built target test-runner", stdout) + self.assertIn(cmake_refresh_cache_command, stdout) + self.assertIn(cmake_build_target_command(target="test-runner"), stdout) + + def test_03_BuildAndRunExistingLibraryTarget(self): + return_code, stdout, stderr = run_ns3("--run core") # this should not work + self.assertEqual(return_code, 1) + self.assertIn("Couldn't find the specified program: core", stderr) + + def test_04_BuildAndRunNonExistingTarget(self): + return_code, stdout, stderr = run_ns3("--run nonsense") # this should not work + self.assertEqual(return_code, 1) + self.assertIn("Couldn't find the specified program: nonsense", stderr) + + def test_05_RunNoBuildExistingExecutableTarget(self): + return_code, stdout, stderr = run_ns3('--verbose --run-no-build "test-runner --list"') + self.assertEqual(return_code, 0) + self.assertNotIn("Built target test-runner", stdout) + self.assertNotIn(cmake_refresh_cache_command, stdout) + self.assertNotIn(cmake_build_target_command(target="test-runner"), stdout) + self.assertIn("test-runner", stdout) + self.assertIn("--list", stdout) + + def test_06_RunNoBuildExistingLibraryTarget(self): + return_code, stdout, stderr = run_ns3("--verbose --run-no-build core") # this should not work + self.assertEqual(return_code, 1) + self.assertIn("Couldn't find the specified program: core", stderr) + + def test_07_RunNoBuildNonExistingExecutableTarget(self): + return_code, stdout, stderr = run_ns3("--verbose --run-no-build nonsense") # this should not work + self.assertEqual(return_code, 1) + self.assertIn("Couldn't find the specified program: nonsense", stderr) + + def test_08_RunNoBuildGdb(self): + return_code, stdout, stderr = run_ns3("--run-no-build scratch-simulator --gdb") + self.assertEqual(return_code, 0) + self.assertIn("scratch-simulator", stdout) + self.assertIn("No debugging symbols found", stdout) + + def test_09_RunNoBuildValgrind(self): + return_code, stdout, stderr = run_ns3("--run-no-build scratch-simulator --valgrind") + self.assertEqual(return_code, 0) + self.assertIn("scratch-simulator", stderr) + self.assertIn("Memcheck", stderr) + + def test_10_DoxygenWithBuild(self): + return_code, stdout, stderr = run_ns3("--verbose --doxygen") + self.assertEqual(return_code, 0) + self.assertIn(cmake_refresh_cache_command, stdout) + self.assertIn(cmake_build_target_command(target="doxygen"), stdout) + self.assertIn("Built target doxygen", stdout) + + def test_11_DoxygenWithoutBuild(self): + return_code, stdout, stderr = run_ns3("--verbose --doxygen-no-build") + self.assertEqual(return_code, 0) + self.assertIn(cmake_refresh_cache_command, stdout) + self.assertIn(cmake_build_target_command(target="doxygen-no-build"), stdout) + self.assertIn("Built target doxygen-no-build", stdout) + + +if __name__ == '__main__': + loader = unittest.TestLoader() + suite = unittest.TestSuite() + + # Put tests cases in order + suite.addTests(loader.loadTestsFromTestCase(NS3RunWafTargets)) + suite.addTests(loader.loadTestsFromTestCase(NS3CommonSettingsTestCase)) + suite.addTests(loader.loadTestsFromTestCase(NS3ConfigureBuildProfileTestCase)) + suite.addTests(loader.loadTestsFromTestCase(NS3ConfigureTestCase)) + suite.addTests(loader.loadTestsFromTestCase(NS3BuildBaseTestCase)) + suite.addTests(loader.loadTestsFromTestCase(NS3ExpectedUseTestCase)) + + # Before running, check if ns3rc exists and save it + ns3rc_script_bak = ns3rc_script + ".bak" + if os.path.exists(ns3rc_script) and not os.path.exists(ns3rc_script_bak): + shutil.move(ns3rc_script, ns3rc_script_bak) + + # Run tests and fail as fast as possible + runner = unittest.TextTestRunner(failfast=True) + result = runner.run(suite) + + # After completing the tests successfully, restore the ns3rc file + if os.path.exists(ns3rc_script_bak): + shutil.move(ns3rc_script_bak, ns3rc_script)