Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't need this variable now.
[simgrid.git] / buildtools / Cmake / CompleteInFiles.cmake
index 8379ad4..a43c745 100644 (file)
@@ -2,9 +2,15 @@ include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckIncludeFiles)
 include(CheckLibraryExists)
+include(TestBigEndian)
+
+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)
@@ -13,27 +19,28 @@ CHECK_LIBRARY_EXISTS(rt     clock_gettime           NO_DEFAULT_PATHS HAVE_POSIX_GETTIME)
 
 CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME)
 CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
-CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
-CHECK_INCLUDE_FILE(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
-CHECK_INCLUDE_FILE(socket.h HAVE_SOCKET_H)
-CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
-CHECK_INCLUDE_FILE(stat.h HAVE_STAT_H)
-CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
-CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
-CHECK_INCLUDE_FILE(winsock.h HAVE_WINSOCK_H)
-CHECK_INCLUDE_FILE(winsock2.h HAVE_WINSOCK2_H)
-CHECK_INCLUDE_FILE(errno.h HAVE_ERRNO_H)
-CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
-CHECK_INCLUDE_FILE(execinfo.h HAVE_EXECINFO_H)
-CHECK_INCLUDE_FILE(signal.h HAVE_SIGNAL_H)
-CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H)
-CHECK_INCLUDE_FILE(time.h HAVE_TIME_H)
-CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
-CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
-CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H)
-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("pthread.h" HAVE_PTHREAD_H)
+CHECK_INCLUDE_FILE("valgrind/valgrind.h" HAVE_VALGRIND_VALGRIND_H)
+CHECK_INCLUDE_FILE("socket.h" HAVE_SOCKET_H)
+CHECK_INCLUDE_FILE("sys/socket.h" HAVE_SYS_SOCKET_H)
+CHECK_INCLUDE_FILE("stat.h" HAVE_STAT_H)
+CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
+CHECK_INCLUDE_FILE("winsock.h" HAVE_WINSOCK_H)
+CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
+CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
+CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
+CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
+CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
+CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
+CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
+CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
+CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
+CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
+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_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
 CHECK_FUNCTION_EXISTS(usleep HAVE_USLEEP)
@@ -49,6 +56,11 @@ CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF)
 CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT)
 CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
 
+if(WIN32)
+    set(HAVE_UCONTEXT_H 1)
+    set(HAVE_MAKECONTEXT 1)
+endif(WIN32)
+
 set(CONTEXT_UCONTEXT 0)
 SET(CONTEXT_THREADS 0)
 SET(HAVE_RUBY 0)
@@ -60,80 +72,32 @@ if(enable_tracing)
        SET(HAVE_TRACING 1)
 endif(enable_tracing)
 
-if(enable_model-checking)
+if(enable_model-checking AND HAVE_MMAP)
+       SET(HAVE_MC 1)
        SET(MMALLOC_WANT_OVERIDE_LEGACY 1)
-endif(enable_model-checking)
+else(enable_model-checking AND HAVE_MMAP)
+       SET(HAVE_MC 0)
+       SET(MMALLOC_WANT_OVERIDE_LEGACY 0)
+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(REPLACE "${LUA_MAJOR_VERSION}." "" LUA_VERSION "${LUA_VERSION}")
-       string(REGEX MATCH "^[0-9]" LUA_MINOR_VERSION "${LUA_VERSION}")
-       string(REPLACE "${LUA_MINOR_VERSION}." "" 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)
@@ -145,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)
@@ -190,20 +153,41 @@ endif(enable_java)
 
 #--------------------------------------------------------------------------------------------------
 ### Initialize of CONTEXT GTNETS
-if(NOT enable_gtnets)
+if(NOT enable_gtnets OR enable_supernovae)
        SET(HAVE_GTNETS 0)
-else(NOT enable_gtnets)
+else(NOT enable_gtnets OR enable_supernovae)
        set(GTNETS_LDFLAGS "-L${gtnets_path}/lib")
        set(GTNETS_CPPFLAGS "-I${gtnets_path}/include/gtnets")
-       exec_program("${CMAKE_CXX_COMPILER} ${GTNETS_CPPFLAGS} -lgtnets ${GTNETS_LDFLAGS} ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_gtnets.cpp " OUTPUT_VARIABLE COMPILE_GTNETS_VAR) 
+       exec_program("${CMAKE_CXX_COMPILER} ${GTNETS_CPPFLAGS} -lgtnets ${GTNETS_LDFLAGS} ${PROJECT_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)
                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)
+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
@@ -218,7 +202,7 @@ if(pthread)
        ### HAVE_SEM_INIT
        
        if(HAVE_SEM_INIT_LIB)
-               exec_program("${CMAKE_C_COMPILER} -lpthread ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_sem_init.c" OUTPUT_VARIABLE HAVE_SEM_INIT_run)
+               exec_program("${CMAKE_C_COMPILER} -lpthread ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_init.c" OUTPUT_VARIABLE HAVE_SEM_INIT_run)
                if(HAVE_SEM_INIT_run)
                        set(HAVE_SEM_INIT 0)
                else(HAVE_SEM_INIT_run)
@@ -229,7 +213,7 @@ if(pthread)
        ### HAVE_SEM_TIMEDWAIT
 
        if(HAVE_SEM_TIMEDWAIT_LIB)
-               exec_program("${CMAKE_C_COMPILER} -lpthread ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_sem_timedwait.c" OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run)
+               exec_program("${CMAKE_C_COMPILER} -lpthread ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_timedwait.c" OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run)
                if(HAVE_SEM_TIMEDWAIT_run)
                        set(HAVE_SEM_TIMEDWAIT 0)
                else(HAVE_SEM_TIMEDWAIT_run)
@@ -240,7 +224,7 @@ if(pthread)
        ### HAVE_MUTEX_TIMEDLOCK
 
        if(HAVE_MUTEX_TIMEDLOCK_LIB)
-               exec_program("${CMAKE_C_COMPILER} -lpthread ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_mutex_timedlock.c" OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run)
+               exec_program("${CMAKE_C_COMPILER} -lpthread ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_mutex_timedlock.c" OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run)
                if(HAVE_MUTEX_TIMEDLOCK_run)
                        set(HAVE_MUTEX_TIMEDLOCK 0)
                else(HAVE_MUTEX_TIMEDLOCK_run)
@@ -255,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/prog_test/prog_AC_CHECK_MCSC.c
+       ${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)
@@ -269,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)
@@ -346,17 +340,16 @@ if(IS_DIRECTORY ${PROJECT_DIRECTORY}/.svn)
 endif(IS_DIRECTORY ${PROJECT_DIRECTORY}/.svn)
 
 if(IS_DIRECTORY ${PROJECT_DIRECTORY}/.git)
-       find_file(GIT ".git" ${PROJECT_DIRECTORY})
+
        exec_program("git --git-dir=${PROJECT_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
-       string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
        exec_program("git --git-dir=${PROJECT_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
        exec_program("git svn info" ${PROJECT_DIRECTORY} OUTPUT_VARIABLE "GIT_SVN_VERSION")
+       
+       string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
        string(REPLACE "\n" ";" GIT_SVN_VERSION ${GIT_SVN_VERSION})
        STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
        STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
        STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
-       message("GIT_DATE       : ${GIT_DATE}")
-       message("GIT_VERSION    : ${GIT_VERSION}")
        foreach(line ${GIT_SVN_VERSION})
                string(REGEX MATCH "^Revision:.*" line_good ${line})
                if(line_good)
@@ -364,18 +357,16 @@ if(IS_DIRECTORY ${PROJECT_DIRECTORY}/.git)
                        set(SVN_VERSION ${line_good})
                endif(line_good)
        endforeach(line ${GIT_SVN_VERSION})
-       message("GIT_SVN_VERSION : ${SVN_VERSION}")
 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}
-       ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_GRAS_ARCH.c
+       ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_ARCH.c
        RUN_OUTPUT_VARIABLE var1
        )
 if(BIGENDIAN)
@@ -447,7 +438,7 @@ endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/4:")
 # Check architecture signature end
 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
        ${PROJECT_DIRECTORY}
-       ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_GRAS_CHECK_STRUCT_COMPACTION.c
+       ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_CHECK_STRUCT_COMPACTION.c
        RUN_OUTPUT_VARIABLE var2
        )
 separate_arguments(var2)
@@ -458,7 +449,7 @@ endforeach(var_tmp ${var2})
 # Check for [SIZEOF_MAX]
 try_run(RUN_SM_VAR COMPILE_SM_VAR
        ${PROJECT_DIRECTORY}
-       ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_max_size.c
+       ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_max_size.c
        RUN_OUTPUT_VARIABLE var3
        )
 SET(SIZEOF_MAX ${var3})
@@ -466,18 +457,28 @@ SET(SIZEOF_MAX ${var3})
 #--------------------------------------------------------------------------------------------------
 
 set(makecontext_CPPFLAGS_2 "")
-if(HAVE_MAKECONTEXT)
+if(HAVE_MAKECONTEXT OR WIN32)
        set(makecontext_CPPFLAGS "-DTEST_makecontext")
        if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
                set(makecontext_CPPFLAGS_2 "-DOSX")
        endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+       
+    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}
-               ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_stacksetup.c
+               ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c
                COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}"
                )
-       
        file(READ ${simgrid_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
        string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
        string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
@@ -486,8 +487,7 @@ if(HAVE_MAKECONTEXT)
        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)
+endif(HAVE_MAKECONTEXT OR WIN32)
 
 #--------------------------------------------------------------------------------------------------
 
@@ -495,7 +495,7 @@ endif(HAVE_MAKECONTEXT)
 
        try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
                ${PROJECT_DIRECTORY}
-               ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_stackgrowth.c
+               ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c
                )
 file(READ "${simgrid_BINARY_DIR}/conftestval" stack)
 if(stack MATCHES "down")
@@ -519,7 +519,7 @@ endif(stack MATCHES "up")
 #AC_PRINTF_NULL
 try_run(RUN_PRINTF_NULL_VAR COMPILE_PRINTF_NULL_VAR
        ${PROJECT_DIRECTORY}
-       ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_printf_null.c
+       ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_printf_null.c
        )
 
 if(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
@@ -541,7 +541,7 @@ set(diff_va "va_copy((d),(s))"
 )
 
 foreach(fct ${diff_va})
-       write_file("${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_va_copy.c" "#include <stdlib.h>
+       write_file("${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c" "#include <stdlib.h>
        #include <stdarg.h>
        #include <string.h>
        #define DO_VA_COPY(d,s) ${fct}
@@ -572,7 +572,7 @@ foreach(fct ${diff_va})
        )
        try_compile(COMPILE_VA_NULL_VAR
        ${PROJECT_DIRECTORY}
-       ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_va_copy.c
+       ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c
        )
        if(COMPILE_VA_NULL_VAR)
                string(REGEX REPLACE "\;" "" fctbis ${fct})
@@ -618,7 +618,7 @@ foreach(fct ${diff_va})
                endif(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s)), sizeof(*(s))")
                                
                if(NOT STATUS_OK)
-               set(__VA_COPY_USE "__VA_COPY_USE_${ac_cv_va_copy}")
+               set(__VA_COPY_USE "__VA_COPY_USE_${ac_cv_va_copy}(d, s)")
                endif(NOT STATUS_OK)
                set(STATUS_OK "1")
                
@@ -630,14 +630,16 @@ endforeach(fct ${diff_va})
 ### Try execut getline command
 try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
        ${PROJECT_DIRECTORY}
-       ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_getline.c
+       ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_getline.c
        OUTPUT_VARIABLE GETLINE_OUTPUT
        )
 
 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
@@ -645,7 +647,7 @@ if(HAVE_SNPRINTF AND HAVE_VSNPRINTF)
 
        try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR
                ${PROJECT_DIRECTORY}
-               ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_snprintf.c
+               ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_snprintf.c
                )
        if(CMAKE_CROSSCOMPILING)
                set(RUN_SNPRINTF_FUNC "cross") 
@@ -653,7 +655,7 @@ if(HAVE_SNPRINTF AND HAVE_VSNPRINTF)
 
        try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR
                ${PROJECT_DIRECTORY}
-               ${PROJECT_DIRECTORY}/buildtools/Cmake/prog_test/prog_vsnprintf.c
+               ${PROJECT_DIRECTORY}/buildtools/Cmake/test_prog/prog_vsnprintf.c
                )
        if(CMAKE_CROSSCOMPILING)
                set(RUN_VSNPRINTF_FUNC "cross")
@@ -669,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
@@ -689,18 +695,14 @@ endif(ADDR2LINE)
 
 ### File to create
 
-configure_file(${PROJECT_DIRECTORY}/src/context_sysv_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/context_sysv_config.h)
+configure_file("${PROJECT_DIRECTORY}/src/context_sysv_config.h.in"                     "${PROJECT_DIRECTORY}/src/context_sysv_config.h" @ONLY IMMEDIATE)
 
 SET( CMAKEDEFINE "#cmakedefine" )
-configure_file("${PROJECT_DIRECTORY}/buildtools/Cmake/src/c_gras_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/gras_config.h" @ONLY IMMEDIATE)
-configure_file("${CMAKE_CURRENT_BINARY_DIR}/src/gras_config.h" "${CMAKE_CURRENT_BINARY_DIR}/src/gras_config.h" @ONLY IMMEDIATE)
-configure_file("${PROJECT_DIRECTORY}/include/simgrid_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_config.h" @ONLY IMMEDIATE)
-configure_file("${PROJECT_DIRECTORY}/buildtools/Cmake/src/tracing_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/include/instr/tracing_config.h" @ONLY IMMEDIATE)
-configure_file("${CMAKE_CURRENT_BINARY_DIR}/include/instr/tracing_config.h" "${CMAKE_CURRENT_BINARY_DIR}/include/instr/tracing_config.h" @ONLY IMMEDIATE)
-
-if(NOT prefix)
-       set(prefix /usr/local)
-endif(NOT prefix)
+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)
 
 set(top_srcdir "${PROJECT_DIRECTORY}")
 set(srcdir "${PROJECT_DIRECTORY}/src")
@@ -709,9 +711,12 @@ set(exec_prefix ${prefix})
 set(includedir ${prefix}/include)
 set(top_builddir ${PROJECT_DIRECTORY})
 set(libdir ${exec_prefix}/lib)
+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)