X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f73218921b124d155d21dd1ca4d0b9b467448780..7b37a877f66f94980a819aa585614fb2a9af2e9a:/tools/cmake/Modules/FindNS3.cmake diff --git a/tools/cmake/Modules/FindNS3.cmake b/tools/cmake/Modules/FindNS3.cmake index 3e612567e8..905f921dee 100644 --- a/tools/cmake/Modules/FindNS3.cmake +++ b/tools/cmake/Modules/FindNS3.cmake @@ -1,26 +1,34 @@ -# Try to find the NS3 library. +# Try to find the ns-3 library. # # The user can hint a path using the NS3_HINT option. # # Once done, the following will be defined: # -# NS3_INCLUDE_DIRS - the NS3 include directories +# NS3_INCLUDE_DIRS - the ns-3 include directories # NS3_LIBRARY_PATH - path to the libs -# NS3_LIBRARIES - link these to use NS3 (full path to libs) +# NS3_LIBRARIES - link these to use ns-3 (full path to libs) # # This could be improved in many ways (patches welcome): -# - No way to specify a minimal version (v3.10 is hardcoded). +# - No way to specify a minimal version (v3.26 is hardcoded). # - No proper find_package() integration -## ADDING A NS3 VERSION. +## ADDING A ns-3 VERSION. # - Add "ns3.${version}-core ns3.${version}-core-debug ns3.${version}-core-optimized" to the NAME line of the find_library below # - Add "include/ns3{version}" to the PATH_SUFFIXES line of the find_path below set(SIMGRID_HAVE_NS3 0) set(NS3_HINT ${ns3_path} CACHE PATH "Path to search for NS3 lib and include") +set(NS3_KNOWN_VERSIONS "3.22" "3.23" "3.24" "3.25" "3.26" "3.27" "3.28" "3.29" "3.30" "3.31" "3.32" "3.33" "3.34" "3.35" "3.36" "3.37" "3.38" "3.39" "3.40") + +foreach (_ns3_ver ${NS3_KNOWN_VERSIONS}) + list(APPEND _ns3_LIB_SEARCH_DIRS "ns${_ns3_ver}-core" "nss${_ns3_ver}-core-optimized" "nss${_ns3_ver}-core-debug") + list(APPEND _ns3_INCLUDE_SEARCH_DIRS "include/ns${_ns3_ver}") +endforeach() + find_library(NS3_LIBRARIES - NAME ns3-core ns3.14-core ns3.15-core ns3.16-core ns3.17-core ns3.18-core ns3.19-core ns3.20-core ns3.21-core ns3.22-core ns3.25-core ns3.26-core ns3.26-core-optimized ns3.26-core-debug ns3.27-core ns3.27-core-optimized ns3.27-core-debug ns3.28-core ns3.28-core-optimized ns3.28-core-debug + NAME ns3-core + ${_ns3_LIB_SEARCH_DIRS} PATH_SUFFIXES lib64 lib ns3/lib PATHS ${NS3_HINT} @@ -28,7 +36,8 @@ find_library(NS3_LIBRARIES find_path(NS3_INCLUDE_DIR NAME ns3/core-module.h - PATH_SUFFIXES include ns3/include include/ns3.14 include/ns3.15 include/ns3.16 include/ns3.17 include/ns3.18 include/ns3.19 include/ns3.20 include/ns3.21 include/ns3.22 include/ns3.25 include/ns3.26 include/ns3.27 include/ns3.28 + PATH_SUFFIXES include ns3/include + ${_ns3_INCLUDE_SEARCH_DIRS} PATHS ${NS3_HINT} ) @@ -60,17 +69,18 @@ if(NS3_INCLUDE_DIR) endif() string(REGEX REPLACE ".*ns([.0-9]+)-core.*" "\\1" NS3_VERSION "${NS3_LIBRARIES}") + string(REGEX REPLACE "3.([.0-9]+)" "\\1" NS3_MINOR_VERSION "${NS3_VERSION}") get_filename_component(NS3_LIBRARY_PATH "${NS3_LIBRARIES}" PATH) # Compute NS3_PATH string(REGEX REPLACE "(.*)/lib" "\\1" NS3_PATH "${NS3_LIBRARY_PATH}") - - message(STATUS "NS-3 found (v3.${NS3_VERSION} in ${NS3_PATH}).") - if (NOT NS3_LIBRARY_PATH STREQUAL "/usr/lib") + message(STATUS "ns-3 found (v${NS3_VERSION}; incl:${NS3_INCLUDE_DIR}; lib: ${NS3_LIBRARY_PATH}).") + + if (NOT NS3_LIBRARY_PATH STREQUAL "/usr/lib") string(REGEX MATCH "${NS3_LIBRARY_PATH}" MatchResult "$ENV{LD_LIBRARY_PATH}") if(NOT MatchResult) - message(STATUS "Warning: NS3 not installed in system path, and not listed in LD_LIBRARY_PATH." + message(STATUS "Warning: NS3 not installed in system path, and not listed in LD_LIBRARY_PATH." " You want to: export LD_LIBRARY_PATH=${NS3_LIBRARY_PATH}\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}") endif() endif() @@ -82,5 +92,5 @@ if(SIMGRID_HAVE_NS3) link_directories(${NS3_LIBRARY_PATH}) include_directories(${NS3_INCLUDE_DIR}) else() - message(STATUS "Warning: To use NS-3 Please install ns3 at least version 3.10 (http://www.nsnam.org/releases/)") + message(STATUS "Warning: Please install ns-3 (version 3.22 or higher -- http://www.nsnam.org/releases/) or disable this feature.") endif()