Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / tools / cmake / Modules / FindNS3.cmake
index 1c47743..9975872 100644 (file)
@@ -42,7 +42,7 @@ if(NS3_FOUND) # Starting from 3.36, ns3 provides a working pkg-config file, maki
 else()
   set(NS3_HINT ${ns3_path} CACHE PATH "Path to search for NS3 lib and include")
 
-  set(NS3_KNOWN_VERSIONS "3-dev" "3.28" "3.29" "3.30" "3.31" "3.32" "3.33" "3.34" "3.35")
+  set(NS3_KNOWN_VERSIONS "3-dev" "3.28" "3.29" "3.30" "3.31" "3.32" "3.33" "3.34" "3.35") # subsequent versions use pkg-config
 
   foreach (_ns3_ver ${NS3_KNOWN_VERSIONS})
     list(APPEND _ns3_LIB_SEARCH_DIRS "ns${_ns3_ver}-core" "ns${_ns3_ver}-core-optimized" "ns${_ns3_ver}-core-debug" "ns${_ns3_ver}-core-default")
@@ -126,8 +126,19 @@ else()
   endforeach()
 endif()
 
+set(SIMGRID_HAVE_NS3_GetNextEventTime FALSE)
 if(SIMGRID_HAVE_NS3)
-  message(STATUS "ns-3 found (v${NS3_VERSION}; minor:${NS3_MINOR_VERSION}; patch:${NS3_PATCH_VERSION}; libpath: ${NS3_LIBRARY_PATH}).")
+  try_compile(compile_ns3 ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_ns3.cpp
+              CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${NS3_INCLUDE_DIR}" "-DLINK_DIRECTORIES=${NS3_LIBRARY_PATH}"
+              LINK_LIBRARIES "${NS3_LIBRARIES}"
+              OUTPUT_VARIABLE compile_ns3_output)
+  if(NOT compile_ns3)
+    message(STATUS "ns-3 does not have the ns3::Simulator::GetNextEventTime patch. The ns-3 model will not be idempotent. Compilation output:\n ${compile_ns3_output}")
+  else()
+    set(SIMGRID_HAVE_NS3_GetNextEventTime TRUE)
+  endif()
+  file(REMOVE ${CMAKE_BINARY_DIR}/prog_ns3)
+  message(STATUS "ns-3 found (v${NS3_VERSION}; minor ver:${NS3_MINOR_VERSION}; patch ver:${NS3_PATCH_VERSION}; GetNextEventTime patch: ${SIMGRID_HAVE_NS3_GetNextEventTime}; libpath: ${NS3_LIBRARY_PATH}).")
   link_directories(${NS3_LIBRARY_PATH})
   include_directories(${NS3_INCLUDE_DIR})
 else()