Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't search for RngStream.h but specific file simulator.h
[simgrid.git] / buildtools / Cmake / Modules / FindGTnets.cmake
index 14dc6b7..44eb7a8 100644 (file)
@@ -1,7 +1,9 @@
-find_path(HAVE_RNGSTREAM_H RngStream.h
+find_library(HAVE_GTNETS_LIB
+    NAME gtnets
     HINTS
+    $ENV{LD_LIBRARY_PATH}
     $ENV{HOME}
-    PATH_SUFFIXES include include/gtnets
+    PATH_SUFFIXES lib64 lib lib64/gtnets lib/gtnets
     PATHS
     /opt
     /opt/local
@@ -11,26 +13,26 @@ find_path(HAVE_RNGSTREAM_H RngStream.h
     ${gtnets_path}
 )
 
-find_library(HAVE_GTNETS_LIB
-    NAME gtnets
+find_path(HAVE_SIMULATOR_H
+       NAME simulator.h
     HINTS
-    $ENV{LD_LIBRARY_PATH}
     $ENV{HOME}
-    PATH_SUFFIXES lib64 lib lib64/gtnets lib/gtnets
+    $ENV{GTNETS_ROOT}
+    PATH_SUFFIXES include include/gtnets
     PATHS
     /opt
     /opt/local
     /opt/csw
     /sw
     /usr
-    ${gtnets_path}
 )
 
 string(REPLACE "/libgtnets.${LIB_EXE}" ""  GTNETS_LIB_PATH "${HAVE_GTNETS_LIB}")
 
-if(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
+if(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
 
-       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)        
+       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
+                                       OUTPUT_VARIABLE COMPILE_GTNETS_VAR)     
        if(COMPILE_GTNETS_VAR)
                SET(HAVE_GTNETS 0)
        else(COMPILE_GTNETS_VAR)
@@ -41,12 +43,7 @@ if(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
                        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${GTNETS_LIB_PATH} ")
                endif(NOT operation)
                
-               string(REGEX MATCH "-I${HAVE_RNGSTREAM_H} " operation "${CMAKE_C_FLAGS}")
-               if(NOT operation)
-                       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${HAVE_RNGSTREAM_H} ")
-               endif(NOT operation)
-               
-               SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_RNGSTREAM_H} -L${GTNETS_LIB_PATH} ")
+               SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_SIMULATOR_H} -L${GTNETS_LIB_PATH} ")
                
                string(REGEX MATCH "${GTNETS_LIB_PATH}" operation "$ENV{LD_LIBRARY_PATH}")
                if(NOT operation)
@@ -55,16 +52,14 @@ if(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
                
        endif(COMPILE_GTNETS_VAR)
 
-else(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
-message(STATUS "Gtnets is enabled but can't find it. You should set LD_LIBRARY_PATH...")
-endif(HAVE_GTNETS_LIB AND HAVE_RNGSTREAM_H)
-
-message(STATUS "Looking for RngStream.h")
-if(HAVE_RNGSTREAM_H)
-message(STATUS "Looking for RngStream.h - found")
-else(HAVE_RNGSTREAM_H)
-message(STATUS "Looking for RngStream.h - not found")
-endif(HAVE_RNGSTREAM_H)
+else(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
+       if(NOT HAVE_GTNETS_LIB)
+       message(STATUS "Gtnets is enabled but can't find it.")
+       endif(NOT HAVE_GTNETS_LIB)
+       if(NOT HAVE_SIMULATOR_H)
+       message(STATUS "Gtnets needs simulator.h")
+       endif(NOT HAVE_SIMULATOR_H)
+endif(HAVE_GTNETS_LIB AND HAVE_SIMULATOR_H)
 
 message(STATUS "Looking for lib gtnets patch")
 if(HAVE_GTNETS)
@@ -74,4 +69,4 @@ message(STATUS "Looking for lib gtnets patch - not found")
 endif(HAVE_GTNETS)
 
 mark_as_advanced(HAVE_GTNETS_LIB)
-mark_as_advanced(HAVE_RNGSTREAM_H)
\ No newline at end of file
+mark_as_advanced(HAVE_SIMULATOR_H)
\ No newline at end of file