Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
82f7e7eb4237b8c5dd530056e1041be5c311c8b8
[simgrid.git] / buildtools / Cmake / Modules / FindGTnets.cmake
1 find_path(HAVE_RNGSTREAM_H RngStream.h
2     HINTS
3     $ENV{HOME}
4     PATH_SUFFIXES include include/gtnets
5     PATHS
6     /opt
7     /opt/local
8     /opt/csw
9     /sw
10     /usr
11     ${gtnets_path}
12 )
13
14 find_library(HAVE_GTNETS_LIB
15     NAME gtnets
16     HINTS
17     $ENV{LD_LIBRARY_PATH}
18     $ENV{HOME}
19     PATH_SUFFIXES lib64 lib lib64/gtnets lib/gtnets
20     PATHS
21     /opt
22     /opt/local
23     /opt/csw
24     /sw
25     /usr
26     ${gtnets_path}
27 )
28
29 string(REPLACE "/libgtnets.${LIB_EXE}" ""  GTNETS_LIB_PATH "${HAVE_GTNETS_LIB}")
30
31 if(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
32
33         exec_program("${CMAKE_CXX_COMPILER} -I${HAVE_RNGSTREAM_H} -lgtnets -L${GTNETS_LIB_PATH} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_gtnets.cpp " OUTPUT_VARIABLE COMPILE_GTNETS_VAR)        
34         if(COMPILE_GTNETS_VAR)
35                 SET(HAVE_GTNETS 0)
36         else(COMPILE_GTNETS_VAR)
37                 SET(HAVE_GTNETS 1)      
38                 
39                 string(REGEX MATCH "-L${GTNETS_LIB_PATH} " operation "${CMAKE_C_FLAGS}")
40                 if(NOT operation)
41                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${GTNETS_LIB_PATH} ")
42                 endif(NOT operation)
43                 
44                 string(REGEX MATCH "-I${HAVE_RNGSTREAM_H} " operation "${CMAKE_C_FLAGS}")
45                 if(NOT operation)
46                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${HAVE_RNGSTREAM_H} ")
47                 endif(NOT operation)
48                 
49                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_RNGSTREAM_H} -L${GTNETS_LIB_PATH} ")
50                 
51                 string(REGEX MATCH "${GTNETS_LIB_PATH}" operation "$ENV{LD_LIBRARY_PATH}")
52                 if(NOT operation)
53                         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")
54                 endif(NOT operation)
55                 
56         endif(COMPILE_GTNETS_VAR)
57
58 else(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
59 message(STATUS "Gtnets is enabled but can't find it.")
60 endif(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
61
62 message(STATUS "Looking for RngStream.h")
63 if(HAVE_RNGSTREAM_H)
64 message(STATUS "Looking for RngStream.h - found")
65 else(HAVE_RNGSTREAM_H)
66 message(STATUS "Looking for RngStream.h - not found")
67 endif(HAVE_RNGSTREAM_H)
68
69 message(STATUS "Looking for lib gtnets patch")
70 if(HAVE_GTNETS)
71 message(STATUS "Looking for lib gtnets patch - found")
72 else(HAVE_GTNETS)
73 message(STATUS "Looking for lib gtnets patch - not found")
74 endif(HAVE_GTNETS)
75
76 mark_as_advanced(HAVE_GTNETS_LIB)
77 mark_as_advanced(HAVE_RNGSTREAM_H)