Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't search for ns3 and gtnets in other paths than the one given by user
[simgrid.git] / buildtools / Cmake / Modules / FindGTnets.cmake
1 find_library(HAVE_GTNETS_LIB
2     NAME gtnets
3     PATH_SUFFIXES lib64 lib lib64/gtnets lib/gtnets
4     PATHS
5     /opt
6     /opt/local
7     /opt/csw
8     /sw
9     /usr
10     ${gtnets_path}
11 )
12
13 find_path(HAVE_SIMULATOR_H
14         NAME simulator.h
15     PATH_SUFFIXES include include/gtnets
16     PATHS
17     /opt
18     /opt/local
19     /opt/csw
20     /sw
21     /usr
22     ${gtnets_path}
23 )
24
25 string(REPLACE "/libgtnets.${LIB_EXE}" ""  GTNETS_LIB_PATH "${HAVE_GTNETS_LIB}")
26
27 if(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
28
29         execute_process(COMMAND ${CMAKE_CXX_COMPILER} -I${HAVE_SIMULATOR_H} -lgtnets -L${GTNETS_LIB_PATH} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_gtnets.cpp
30                                         OUTPUT_VARIABLE COMPILE_GTNETS_VAR)     
31         if(COMPILE_GTNETS_VAR)
32                 SET(HAVE_GTNETS 0)
33         else(COMPILE_GTNETS_VAR)
34                 SET(HAVE_GTNETS 1)      
35                 
36                 string(REGEX MATCH "-L${GTNETS_LIB_PATH} " operation "${CMAKE_C_FLAGS}")
37                 if(NOT operation)
38                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${GTNETS_LIB_PATH} ")
39                 endif(NOT operation)
40                 
41                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_SIMULATOR_H} -L${GTNETS_LIB_PATH} ")
42                 
43                 string(REGEX MATCH "${GTNETS_LIB_PATH}" operation "$ENV{LD_LIBRARY_PATH}")
44                 if(NOT operation)
45                         message(FATAL_ERROR "\n\nTo use GTNETS don't forget to set LD_LIBRARY_PATH with \n\texport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${GTNETS_LIB_PATH}\n\n")
46                 endif(NOT operation)
47                 
48         endif(COMPILE_GTNETS_VAR)
49
50 else(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
51         if(NOT HAVE_GTNETS_LIB)
52         message(STATUS "Gtnets is enabled but can't find it.")
53         endif(NOT HAVE_GTNETS_LIB)
54         if(NOT HAVE_SIMULATOR_H)
55         message(STATUS "Gtnets needs simulator.h")
56         endif(NOT HAVE_SIMULATOR_H)
57 endif(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
58
59 message(STATUS "Looking for lib gtnets patch")
60 if(HAVE_GTNETS)
61 message(STATUS "Looking for lib gtnets patch - found")
62 else(HAVE_GTNETS)
63 message(STATUS "Looking for lib gtnets patch - not found")
64 endif(HAVE_GTNETS)
65
66 mark_as_advanced(HAVE_GTNETS_LIB)
67 mark_as_advanced(HAVE_SIMULATOR_H)