Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Only search on given path
[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     ${gtnets_path}
6 )
7
8 find_path(HAVE_SIMULATOR_H
9         NAME simulator.h
10     PATH_SUFFIXES include include/gtnets
11     PATHS
12     ${gtnets_path}
13 )
14
15 string(REPLACE "/libgtnets.${LIB_EXE}" ""  GTNETS_LIB_PATH "${HAVE_GTNETS_LIB}")
16
17 if(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
18
19         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
20                                         OUTPUT_VARIABLE COMPILE_GTNETS_VAR)     
21         if(COMPILE_GTNETS_VAR)
22                 SET(HAVE_GTNETS 0)
23         else(COMPILE_GTNETS_VAR)
24                 SET(HAVE_GTNETS 1)      
25                 
26                 string(REGEX MATCH "-L${GTNETS_LIB_PATH} " operation "${CMAKE_C_FLAGS}")
27                 if(NOT operation)
28                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${GTNETS_LIB_PATH} ")
29                 endif(NOT operation)
30                 
31                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_SIMULATOR_H} -L${GTNETS_LIB_PATH} ")
32                 
33                 string(REGEX MATCH "${GTNETS_LIB_PATH}" operation "$ENV{LD_LIBRARY_PATH}")
34                 if(NOT operation)
35                         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")
36                 endif(NOT operation)
37                 
38         endif(COMPILE_GTNETS_VAR)
39
40 else(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
41         if(NOT HAVE_GTNETS_LIB)
42         message(STATUS "Gtnets is enabled but can't find it.")
43         endif(NOT HAVE_GTNETS_LIB)
44         if(NOT HAVE_SIMULATOR_H)
45         message(STATUS "Gtnets needs simulator.h")
46         endif(NOT HAVE_SIMULATOR_H)
47 endif(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
48
49 message(STATUS "Looking for lib gtnets patch")
50 if(HAVE_GTNETS)
51 message(STATUS "Looking for lib gtnets patch - found")
52 else(HAVE_GTNETS)
53 message(STATUS "Looking for lib gtnets patch - not found")
54 endif(HAVE_GTNETS)
55
56 mark_as_advanced(HAVE_GTNETS_LIB)
57 mark_as_advanced(HAVE_SIMULATOR_H)