Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid into tomerge
[simgrid.git] / buildtools / Cmake / Modules / FindNS3.cmake
1
2 ## ADDING A NS3 VERSION.
3 #   - Add ns3.${version}-core to the NAME line of the find_library below
4 #   - Add include/ns3{version} to the PATH_SUFFIXES line of the find_path below
5
6 find_library(HAVE_NS3_CORE_LIB
7   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
8   PATH_SUFFIXES lib64 lib ns3/lib
9   PATHS
10   ${ns3_path}
11   )
12
13 find_path(HAVE_CORE_MODULE_H
14   NAME ns3/core-module.h
15   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
16   PATHS
17   ${ns3_path}
18   )
19
20
21
22 if(HAVE_CORE_MODULE_H)
23   message(STATUS "Looking for ns3/core-module.h - found")
24 else()
25   message(STATUS "Looking for ns3/core-module.h - not found")
26 endif()
27 mark_as_advanced(HAVE_CORE_MODULE_H)
28
29 message(STATUS "Looking for lib ns3-core")
30 if(HAVE_NS3_CORE_LIB)
31   message(STATUS "Looking for lib ns3-core - found")
32 else()
33   message(STATUS "Looking for lib ns3-core - not found")
34 endif()
35
36 mark_as_advanced(HAVE_NS3_LIB)
37 mark_as_advanced(HAVE_NS3_CORE_LIB)
38
39 if(HAVE_CORE_MODULE_H)
40   if(HAVE_NS3_LIB)
41     message(STATUS "Warning: NS-3 version <= 3.10")
42     set(HAVE_NS3 1)
43     set(NS3_VERSION_MINOR 10)
44     get_filename_component(NS3_LIBRARY_PATH "${HAVE_NS3_LIB}" PATH)
45   endif()
46   if(HAVE_NS3_CORE_LIB)
47     message(STATUS "NS-3 version > 3.10")
48     string(REGEX REPLACE ".*ns3.([0-9]+)-core.*" "\\1" NS3_VERSION_MINOR "${HAVE_NS3_CORE_LIB}")
49     set(HAVE_NS3 1)
50     get_filename_component(NS3_LIBRARY_PATH "${HAVE_NS3_CORE_LIB}" PATH)
51   endif()
52 endif()
53
54 if(HAVE_NS3)
55   string(REGEX MATCH "${NS3_LIBRARY_PATH}" operation "$ENV{LD_LIBRARY_PATH}")
56   if(NOT operation)
57     message(STATUS "Warning: To use NS-3 don't forget to set LD_LIBRARY_PATH with: export LD_LIBRARY_PATH=${NS3_LIBRARY_PATH}\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}")
58   endif()
59
60   link_directories(${NS3_LIBRARY_PATH})
61   include_directories(${HAVE_CORE_MODULE_H})
62 else()
63   message(STATUS "Warning: To use NS-3 Please install ns3 at least version 3.10 (http://www.nsnam.org/releases/)")
64 endif()