Merge tag 'ns-3.40' into unison

ns-3.40 release
This commit is contained in:
F5
2023-11-20 21:18:22 +08:00
1037 changed files with 20838 additions and 11813 deletions

View File

@@ -29,7 +29,7 @@ function(build_required_and_libs_lists module_name visibility libraries
)
set(lib_real_name "-l${lib_real_name}")
else()
if(IS_ABSOLUTE ${lib})
if((IS_ABSOLUTE "${lib}") OR ("${lib}" MATCHES "^-l"))
set(lib_real_name ${lib})
else()
set(lib_real_name "-l${lib}")
@@ -88,6 +88,9 @@ function(pkgconfig_module libname)
string(REPLACE ";-I" " -I" pkgconfig_interface_include_directories
"${pkgconfig_interface_include_directories}"
)
string(REPLACE ";" "" pkgconfig_interface_include_directories
"${pkgconfig_interface_include_directories}"
)
endif()
# Configure pkgconfig file for the module using pkgconfig variables

View File

@@ -54,12 +54,20 @@
# Now the CMake part
set(ON ON)
macro(check_on_or_off user_config_switch confirmation_flag)
if(${user_config_switch})
if(${confirmation_flag})
# Argument parsing
if(${${user_config_switch}})
if(${${confirmation_flag}})
string(APPEND out "${Green}ON${ColourReset}\n")
else()
string(APPEND out "${Red}OFF (missing dependency)${ColourReset}\n")
if(${confirmation_flag}_REASON)
string(APPEND out
"${Red}OFF (${${confirmation_flag}_REASON})${ColourReset}\n"
)
else()
string(APPEND out "${Red}OFF (missing dependency)${ColourReset}\n")
endif()
endif()
else()
string(APPEND out "OFF (not requested)\n")
@@ -120,76 +128,76 @@ macro(write_configtable)
)
string(APPEND out "Build with runtime asserts : ")
check_on_or_off("${NS3_ASSERT}" "${NS3_ASSERT}")
check_on_or_off("NS3_ASSERT" "NS3_ASSERT")
string(APPEND out "Build with runtime logging : ")
check_on_or_off("${NS3_LOG}" "${NS3_LOG}")
check_on_or_off("NS3_LOG" "NS3_LOG")
string(APPEND out "Build version embedding : ")
check_on_or_off("${NS3_ENABLE_BUILD_VERSION}" "${ENABLE_BUILD_VERSION}")
check_on_or_off("NS3_ENABLE_BUILD_VERSION" "ENABLE_BUILD_VERSION")
string(APPEND out "BRITE Integration : ")
check_on_or_off("ON" "${NS3_BRITE}")
check_on_or_off("ON" "NS3_BRITE")
string(APPEND out "DES Metrics event collection : ")
check_on_or_off("${NS3_DES_METRICS}" "${NS3_DES_METRICS}")
check_on_or_off("NS3_DES_METRICS" "NS3_DES_METRICS")
string(APPEND out "DPDK NetDevice : ")
check_on_or_off("${NS3_DPDK}" "${ENABLE_DPDKDEVNET}")
check_on_or_off("NS3_DPDK" "ENABLE_DPDKDEVNET")
string(APPEND out "Emulation FdNetDevice : ")
check_on_or_off("${ENABLE_EMU}" "${ENABLE_EMUNETDEV}")
check_on_or_off("ENABLE_EMU" "ENABLE_EMUNETDEV")
string(APPEND out "Examples : ")
check_on_or_off("${ENABLE_EXAMPLES}" "${ENABLE_EXAMPLES}")
check_on_or_off("ENABLE_EXAMPLES" "ENABLE_EXAMPLES")
string(APPEND out "File descriptor NetDevice : ")
check_on_or_off("ON" "${ENABLE_FDNETDEV}")
check_on_or_off("ON" "ENABLE_FDNETDEV")
string(APPEND out "GNU Scientific Library (GSL) : ")
check_on_or_off("${NS3_GSL}" "${GSL_FOUND}")
check_on_or_off("NS3_GSL" "GSL_FOUND")
string(APPEND out "GtkConfigStore : ")
check_on_or_off("${NS3_GTK3}" "${GTK3_FOUND}")
check_on_or_off("NS3_GTK3" "GTK3_FOUND")
string(APPEND out "LibXml2 support : ")
check_on_or_off("ON" "${LIBXML2_FOUND}")
check_on_or_off("ON" "LIBXML2_FOUND")
string(APPEND out "MPI Support : ")
check_on_or_off("${NS3_MPI}" "${MPI_FOUND}")
check_on_or_off("NS3_MPI" "MPI_FOUND")
string(APPEND out "Multithreaded Simulation : ")
check_on_or_off("${NS3_MTP}" "ON")
string(APPEND out "ns-3 Click Integration : ")
check_on_or_off("ON" "${NS3_CLICK}")
check_on_or_off("ON" "NS3_CLICK")
string(APPEND out "ns-3 OpenFlow Integration : ")
check_on_or_off("ON" "${NS3_OPENFLOW}")
check_on_or_off("ON" "NS3_OPENFLOW")
string(APPEND out "Netmap emulation FdNetDevice : ")
check_on_or_off("${ENABLE_EMU}" "${ENABLE_NETMAP_EMU}")
check_on_or_off("ENABLE_EMU" "ENABLE_NETMAP_EMU")
string(APPEND out "PyViz visualizer : ")
check_on_or_off("${NS3_VISUALIZER}" "${ENABLE_VISUALIZER}")
check_on_or_off("NS3_VISUALIZER" "ENABLE_VISUALIZER")
string(APPEND out "Python Bindings : ")
check_on_or_off("${NS3_PYTHON_BINDINGS}" "${ENABLE_PYTHON_BINDINGS}")
check_on_or_off("NS3_PYTHON_BINDINGS" "ENABLE_PYTHON_BINDINGS")
string(APPEND out "SQLite support : ")
check_on_or_off("${NS3_SQLITE}" "${ENABLE_SQLITE}")
check_on_or_off("NS3_SQLITE" "ENABLE_SQLITE")
string(APPEND out "Eigen3 support : ")
check_on_or_off("${NS3_EIGEN}" "${ENABLE_EIGEN}")
check_on_or_off("NS3_EIGEN" "ENABLE_EIGEN")
string(APPEND out "Tap Bridge : ")
check_on_or_off("${ENABLE_TAP}" "${ENABLE_TAP}")
check_on_or_off("ENABLE_TAP" "ENABLE_TAP")
string(APPEND out "Tap FdNetDevice : ")
check_on_or_off("${ENABLE_TAP}" "${ENABLE_TAPNETDEV}")
check_on_or_off("ENABLE_TAP" "ENABLE_TAPNETDEV")
string(APPEND out "Tests : ")
check_on_or_off("${ENABLE_TESTS}" "${ENABLE_TESTS}")
check_on_or_off("ENABLE_TESTS" "ENABLE_TESTS")
# string(APPEND out "Use sudo to set suid bit : not enabled (option
# --enable-sudo not selected) string(APPEND out "XmlIo : enabled

View File

@@ -191,9 +191,29 @@ function(build_lib)
# include directories, allowing consumers of this module to include and link
# the 3rd-party code with no additional setup
get_target_includes(${lib${BLIB_LIBNAME}} exported_include_directories)
string(REPLACE "-I" "" exported_include_directories
"${exported_include_directories}"
)
# include directories prefixed in the source or binary directory need to be
# treated differently
set(new_exported_include_directories)
foreach(directory ${exported_include_directories})
string(FIND "${directory}" "${PROJECT_SOURCE_DIR}" is_prefixed_in_subdir)
if(${is_prefixed_in_subdir} GREATER_EQUAL 0)
string(SUBSTRING "${directory}" ${is_prefixed_in_subdir} -1
directory_path
)
list(APPEND new_exported_include_directories
$<BUILD_INTERFACE:${directory_path}>
)
else()
list(APPEND new_exported_include_directories ${directory})
endif()
endforeach()
set(exported_include_directories ${new_exported_include_directories})
string(REPLACE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/include" ""
exported_include_directories
"${exported_include_directories}"
@@ -235,6 +255,23 @@ function(build_lib)
INTERFACE ${exported_include_directories}
)
# Export definitions as interface definitions, propagating local definitions
# to other modules and scratches
get_target_property(
target_definitions ${lib${BLIB_LIBNAME}} COMPILE_DEFINITIONS
)
if(${target_definitions} STREQUAL "target_definitions-NOTFOUND")
set(target_definitions)
endif()
get_directory_property(dir_definitions COMPILE_DEFINITIONS)
set(exported_definitions "${target_definitions};${dir_definitions}")
list(REMOVE_DUPLICATES exported_definitions)
list(REMOVE_ITEM exported_definitions "")
set_target_properties(
${lib${BLIB_LIBNAME}} PROPERTIES INTERFACE_COMPILE_DEFINITIONS
"${exported_definitions}"
)
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"

View File

@@ -0,0 +1,198 @@
# Copyright (c) 2017-2023 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 <gabrielcarvfer@gmail.com>
# Set default installation directory
set(VCPKG_DIR "${PROJECT_SOURCE_DIR}/vcpkg")
# Check if there is an existing vcpkg installation in the user directory
if(WIN32)
set(user_dir $ENV{USERPROFILE})
else()
set(user_dir $ENV{HOME})
endif()
# Override the default vcpkg installation directory in case it does
if(EXISTS "${user_dir}/vcpkg")
set(VCPKG_DIR "${user_dir}/vcpkg")
endif()
find_package(Git)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(VCPKG_TARGET_ARCH x64)
else()
set(VCPKG_TARGET_ARCH x86)
endif()
if(WIN32)
set(VCPKG_EXEC vcpkg.exe)
set(VCPKG_TRIPLET ${VCPKG_TARGET_ARCH}-windows)
else()
set(VCPKG_EXEC vcpkg)
if(NOT APPLE) # LINUX
set(VCPKG_TRIPLET ${VCPKG_TARGET_ARCH}-linux)
else()
set(VCPKG_TRIPLET ${VCPKG_TARGET_ARCH}-osx)
endif()
endif()
# https://learn.microsoft.com/en-us/vcpkg/users/buildsystems/cmake-integration
set(VCPKG_TARGET_TRIPLET ${VCPKG_TRIPLET})
set(VCPKG_MANIFEST ${PROJECT_SOURCE_DIR}/vcpkg.json)
function(setup_vcpkg)
message(STATUS "vcpkg: setting up support in ${VCPKG_DIR}")
# Check if vcpkg was downloaded previously
if(EXISTS "${VCPKG_DIR}")
# Vcpkg already downloaded
message(STATUS "vcpkg: folder already exists, skipping git download")
else()
if(NOT ${Git_FOUND})
message(FATAL_ERROR "vcpkg: Git is required, but it was not found")
endif()
get_filename_component(VCPKG_PARENT_DIR ${VCPKG_DIR} DIRECTORY)
execute_process(
COMMAND ${GIT_EXECUTABLE} clone --depth 1
https://github.com/microsoft/vcpkg.git
WORKING_DIRECTORY "${VCPKG_PARENT_DIR}/"
)
endif()
if(${MSVC})
message(FATAL_ERROR "vcpkg: Visual Studio is unsupported")
else()
# Check if required packages are installed (unzip curl tar)
if(WIN32)
find_program(ZIP_PRESENT zip.exe)
find_program(UNZIP_PRESENT unzip.exe)
find_program(CURL_PRESENT curl.exe)
find_program(TAR_PRESENT tar.exe)
else()
find_program(ZIP_PRESENT zip)
find_program(UNZIP_PRESENT unzip)
find_program(CURL_PRESENT curl)
find_program(TAR_PRESENT tar)
endif()
if(${ZIP_PRESENT} STREQUAL ZIP_PRESENT-NOTFOUND)
message(FATAL_ERROR "vcpkg: Zip is required, but is not installed")
endif()
if(${UNZIP_PRESENT} STREQUAL UNZIP_PRESENT-NOTFOUND)
message(FATAL_ERROR "vcpkg: Unzip is required, but is not installed")
endif()
if(${CURL_PRESENT} STREQUAL CURL_PRESENT-NOTFOUND)
message(FATAL_ERROR "vcpkg: Curl is required, but is not installed")
endif()
if(${TAR_PRESENT} STREQUAL TAR_PRESENT-NOTFOUND)
message(FATAL_ERROR "vcpkg: Tar is required, but is not installed")
endif()
endif()
# message(WARNING "Checking VCPKG bootstrapping") Check if vcpkg was
# bootstrapped previously
if(EXISTS "${VCPKG_DIR}/${VCPKG_EXEC}")
message(STATUS "vcpkg: already bootstrapped")
else()
# message(WARNING "vcpkg: bootstrapping")
set(COMPILER_ENFORCING)
if(WIN32)
set(command bootstrap-vcpkg.bat -disableMetrics)
else()
# if(NOT APPLE) #linux/bsd
set(command bootstrap-vcpkg.sh -disableMetrics)
# else() set(command bootstrap-vcpkg.sh)# --allowAppleClang) endif()
endif()
execute_process(
COMMAND ${COMPILER_ENFORCING} ${VCPKG_DIR}/${command}
WORKING_DIRECTORY ${VCPKG_DIR}
)
# message(STATUS "vcpkg: bootstrapped") include_directories(${VCPKG_DIR})
set(ENV{VCPKG_ROOT} ${VCPKG_DIR})
endif()
if(NOT WIN32)
execute_process(COMMAND chmod +x ${VCPKG_DIR}/${VCPKG_EXEC})
endif()
set(CMAKE_PREFIX_PATH
"${VCPKG_DIR}/installed/${VCPKG_TRIPLET}/;${CMAKE_PREFIX_PATH}"
PARENT_SCOPE
)
# Install packages in manifest mode
if(EXISTS ${VCPKG_MANIFEST})
message(STATUS "vcpkg: detected a vcpkg manifest file: ${VCPKG_MANIFEST}")
execute_process(
COMMAND ${VCPKG_DIR}/${VCPKG_EXEC} install --triplet ${VCPKG_TRIPLET}
--x-install-root=${VCPKG_DIR}/installed RESULT_VARIABLE res
)
if(${res} EQUAL 0)
message(STATUS "vcpkg: packages defined in the manifest were installed")
else()
message(
FATAL_ERROR
"vcpkg: packages defined in the manifest failed to be installed"
)
endif()
endif()
endfunction()
function(add_package package_name)
# Early exit in case vcpkg support is not enabled
if(NOT ${NS3_VCPKG})
message(${HIGHLIGHTED_STATUS}
"vcpkg: support is disabled. Not installing: ${package_name}"
)
return()
endif()
# Early exit in case a vcpkg.json manifest file is present
if(EXISTS ${VCPKG_MANIFEST})
file(READ ${VCPKG_MANIFEST} contents)
if(${contents} MATCHES ${package_name})
message(STATUS "vcpkg: ${package_name} was installed")
return()
else()
message(
FATAL_ERROR
"vcpkg: manifest mode in use, but ${package_name} is not listed in ${VCPKG_MANIFEST}"
)
endif()
endif()
# Normal exit
message(STATUS "vcpkg: ${package_name} will be installed")
execute_process(
COMMAND ${VCPKG_DIR}/${VCPKG_EXEC} install ${package_name} --triplet
${VCPKG_TRIPLET} RESULT_VARIABLE res
)
if(${res} EQUAL 0)
message(STATUS "vcpkg: ${package_name} was installed")
else()
message(FATAL_ERROR "vcpkg: ${package_name} failed to be installed")
endif()
endfunction()
if(${NS3_VCPKG})
setup_vcpkg()
endif()

View File

@@ -150,6 +150,7 @@ set(CMAKE_HEADER_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/include/ns3)
set(THIRD_PARTY_DIRECTORY ${PROJECT_SOURCE_DIR}/3rd-party)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
link_directories(${CMAKE_OUTPUT_DIRECTORY}/lib)
file(MAKE_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY})
# Get installation folder default values for each platform and include package
# configuration macro
@@ -664,23 +665,6 @@ macro(process_options)
endif()
endif()
set(ENABLE_SQLITE False)
if(${NS3_SQLITE})
# find_package(SQLite3 QUIET) # unsupported in CMake 3.10 We emulate the
# behavior of find_package below
find_external_library(
DEPENDENCY_NAME SQLite3 HEADER_NAME sqlite3.h LIBRARY_NAME sqlite3
)
if(${SQLite3_FOUND})
set(ENABLE_SQLITE True)
add_definitions(-DHAVE_SQLITE3)
include_directories(${SQLite3_INCLUDE_DIRS})
else()
message(${HIGHLIGHTED_STATUS} "SQLite was not found")
endif()
endif()
if(${NS3_NATIVE_OPTIMIZATIONS} AND ${GCC})
add_compile_options(-march=native -mtune=native)
endif()
@@ -751,6 +735,68 @@ macro(process_options)
)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/build-support/3rd-party")
# Include our package managers
# cmake-format: off
# Starting with a custom cmake file that provides a Hunter-like interface to vcpkg
# Use add_package(package) to install a package
# Then find_package(package) to use it
# cmake-format: on
include(ns3-vcpkg-hunter)
# Then the beautiful CPM manager (too bad it doesn't work with everything)
# https://github.com/cpm-cmake/CPM.cmake
if(${NS3_CPM})
set(CPM_DOWNLOAD_VERSION 0.38.2)
set(CPM_DOWNLOAD_LOCATION
"${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake"
)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()
include(${CPM_DOWNLOAD_LOCATION})
set(CPM_USE_LOCAL_PACKAGES ON)
endif()
# Package manager test block
if(TEST_PACKAGE_MANAGER)
if(${TEST_PACKAGE_MANAGER} STREQUAL "CPM")
cpmaddpackage(
NAME ARMADILLO GIT_TAG 6cada351248c9a967b137b9fcb3d160dad7c709b
GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git
)
find_package(ARMADILLO REQUIRED)
message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}")
elseif(${TEST_PACKAGE_MANAGER} STREQUAL "VCPKG")
add_package(Armadillo)
find_package(Armadillo REQUIRED)
message(STATUS "Armadillo was found? ${ARMADILLO_FOUND}")
else()
find_package(Armadillo REQUIRED)
endif()
endif()
# End of package managers
set(ENABLE_SQLITE False)
if(${NS3_SQLITE})
# find_package(SQLite3 QUIET) # unsupported in CMake 3.10 We emulate the
# behavior of find_package below
find_external_library(
DEPENDENCY_NAME SQLite3 HEADER_NAME sqlite3.h LIBRARY_NAME sqlite3
)
if(${SQLite3_FOUND})
set(ENABLE_SQLITE True)
add_definitions(-DHAVE_SQLITE3)
include_directories(${SQLite3_INCLUDE_DIRS})
else()
message(${HIGHLIGHTED_STATUS} "SQLite was not found")
endif()
endif()
set(ENABLE_EIGEN False)
if(${NS3_EIGEN})
find_package(Eigen3 QUIET)
@@ -889,6 +935,7 @@ macro(process_options)
message(${HIGHLIGHTED_STATUS}
"Python: development libraries were not found"
)
set(ENABLE_PYTHON_BINDINGS_REASON "missing Python development libraries")
endif()
else()
if(${NS3_PYTHON_BINDINGS})
@@ -896,6 +943,7 @@ macro(process_options)
${HIGHLIGHTED_STATUS}
"Python: an incompatible version of Python was found, python bindings will be disabled"
)
set(ENABLE_PYTHON_BINDINGS_REASON "incompatible Python version")
endif()
endif()
@@ -906,6 +954,15 @@ macro(process_options)
${HIGHLIGHTED_STATUS}
"Bindings: python bindings require Python, but it could not be found"
)
set(ENABLE_PYTHON_BINDINGS_REASON "missing dependency: python")
elseif(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
# Warn users that Cppyy on ARM Macs isn't supported yet
message(${HIGHLIGHTED_STATUS}
"Bindings: macOS silicon detected -- see issue 930"
)
set(ENABLE_PYTHON_BINDINGS_REASON
"macOS silicon detected -- see issue 930"
)
else()
check_python_packages("cppyy" missing_packages)
if(missing_packages)
@@ -913,6 +970,9 @@ macro(process_options)
${HIGHLIGHTED_STATUS}
"Bindings: python bindings disabled due to the following missing dependencies: ${missing_packages}"
)
set(ENABLE_PYTHON_BINDINGS_REASON
"missing dependency: ${missing_packages}"
)
else()
set(ENABLE_PYTHON_BINDINGS ON)
endif()
@@ -999,10 +1059,21 @@ macro(process_options)
set(ENABLE_VISUALIZER FALSE)
if(${NS3_VISUALIZER})
if((NOT ${ENABLE_PYTHON_BINDINGS}) OR (NOT ${Python3_FOUND}))
message(${HIGHLIGHTED_STATUS} "Visualizer requires Python bindings")
# If bindings are enabled, check if visualizer dependencies are met
if(${NS3_PYTHON_BINDINGS})
if(NOT ${Python3_FOUND})
set(ENABLE_VISUALIZER_REASON "missing Python")
elseif(NOT ${ENABLE_PYTHON_BINDINGS})
set(ENABLE_VISUALIZER_REASON "missing Python Bindings")
else()
set(ENABLE_VISUALIZER TRUE)
endif()
# If bindings are disabled, just say python bindings are disabled
else()
set(ENABLE_VISUALIZER TRUE)
set(ENABLE_VISUALIZER_REASON "Python Bindings are disabled")
endif()
if(ENABLE_VISUALIZER_REASON)
message(${HIGHLIGHTED_STATUS} "Visualizer: ${ENABLE_VISUALIZER_REASON}")
endif()
endif()

View File

@@ -0,0 +1,42 @@
if(NOT
TEST_PACKAGE_MANAGER
)
message(
STATUS "Skipping test module because TEST_PACKAGE_MANAGER is not set."
)
return()
endif()
set(armadillo)
if(${TEST_PACKAGE_MANAGER}
STREQUAL
"CPM"
)
set(armadillo
armadillo
)
include_directories(${CMAKE_BINARY_DIR}/_deps/armadillo-src/include)
elseif(
${TEST_PACKAGE_MANAGER}
STREQUAL
"VCPKG"
)
set(armadillo
${ARMADILLO_LIBRARIES}
)
include_directories(${ARMADILLO_INCLUDE_DIRS})
else()
message(FATAL_ERROR "zoincs")
message(
STATUS
"Skipping test module because TEST_PACKAGE_MANAGER is set to an unsupported value."
)
return()
endif()
build_lib(
LIBNAME test-package-managers
SOURCE_FILES src.cc
LIBRARIES_TO_LINK ${libcore}
${armadillo}
)

View File

@@ -0,0 +1,10 @@
#include <armadillo>
int
main(int argc, char** argv)
{
arma::arma_rng::set_seed_random();
arma::Mat<double> mat = arma::randu(4, 4);
std::cout << "mat:\n" << mat << "\n";
return 0;
}