diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cd5b8e75..2407c7517 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,6 @@ 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) diff --git a/build-support/custom-modules/ns3-configtable.cmake b/build-support/custom-modules/ns3-configtable.cmake index df276b970..40839ed2f 100644 --- a/build-support/custom-modules/ns3-configtable.cmake +++ b/build-support/custom-modules/ns3-configtable.cmake @@ -178,9 +178,6 @@ macro(write_configtable) string(APPEND out "Tests : ") check_on_or_off("${ENABLE_TESTS}" "${ENABLE_TESTS}") - 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 "\n\n") diff --git a/build-support/custom-modules/ns3-lock.cmake b/build-support/custom-modules/ns3-lock.cmake index 95a1f1c10..4da50f535 100644 --- a/build-support/custom-modules/ns3-lock.cmake +++ b/build-support/custom-modules/ns3-lock.cmake @@ -62,7 +62,6 @@ function(write_lock) ) cache_cmake_flag(ENABLE_REALTIME "ENABLE_REAL_TIME" lock_contents) - cache_cmake_flag(NS3_PTHREAD "ENABLE_THREADING" lock_contents) cache_cmake_flag(ENABLE_EXAMPLES "ENABLE_EXAMPLES" lock_contents) cache_cmake_flag(ENABLE_TESTS "ENABLE_TESTS" lock_contents) cache_cmake_flag(NS3_OPENFLOW "ENABLE_OPENFLOW" lock_contents) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 303c8bc89..a8104ac7a 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -683,6 +683,7 @@ macro(process_options) # LibRT mark_as_advanced(LIBRT) + set(ENABLE_REALTIME FALSE) if(${NS3_REALTIME}) if(APPLE) message( @@ -692,7 +693,6 @@ macro(process_options) find_library(LIBRT rt QUIET) if(NOT ${LIBRT_FOUND}) message(FATAL_ERROR "LibRT was not found.") - set(ENABLE_REALTIME FALSE) else() message(STATUS "LibRT was found.") set(ENABLE_REALTIME TRUE) @@ -702,17 +702,15 @@ macro(process_options) endif() endif() - set(THREADS_ENABLED FALSE) - set(PTHREADS_FOUND FALSE) - if(${NS3_PTHREAD}) - set(THREADS_PREFER_PTHREAD_FLAG) - find_package(Threads QUIET) - if(${CMAKE_USE_PTHREADS_INIT}) - include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) - set(PTHREADS_FOUND TRUE) - set(HAVE_PTHREAD_H TRUE) # for core-config.h - set(THREADS_ENABLED TRUE) - endif() + set(THREADS_PREFER_PTHREAD_FLAG) + find_package(Threads QUIET) + if(${CMAKE_USE_PTHREADS_INIT}) + include_directories(${THREADS_PTHREADS_INCLUDE_DIR}) + set(HAVE_PTHREAD_H TRUE) # for core-config.h + set(THREADS_ENABLED TRUE) + set(THREADS_FOUND TRUE) + else() + message(FATAL_ERROR Pthreads are required by ns-3) endif() set(Python3_LIBRARIES) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f74892f25..966dff903 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -63,15 +63,17 @@ else() ) endif() -set(rt_sources - model/realtime-simulator-impl.cc - model/wall-clock-synchronizer.cc -) -set(rt_headers - model/realtime-simulator-impl.h - model/wall-clock-synchronizer.h -) +set(rt_sources) +set(rt_headers) if(${ENABLE_REALTIME}) + 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 + ) set(libraries_to_link ${libraries_to_link} ${LIBRT} @@ -118,40 +120,25 @@ elseif( ) endif() -set(thread_sources) -set(thread_headers) -set(thread_test_sources) - -if(${NS3_PTHREAD}) - if(${THREADS_FOUND}) - set(thread_sources - model/unix-fd-reader.cc - ) - set(thread_headers - model/unix-fd-reader.h - ) - set(thread_sources - ${thread_sources} - model/system-thread.cc - model/unix-system-mutex.cc - model/unix-system-condition.cc - ) - - set(thread_headers - ${thread_headers} - model/system-mutex.h - model/system-thread.h - model/system-condition.h - ) - set(libraries_to_link - ${libraries_to_link} - pthread - ) - set(thread_test_sources - test/threaded-test-suite.cc - ) - endif() -endif() +set(thread_sources + model/system-thread.cc + model/unix-fd-reader.cc + model/unix-system-condition.cc + model/unix-system-mutex.cc +) +set(thread_headers + model/system-condition.h + model/system-mutex.h + model/system-thread.h + model/unix-fd-reader.h +) +set(libraries_to_link + ${libraries_to_link} + pthread +) +set(thread_test_sources + test/threaded-test-suite.cc +) if(${ENABLE_EXAMPLES}) set(example_as_test_sources diff --git a/src/fd-net-device/CMakeLists.txt b/src/fd-net-device/CMakeLists.txt index dcb83e473..7afec7d4d 100644 --- a/src/fd-net-device/CMakeLists.txt +++ b/src/fd-net-device/CMakeLists.txt @@ -77,9 +77,7 @@ set(ENABLE_NETMAP_EMU "" ) -if(${THREADS_ENABLED} - AND HAVE_NET_ETHERNET_H -) +if(HAVE_NET_ETHERNET_H) set(ENABLE_FDNETDEV True CACHE INTERNAL @@ -107,6 +105,8 @@ if(${THREADS_ENABLED} AND HAVE_IF_TUN_H AND HAVE_SYS_IOCTL_H AND ${ENABLE_TAP} + AND ${ENABLE_REALTIME} + AND ${ENABLE_EMU} ) set(ENABLE_TAPNETDEV True diff --git a/src/fd-net-device/examples/CMakeLists.txt b/src/fd-net-device/examples/CMakeLists.txt index e6338b977..3d8265487 100644 --- a/src/fd-net-device/examples/CMakeLists.txt +++ b/src/fd-net-device/examples/CMakeLists.txt @@ -90,7 +90,7 @@ if(${ENABLE_EMU}) ) endif() -if(${ENABLE_TAP}) +if(${ENABLE_TAPNETDEV}) build_lib_example( NAME fd-tap-ping SOURCE_FILES fd-tap-ping.cc diff --git a/src/tap-bridge/CMakeLists.txt b/src/tap-bridge/CMakeLists.txt index 5a22d46d3..f7e1f9ce7 100644 --- a/src/tap-bridge/CMakeLists.txt +++ b/src/tap-bridge/CMakeLists.txt @@ -1,3 +1,25 @@ +if((NOT + ${ENABLE_REALTIME}) + OR (NOT + ${ENABLE_EMU}) +) + message( + ${HIGHLIGHTED_STATUS} + "tap-bridge requires emulation and realtime features" + ) + message( + ${HIGHLIGHTED_STATUS} + "Skipping src/tap-bridge" + ) + list( + REMOVE_ITEM + libs_to_build + tap-bridge + PARENT_SCOPE + ) + return() +endif() + build_lib( LIBNAME tap-bridge SOURCE_FILES