Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Having LD_LIBRARY_PATH is not mandatory.
[simgrid.git] / buildtools / Cmake / Modules / FindNS3.cmake
1 find_library(HAVE_NS3_LIB
2     NAME ns3
3     PATH_SUFFIXES lib64 lib ns3/lib
4     PATHS
5     /opt
6     /opt/local
7     /opt/csw
8     /sw
9     /usr
10     ${ns3_path}
11 )
12
13 find_library(HAVE_NS3_CORE_LIB
14     NAME ns3-core
15     PATH_SUFFIXES lib64 lib ns3/lib
16     PATHS
17     /opt
18     /opt/local
19     /opt/csw
20     /sw
21     /usr
22     ${ns3_path}
23 )
24
25 find_path(HAVE_CORE_MODULE_H
26         NAME ns3/core-module.h
27     PATH_SUFFIXES include ns3/include
28     PATHS
29     /opt
30     /opt/local
31     /opt/csw
32     /sw
33     /usr
34     ${ns3_path}
35 )
36
37 message(STATUS "Looking for core-module.h")
38 if(HAVE_CORE_MODULE_H)
39 message(STATUS "Looking for core-module.h - found")
40 else(HAVE_CORE_MODULE_H)
41 message(STATUS "Looking for core-module.h - not found")
42 endif(HAVE_CORE_MODULE_H)
43 mark_as_advanced(HAVE_CORE_MODULE_H)
44
45 message(STATUS "Looking for lib ns3")
46 if(HAVE_NS3_LIB)
47 message(STATUS "Looking for lib ns3 - found")
48 else(HAVE_NS3_LIB)
49 message(STATUS "Looking for lib ns3 - not found")
50 endif(HAVE_NS3_LIB)
51 mark_as_advanced(HAVE_NS3_LIB)
52
53 message(STATUS "Looking for lib ns3-core")
54 if(HAVE_NS3_CORE_LIB)
55 message(STATUS "Looking for lib ns3-core - found")
56 else(HAVE_NS3_CORE_LIB)
57 message(STATUS "Looking for lib ns3-core - not found")
58 endif(HAVE_NS3_CORE_LIB)
59 mark_as_advanced(HAVE_NS3_LIB)
60 mark_as_advanced(HAVE_NS3_CORE_LIB)
61
62 if(HAVE_CORE_MODULE_H)
63     if(HAVE_NS3_LIB)
64         message(STATUS "Warning: NS-3 version <= 3.10")
65         set(HAVE_NS3 1)
66         set(NS3_VERSION 310)
67         string(REPLACE "/libns3.${LIB_EXE}" ""  HAVE_NS3_LIB "${HAVE_NS3_LIB}")
68     endif(HAVE_NS3_LIB)
69     if(HAVE_NS3_CORE_LIB)
70         message(STATUS "NS-3 version > 3.10")
71         set(HAVE_NS3 1)
72         set(NS3_VERSION 312)
73         string(REPLACE "/libns3-core.${LIB_EXE}" ""  HAVE_NS3_LIB "${HAVE_NS3_CORE_LIB}")
74     endif(HAVE_NS3_CORE_LIB)
75 endif(HAVE_CORE_MODULE_H)
76
77 if(HAVE_NS3)
78         string(REGEX MATCH "${HAVE_NS3_LIB}" operation "$ENV{LD_LIBRARY_PATH}")
79         if(NOT operation)
80                 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}")
81         else(NOT operation)
82         
83                 string(REGEX MATCH "-L${HAVE_NS3_LIB} " operation1 "${CMAKE_C_FLAGS}")
84                 if(NOT operation1)
85                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${HAVE_NS3_LIB} ")
86                 endif(NOT operation1)
87                 
88                 string(REGEX MATCH "-I${HAVE_CORE_MODULE_H} " operation1 "${CMAKE_C_FLAGS}")
89                 if(NOT operation1)
90                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${HAVE_CORE_MODULE_H} ")
91                 endif(NOT operation1)
92         
93                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_CORE_MODULE_H} -L${HAVE_NS3_LIB} ")
94         endif(NOT operation)            
95 else(HAVE_NS3)
96     message(STATUS "Warning: To use NS-3 Please install ns3 at least version 3.10 (http://www.nsnam.org/releases/)")
97 endif(HAVE_NS3)
98
99 if(HAVE_NS3 AND enable_supernovae)
100     set(enable_supernovae OFF)
101 endif(HAVE_NS3 AND enable_supernovae)