Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add FindNS3 module to cmake.
authorNavarrop <Pierre.Navarro@imag.fr>
Wed, 13 Apr 2011 14:30:48 +0000 (16:30 +0200)
committerNavarrop <Pierre.Navarro@imag.fr>
Thu, 14 Apr 2011 08:29:19 +0000 (10:29 +0200)
buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/MakeLib.cmake
buildtools/Cmake/Modules/FindGTnets.cmake
buildtools/Cmake/Modules/FindNS3.cmake [new file with mode: 0644]
buildtools/Cmake/Option.cmake
buildtools/Cmake/PrintArgs.cmake

index 4f801eb..63de957 100644 (file)
@@ -19,6 +19,7 @@ string(TOUPPER ${enable_pcre} enable_pcre)
 if(enable_pcre STREQUAL "AUTO" OR enable_pcre STREQUAL "ON")
 include(FindPCRE)
 endif(enable_pcre STREQUAL "AUTO" OR enable_pcre STREQUAL "ON")
+set(HAVE_GTNETS 0)
 if(enable_gtnets)      
        include(FindGTnets)
 endif(enable_gtnets)
@@ -28,6 +29,10 @@ endif(enable_smpi)
 if(enable_lua)
        include(FindLua51Simgrid)
 endif(enable_lua)
+set(HAVE_NS3 0)
+if(enable_ns3)
+       include(FindNS3)
+endif(enable_ns3)
 
 # Checks for header libraries functions.
 CHECK_LIBRARY_EXISTS(pthread   pthread_create                  "" pthread)
@@ -637,7 +642,7 @@ set(includedir ${CMAKE_INSTALL_PREFIX}/include)
 set(top_builddir ${CMAKE_HOME_DIRECTORY})
 set(libdir ${exec_prefix}/lib)
 set(CMAKE_LINKARGS "${CMAKE_BINARY_DIR}/lib")
-set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:${GTNETS_LIB_PATH}:$LD_LIBRARY_PATH")
+set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:${GTNETS_LIB_PATH}:${HAVE_NS3_LIB}:$LD_LIBRARY_PATH")
 
 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/smpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/smpif.h @ONLY)
 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/bin/smpicc @ONLY)
index 2c1847c..06185fb 100644 (file)
@@ -123,6 +123,10 @@ if(HAVE_GTNETS)
        SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
 endif(HAVE_GTNETS)
 
+if(HAVE_NS3)
+       SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3")
+endif(HAVE_NS3)
+
 if(HAVE_POSIX_GETTIME)
        SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
 endif(HAVE_POSIX_GETTIME)
index 44eb7a8..a1e39de 100644 (file)
@@ -25,6 +25,7 @@ find_path(HAVE_SIMULATOR_H
     /opt/csw
     /sw
     /usr
+    ${gtnets_path}
 )
 
 string(REPLACE "/libgtnets.${LIB_EXE}" ""  GTNETS_LIB_PATH "${HAVE_GTNETS_LIB}")
diff --git a/buildtools/Cmake/Modules/FindNS3.cmake b/buildtools/Cmake/Modules/FindNS3.cmake
new file mode 100644 (file)
index 0000000..8906d1f
--- /dev/null
@@ -0,0 +1,66 @@
+find_library(HAVE_NS3_LIB
+    NAME ns3
+    HINTS
+    $ENV{LD_LIBRARY_PATH}
+    $ENV{HOME}
+    PATH_SUFFIXES lib64 lib lib64/ns3 lib/ns3
+    PATHS
+    /opt
+    /opt/local
+    /opt/csw
+    /sw
+    /usr
+    ${ns3_path}
+)
+
+find_path(HAVE_CORE_MODULE_H
+       NAME ns3/core-module.h
+    HINTS
+    $ENV{HOME}
+    PATH_SUFFIXES include include/ns3
+    PATHS
+    /opt
+    /opt/local
+    /opt/csw
+    /sw
+    /usr
+    ${ns3_path}
+)
+
+message(STATUS "Looking for core-module.h")
+if(HAVE_CORE_MODULE_H)
+message(STATUS "Looking for core-module.h - found")
+else(HAVE_CORE_MODULE_H)
+message(STATUS "Looking for core-module.h - not found")
+endif(HAVE_CORE_MODULE_H)
+mark_as_advanced(HAVE_CORE_MODULE_H)
+
+message(STATUS "Looking for lib ns3")
+if(HAVE_NS3_LIB)
+message(STATUS "Looking for lib ns3 - found")
+else(HAVE_NS3_LIB)
+message(STATUS "Looking for lib ns3 - not found")
+endif(HAVE_NS3_LIB)
+mark_as_advanced(HAVE_NS3_LIB)
+
+if(HAVE_NS3_LIB AND HAVE_CORE_MODULE_H)
+       set(HAVE_NS3 1)
+       string(REPLACE "/libns3.${LIB_EXE}" ""  HAVE_NS3_LIB "${HAVE_NS3_LIB}")
+       string(REGEX MATCH "${HAVE_NS3_LIB}" operation "$ENV{LD_LIBRARY_PATH}")
+       
+       if(NOT operation)
+       
+               message(STATUS "Warning: To use NS-3 don't forget to set LD_LIBRARY_PATH with:  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HAVE_NS3_LIB}")
+               set(HAVE_NS3 0)
+               
+       else(NOT operation)
+       
+               string(REGEX MATCH "-L${HAVE_NS3_LIB} " operation1 "${CMAKE_C_FLAGS}")
+               if(NOT operation1)
+                       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${HAVE_NS3_LIB} ")
+               endif(NOT operation1)
+       
+               SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_CORE_MODULE_H} -L${HAVE_NS3_LIB} ")
+       endif(NOT operation)            
+
+endif(HAVE_NS3_LIB AND HAVE_CORE_MODULE_H)
\ No newline at end of file
index bd58b59..b4b671d 100644 (file)
@@ -5,6 +5,7 @@
 
 set(BIBTEX2HTML ${BIBTEX2HTML} CACHE PATH "Path to bibtex2html")
 set(gtnets_path ${gtnets_path} CACHE PATH "Path to gtnets lib and include")
+set(ns3_path ${ns3_path} CACHE PATH "Path to ns3 lib and include")
 set(custom_flags ${custom_flags} CACHE FORCE "Customers flags add to cmake_c_flag")
 
 if(NOT CMAKE_INSTALL_PREFIX)
@@ -16,6 +17,7 @@ endif(NOT CMAKE_INSTALL_PREFIX)
 set(pipol_user ${pipol_user} CACHE TYPE INTERNAL FORCE)
 
 option(enable_gtnets "Whether gtnets model is activated." on)
+option(enable_ns3    "Whether ns3 model is activated." off)
 option(enable_smpi "This variable set smpi lib." on)
 option(enable_lua "Whether the lua bindings are activated." on)
 set(enable_pcre ${enable_pcre} CACHE FORCE "Whether the pcre lib is activated.")
index 613d96a..9e7c532 100644 (file)
@@ -89,7 +89,9 @@ message("            CPPFlags:        ${CMAKE_CXX_FLAGS}")
 message("")
 if(NOT APPLE AND NOT WIN32)
 message("      Compile Gtnets :        ${HAVE_GTNETS}")
+message("      Compile NS-3   :        ${HAVE_NS3}")
 message("      Gtnets path    :        ${gtnets_path}")
+message("      NS-3 path      :        ${ns3_path}")
 endif(NOT APPLE AND NOT WIN32)
 message("      Compile Lua    :        ${HAVE_LUA}")
 message("      Compile Smpi   :        ${enable_smpi}")