Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't need this variable now.
[simgrid.git] / buildtools / Cmake / CompleteInFiles.cmake
index 196c6b1..a43c745 100644 (file)
@@ -2,11 +2,15 @@ include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckIncludeFiles)
 include(CheckLibraryExists)
+include(TestBigEndian)
 
-set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${CGRPAH_PATH}")
+TEST_BIG_ENDIAN(BIGENDIAN)
 
 # Checks for header libraries functions.
 
+find_library(HAVE_CGRAPH_LIB cgraph)
+find_file(HAVE_CGRAPH_H graphviz/cgraph.h)
+
 CHECK_LIBRARY_EXISTS(pthread   pthread_create          NO_DEFAULT_PATHS pthread)
 CHECK_LIBRARY_EXISTS(pthread   sem_init                NO_DEFAULT_PATHS HAVE_SEM_INIT_LIB)
 CHECK_LIBRARY_EXISTS(pthread   sem_timedwait           NO_DEFAULT_PATHS HAVE_SEM_TIMEDWAIT_LIB)
@@ -37,7 +41,6 @@ CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
 CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
 CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
 CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
-CHECK_INCLUDE_FILE("graphviz/cgraph.h" HAVE_CGRAPH_H)
 
 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
 CHECK_FUNCTION_EXISTS(usleep HAVE_USLEEP)
@@ -78,75 +81,23 @@ else(enable_model-checking AND HAVE_MMAP)
 endif(enable_model-checking AND HAVE_MMAP)
 
 if(enable_lua)
-       exec_program("lua -v" OUTPUT_VARIABLE LUA_VERSION)
-       string(REGEX MATCH "[0-9]+[.]+[0-9]+[.]+[0-9]+" LUA_VERSION "${LUA_VERSION}")
-       string(REGEX MATCH "^[0-9]+" LUA_MAJOR_VERSION "${LUA_VERSION}")
-       string(REGEX MATCH "[0-9]+[.]+[0-9]+$" LUA_VERSION "${LUA_VERSION}")
-       string(REGEX MATCH "^[0-9]+" LUA_MINOR_VERSION "${LUA_VERSION}")
-       string(REGEX MATCH "[0-9]+$" LUA_PATCH_VERSION "${LUA_VERSION}")
-
-       if(LUA_MAJOR_VERSION MATCHES "5" AND LUA_MINOR_VERSION MATCHES "1")
-       
-               find_path(HAVE_LUA5_1_LUALIB_H
-               NAMES lualib.h 
-               PATHS "/sw/include/" "/usr/include/lua${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}/"
-               )
-               find_path(HAVE_LUA5_1_LAUXLIB_H
-               NAMES lauxlib.h
-               PATHS "/sw/include/" "/usr/include/lua${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}/"
-               )
-               find_library(LUA_LIB_PATH_1
-               NAMES lua${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}
-               PATHS /usr
-               )
-               find_library(LUA_LIB_PATH_2
-               NAMES lua-${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}
-               PATHS /usr
-               )
-               find_library(LUA_LIB_PATH_3
-               NAMES lua.${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}.${LUA_PATCH_VERSION}
-               PATHS /sw
-               )
-       
-               if(HAVE_LUA5_1_LUALIB_H AND HAVE_LUA5_1_LAUXLIB_H)
-                       set(HAVE_LUA 1)
-                       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${HAVE_LUA5_1_LUALIB_H} ")
-       
-                       if(NOT HAVE_LUA5_1_LUALIB_H STREQUAL HAVE_LUA5_1_LAUXLIB_H)
-                               SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${HAVE_LUA5_1_LAUXLIB_H} ")
-                               #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_LUA5_1_LAUXLIB_H} ")
-                       endif(NOT HAVE_LUA5_1_LUALIB_H STREQUAL HAVE_LUA5_1_LAUXLIB_H)
-               endif(HAVE_LUA5_1_LUALIB_H AND HAVE_LUA5_1_LAUXLIB_H)
-       
-               if(LUA_LIB_PATH_1)
-                       set(liblua lua${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION})
-                       set(lua_lib_path_to_use ${LUA_LIB_PATH_1})
-               endif(LUA_LIB_PATH_1)
-       
-               if(LUA_LIB_PATH_2)
-                       set(liblua lua-${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION})
-                       set(lua_lib_path_to_use ${LUA_LIB_PATH_2})
-               endif(LUA_LIB_PATH_2)
-       
-               if(LUA_LIB_PATH_3)
-                       set(liblua lua.${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}.${LUA_PATCH_VERSION})
-                       set(lua_lib_path_to_use ${LUA_LIB_PATH_3})
-               endif(LUA_LIB_PATH_3)
-       
-               if(NOT LUA_LIB_PATH_1 AND NOT LUA_LIB_PATH_2 AND NOT LUA_LIB_PATH_3)
-                       set(HAVE_LUA 0)
-               else(NOT LUA_LIB_PATH_1 AND NOT LUA_LIB_PATH_2 AND NOT LUA_LIB_PATH_3)
-                       string(REGEX REPLACE "liblua.*" "" lua_lib_path_to_use ${lua_lib_path_to_use})
-                       string(REGEX MATCH "-L${lua_lib_path_to_use}" operation "${CMAKE_EXE_LINKER_FLAGS}")
-                       if(NOT operation)
-                               SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}-L${lua_lib_path_to_use} ")
-                       endif(NOT operation)
-               endif(NOT LUA_LIB_PATH_1 AND NOT LUA_LIB_PATH_2 AND NOT LUA_LIB_PATH_3)
-               
-       else(LUA_MAJOR_VERSION MATCHES "5" AND LUA_MINOR_VERSION MATCHES "1")
-               message("Lua binding need version 5.1.x actually version ${LUA_MAJOR_VERSION}.${LUA_MINOR_VERSION}.x")
-       endif(LUA_MAJOR_VERSION MATCHES "5" AND LUA_MINOR_VERSION MATCHES "1")
-       
+       include(FindLua51)
+       if(LUA51_FOUND)
+               set(HAVE_LUA 1)
+               SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${LUA_INCLUDE_DIR} ")
+               foreach(path_lua ${LUA_LIBRARIES})
+               string(REGEX REPLACE "liblua.*" "" path_lua_to_use ${path_lua})
+               string(REGEX MATCH ".*lua.*" operation "${path_lua}")
+               if(NOT operation)
+                       string(REGEX REPLACE "${path_lua_to_use}" "" liblua ${path_lua})
+                       string(REPLACE "lib" "" liblua "${liblua}")
+                       string(REGEX REPLACE "[.][^.]*$" "" liblua "${liblua}")                 
+               endif(NOT operation)
+               endforeach(path_lua ${LUA_LIBRARIES})
+       else(LUA51_FOUND)
+               message("Lua binding need version 5.1 and cmake version 2.8")
+               message("Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
+       endif(LUA51_FOUND)
 endif(enable_lua)
 
 if(enable_ruby)
@@ -158,8 +109,7 @@ if(enable_ruby)
                        if(NOT RUBY_LIBRARY_NAME)
                                set(RUBY_LIBRARY_NAME ruby)
                        endif(NOT RUBY_LIBRARY_NAME)
-                       string(REGEX REPLACE "libruby.*$" "" RUBY_LIBRARY ${RUBY_LIBRARY})
-                       SET(CMAKE_EXE_LINKER_FLAGS "-L${RUBY_LIBRARY} ")
+                       string(REGEX REPLACE "/libruby.*$" "" RUBY_LIBRARY ${RUBY_LIBRARY})
                        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${RUBY_CONFIG_INCLUDE_DIR} ") #path to config.h
                        string(COMPARE EQUAL "${RUBY_INCLUDE_DIR}" "${RUBY_CONFIG_INCLUDE_DIR}" operation)
                        if(NOT operation)
@@ -201,13 +151,6 @@ if(enable_java)
        endif(JAVA_COMPILE AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2)
 endif(enable_java)
 
-#--------------------------------------------------------------------------------------------------
-### Initialize of cgraph
-
-if(HAVE_CGRAPH_H)
-       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${CGRPAH_PATH} ")
-endif(HAVE_CGRAPH_H)
-
 #--------------------------------------------------------------------------------------------------
 ### Initialize of CONTEXT GTNETS
 if(NOT enable_gtnets OR enable_supernovae)
@@ -220,11 +163,32 @@ else(NOT enable_gtnets OR enable_supernovae)
                SET(HAVE_GTNETS 0)
        else(COMPILE_GTNETS_VAR)
                SET(HAVE_GTNETS 1)
-               SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}${GTNETS_LDFLAGS} ${GTNETS_CPPFLAGS} ")
-               SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${GTNETS_LDFLAGS} ${GTNETS_CPPFLAGS} ")
+               SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}${GTNETS_CPPFLAGS} ${GTNETS_LDFLAGS} ")
+               SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${GTNETS_CPPFLAGS} ${GTNETS_LDFLAGS} ")
+               string(REGEX MATCH "${gtnets_path}/lib" operation "$ENV{LD_LIBRARY_PATH}")
+               if(NOT operation)
+                       message("Don't forget to set LD_LIBRARY_PATH")
+                       message("export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${gtnets_path}/lib")
+               endif(NOT operation)
        endif(COMPILE_GTNETS_VAR)
 endif(NOT enable_gtnets OR enable_supernovae)
 
+#--------------------------------------------------------------------------------------------------
+### Initialize of cgraph
+mark_as_advanced(HAVE_CGRAPH_LIB)
+mark_as_advanced(HAVE_CGRAPH_H)
+
+if(HAVE_CGRAPH_LIB AND HAVE_CGRAPH_H)
+       string(REGEX REPLACE "/libcgraph.*" "" lib_cgraph ${HAVE_CGRAPH_LIB})
+       string(REPLACE "/cgraph.h" "" file_cgraph_h ${HAVE_CGRAPH_H})
+               
+       string(REGEX MATCH "-I${file_cgraph_h} " operation "${CMAKE_C_FLAGS}")
+       if(NOT operation)
+               SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${file_cgraph_h} ")
+       endif(NOT operation)
+       
+endif(HAVE_CGRAPH_LIB AND HAVE_CGRAPH_H)
+
 #--------------------------------------------------------------------------------------------------
 ### Initialize of CONTEXT THREADS
 
@@ -275,13 +239,23 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
        set(mcsc_flags "-D_XOPEN_SOURCE")
 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
 
+if(WIN32)
+    if(__VISUALC__)
+       set(mcsc_flags "/D_XBT_WIN32 /I${PROJECT_DIRECTORY}/include/xbt /I${PROJECT_DIRECTORY}/src/xbt")
+       endif(__VISUALC__)
+       if(__GNUC__)
+               set(mcsc_flags "-D_XBT_WIN32 -I${PROJECT_DIRECTORY}/include/xbt -I${PROJECT_DIRECTORY}/src/xbt")
+       endif(__GNUC__)
+endif(WIN32)
+
 try_run(RUN_mcsc_VAR COMPILE_mcsc_VAR
        ${PROJECT_DIRECTORY}
        ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c
        COMPILE_DEFINITIONS "${mcsc_flags}"
+       OUTPUT_VARIABLE var_compil
        )
-       
-if(EXISTS "${simgrid_BINARY_DIR}/conftestval")
+
+if(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
        file(READ "${simgrid_BINARY_DIR}/conftestval" mcsc)
        STRING(REPLACE "\n" "" mcsc "${mcsc}")
        if(mcsc)
@@ -289,9 +263,9 @@ if(EXISTS "${simgrid_BINARY_DIR}/conftestval")
        elseif(mcsc)
                set(mcsc "no")
        endif(mcsc)
-else(EXISTS "${simgrid_BINARY_DIR}/conftestval")
+else(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
        set(mcsc "no")
-endif(EXISTS "${simgrid_BINARY_DIR}/conftestval")
+endif(EXISTS "${simgrid_BINARY_DIR}/conftestval" AND COMPILE_mcsc_VAR)
 
 if(mcsc MATCHES "no" AND pthread)
        if(HAVE_WINDOWS_H)
@@ -388,8 +362,7 @@ endif(IS_DIRECTORY ${PROJECT_DIRECTORY}/.git)
 ###################################
 ## SimGrid and GRAS specific checks
 ##
-include(TestBigEndian)
-TEST_BIG_ENDIAN(BIGENDIAN)
+
 # Check architecture signature begin
 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
        ${PROJECT_DIRECTORY}
@@ -490,9 +463,16 @@ if(HAVE_MAKECONTEXT OR WIN32)
                set(makecontext_CPPFLAGS_2 "-DOSX")
        endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
        
-       if(WIN32)
-           set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 ${INCLUDES}")
-       endif(WIN32)
+    if(WIN32)
+        if(__VISUALC__)
+            set(makecontext_CPPFLAGS "/DTEST_makecontext")
+           set(makecontext_CPPFLAGS_2 "/D_XBT_WIN32 /I${PROJECT_DIRECTORY}/include/xbt /I${PROJECT_DIRECTORY}/src/xbt")
+       endif(__VISUALC__)
+       if(__GNUC__)
+           set(makecontext_CPPFLAGS "-DTEST_makecontext")
+               set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${PROJECT_DIRECTORY}/include/xbt -I${PROJECT_DIRECTORY}/src/xbt")
+       endif(__GNUC__)
+    endif(WIN32)
 
        try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
                ${PROJECT_DIRECTORY}
@@ -507,7 +487,6 @@ if(HAVE_MAKECONTEXT OR WIN32)
        string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}")   
        set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
        set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
-
 endif(HAVE_MAKECONTEXT OR WIN32)
 
 #--------------------------------------------------------------------------------------------------
@@ -657,8 +636,10 @@ try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
 
 if(NOT COMPILE_RESULT_VAR)
 SET(need_getline "#define SIMGRID_NEED_GETLINE 1")
+SET(SIMGRID_NEED_GETLINE 1)
 else(NOT COMPILE_RESULT_VAR)
 SET(need_getline "")
+SET(SIMGRID_NEED_GETLINE 0)
 endif(NOT COMPILE_RESULT_VAR)
 
 ### check for a working snprintf
@@ -690,15 +671,19 @@ endif(HAVE_SNPRINTF AND HAVE_VSNPRINTF)
 
 ### check for asprintf function familly
 if(HAVE_ASPRINTF)
-       SET(need_asprintf "")
+       SET(simgrid_need_asprintf "")
+       SET(NEED_ASPRINTF 0)
 else(HAVE_ASPRINTF)
-       SET(need_asprintf "#define SIMGRID_NEED_ASPRINTF 1")
+       SET(simgrid_need_asprintf "#define SIMGRID_NEED_ASPRINTF 1")
+       SET(NEED_ASPRINTF 1)
 endif(HAVE_ASPRINTF)
 
 if(HAVE_VASPRINTF)
-       SET(need_vasprintf "")
+       SET(simgrid_need_vasprintf "")
+       SET(NEED_VASPRINTF 0)
 else(HAVE_VASPRINTF)
-       SET(need_vasprintf "#define SIMGRID_NEED_VASPRINTF 1")
+       SET(simgrid_need_vasprintf "#define SIMGRID_NEED_VASPRINTF 1")
+       SET(NEED_VASPRINTF 1)
 endif(HAVE_VASPRINTF)
 
 ### check for addr2line
@@ -716,8 +701,8 @@ SET( CMAKEDEFINE "#cmakedefine" )
 configure_file("${PROJECT_DIRECTORY}/buildtools/Cmake/gras_config.h.in"        "${PROJECT_DIRECTORY}/src/gras_config.h" @ONLY IMMEDIATE)
 configure_file("${PROJECT_DIRECTORY}/src/gras_config.h"                                "${PROJECT_DIRECTORY}/src/gras_config.h" @ONLY IMMEDIATE)
 configure_file("${PROJECT_DIRECTORY}/include/simgrid_config.h.in"                      "${PROJECT_DIRECTORY}/include/simgrid_config.h" @ONLY IMMEDIATE)
-configure_file("${PROJECT_DIRECTORY}/buildtools/Cmake/tracing_config.h.in"     "${PROJECT_DIRECTORY}/include/instr/tracing_config.h" @ONLY IMMEDIATE)
-configure_file("${PROJECT_DIRECTORY}/include/instr/tracing_config.h"           "${PROJECT_DIRECTORY}/include/instr/tracing_config.h" @ONLY IMMEDIATE)
+#configure_file("${PROJECT_DIRECTORY}/buildtools/Cmake/tracing_config.h.in"    "${PROJECT_DIRECTORY}/include/instr/tracing_config.h" @ONLY IMMEDIATE)
+#configure_file("${PROJECT_DIRECTORY}/include/instr/tracing_config.h"          "${PROJECT_DIRECTORY}/include/instr/tracing_config.h" @ONLY IMMEDIATE)
 
 set(top_srcdir "${PROJECT_DIRECTORY}")
 set(srcdir "${PROJECT_DIRECTORY}/src")
@@ -730,6 +715,8 @@ set(CMAKE_LINKARGS "${CMAKE_CURRENT_BINARY_DIR}/lib")
 
 configure_file(${PROJECT_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_CURRENT_BINARY_DIR}/bin/smpicc @ONLY)
 configure_file(${PROJECT_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_CURRENT_BINARY_DIR}/bin/smpirun @ONLY)
+configure_file(${PROJECT_DIRECTORY}/examples/smpi/hostfile ${CMAKE_CURRENT_BINARY_DIR}/examples/smpi/hostfile COPYONLY)
+configure_file(${PROJECT_DIRECTORY}/examples/msg/small_platform.xml ${CMAKE_CURRENT_BINARY_DIR}/examples/msg/small_platform.xml COPYONLY)
 
 exec_program("chmod a=rwx ${CMAKE_CURRENT_BINARY_DIR}/bin/smpicc" OUTPUT_VARIABLE OKITOKI)
 exec_program("chmod a=rwx ${CMAKE_CURRENT_BINARY_DIR}/bin/smpirun" OUTPUT_VARIABLE OKITOKI)