build: Fix features and make pthread an explicit dependency
Includes: - Include threads sources even when NS3_PTHREAD=OFF - Do not include realtime sources if NS3_REALTIME=OFF - Disable tap-bridge if emulation or realtime features are disabled - Build tap examples when tap-netdevice is enabled - Remove NS3_PTHREAD option and make it an explicit requirement
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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_FOUND TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR Pthreads are required by ns-3)
|
||||
endif()
|
||||
|
||||
set(Python3_LIBRARIES)
|
||||
|
||||
@@ -63,15 +63,17 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
set(rt_sources
|
||||
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
|
||||
)
|
||||
set(rt_headers
|
||||
model/realtime-simulator-impl.h
|
||||
model/wall-clock-synchronizer.h
|
||||
)
|
||||
if(${ENABLE_REALTIME})
|
||||
)
|
||||
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}
|
||||
set(thread_sources
|
||||
model/system-thread.cc
|
||||
model/unix-system-mutex.cc
|
||||
model/unix-fd-reader.cc
|
||||
model/unix-system-condition.cc
|
||||
)
|
||||
|
||||
set(thread_headers
|
||||
${thread_headers}
|
||||
model/unix-system-mutex.cc
|
||||
)
|
||||
set(thread_headers
|
||||
model/system-condition.h
|
||||
model/system-mutex.h
|
||||
model/system-thread.h
|
||||
model/system-condition.h
|
||||
)
|
||||
set(libraries_to_link
|
||||
model/unix-fd-reader.h
|
||||
)
|
||||
set(libraries_to_link
|
||||
${libraries_to_link}
|
||||
pthread
|
||||
)
|
||||
set(thread_test_sources
|
||||
)
|
||||
set(thread_test_sources
|
||||
test/threaded-test-suite.cc
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
)
|
||||
|
||||
if(${ENABLE_EXAMPLES})
|
||||
set(example_as_test_sources
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user