Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce cmake verbosity
[simgrid.git] / buildtools / Cmake / Modules / FindNS3.cmake
index 250dfed..70d45b4 100644 (file)
@@ -1,6 +1,6 @@
 # Try to find the NS3 library.
 #
-# The user can hint a path using the ns3_path option.
+# The user can hint a path using the NS3_HINT option.
 #
 # Once done, the following will be defined:
 #
 #   - Add include/ns3{version} to the PATH_SUFFIXES line of the find_path below
 
 set(HAVE_NS3 0)
+set(NS3_HINT ${ns3_path} CACHE PATH "Path to search for NS3 lib and include")
 
 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
   PATH_SUFFIXES lib64 lib ns3/lib
   PATHS
-  ${ns3_path}
+  ${NS3_HINT}
   )
 
 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
   PATHS
-  ${ns3_path}
+  ${NS3_HINT}
   )
 
 
@@ -55,13 +56,13 @@ if(NS3_INCLUDE_DIR)
   if(NS3_LIBRARIES)
     set(HAVE_NS3 1)
     
-    string(REGEX REPLACE ".*ns3.([0-9]+)-core.*" "\\1" NS3_VERSION_MINOR "${NS3_LIBRARIES}")
+    string(REGEX REPLACE ".*ns([.0-9]+)-core.*" "\\1" NS3_VERSION "${NS3_LIBRARIES}")
     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_MINOR} in ${NS3_PATH}).")
+    message(STATUS "NS-3 found (v3.${NS3_VERSION} in ${NS3_PATH}).")
 
     if (NOT NS3_LIBRARY_PATH STREQUAL "/usr/lib") 
       string(REGEX MATCH "${NS3_LIBRARY_PATH}" MatchResult "$ENV{LD_LIBRARY_PATH}")
@@ -74,7 +75,6 @@ if(NS3_INCLUDE_DIR)
 endif()
 mark_as_advanced(NS3_LIBRARY_PATH)
 
-
 if(HAVE_NS3)
   link_directories(${NS3_LIBRARY_PATH})
   include_directories(${NS3_INCLUDE_DIR})