Logo AND Algorithmique Numérique Distribuée

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