Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9ceb7ef974b9779fa33680b71ea072e64149428a
[simgrid.git] / buildtools / Cmake / CompleteInFiles.cmake
1 set(CMAKE_MODULE_PATH
2   ${CMAKE_MODULE_PATH}
3   ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Modules
4   )
5
6 # x86_64
7 # x86
8 # i.86
9
10 ### Determine the assembly flavor that we need today
11 include(CMakeDetermineSystem)
12 IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64")
13   IF(${ARCH_32_BITS})
14     message(STATUS "System processor: i686 (${CMAKE_SYSTEM_PROCESSOR}, 32 bits)")
15     set(PROCESSOR_i686 1)
16   ELSE()
17     message(STATUS "System processor: x86_64 (${CMAKE_SYSTEM_PROCESSOR}, 64 bits)")
18     set(PROCESSOR_x86_64 1)
19   ENDIF()
20   set(HAVE_RAWCTX 1)
21
22 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
23   message(STATUS "System processor: alpha")
24
25 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
26   # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
27   message(STATUS "System processor: arm")
28
29 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
30   # mips* machines are bi-endian mostly so processor does not tell
31   # endianess of the underlying system.
32   message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
33
34 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
35   message(STATUS "System processor: ppc64")
36
37 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
38   message(STATUS "System processor: ppc")
39
40 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
41   # Both flavours can run on the same processor
42   message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
43
44 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
45   message(STATUS "System processor: parisc" "parisc64")
46
47 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
48   # s390 binaries can run on s390x machines
49   message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
50
51 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
52   message(STATUS "System processor: sh")
53
54 ELSE() #PROCESSOR NOT FOUND
55   message(STATUS "PROCESSOR NOT FOUND: ${CMAKE_SYSTEM_PROCESSOR}")
56
57 ENDIF()
58
59 if(ARCH_32_BITS)
60   set(MPI_ADDRESS_SIZE 4)
61 else()
62   set(MPI_ADDRESS_SIZE 8)
63 endif()
64
65 message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
66
67 include(CheckFunctionExists)
68 include(CheckTypeSize)
69 include(CheckIncludeFile)
70 include(CheckIncludeFiles)
71 include(CheckLibraryExists)
72 include(TestBigEndian)
73 TEST_BIG_ENDIAN(BIGENDIAN)
74
75 include(FindGraphviz)
76 include(FindLibSigc++)
77
78 set(HAVE_GTNETS 0)
79 if(enable_gtnets)
80   include(FindGTnets)
81 endif()
82 if(enable_java)
83   find_package(Java REQUIRED COMPONENTS Runtime Development)
84   find_package(JNI REQUIRED)
85   message("-- [Java] JNI found: ${JNI_FOUND}")
86   message("-- [Java] JNI include dirs: ${JNI_INCLUDE_DIRS}")
87   if(enable_maintainer_mode)
88     find_package(SWIG REQUIRED)
89     include(UseSWIG)
90     message("-- [Java] Swig found: ${SWIG_FOUND} (version ${SWIG_VERSION})")
91   endif()
92   set(HAVE_Java 1)
93 endif()
94 if(enable_scala)
95   find_package(Scala REQUIRED)
96   message("-- [Scala] scalac found: ${SCALA_COMPILE}")
97   set(HAVE_Scala 1)
98 endif()
99 if(enable_lua)
100   include(FindLua51Simgrid)
101 endif()
102 set(HAVE_NS3 0)
103 if(enable_ns3)
104   include(FindNS3)
105 endif()
106
107 # algorithm 1.50.0
108 # function 1.23.0
109 # intrusive 1.35.0
110 # lambda 1.28.0
111 # signals2 1.39.0
112 find_package(Boost 1.42 REQUIRED)
113 if(Boost_FOUND)
114   include_directories(${Boost_INCLUDE_DIRS})
115 else()
116   if(APPLE) #MAC
117     message(FATAL_ERROR, "Failed to find Boost libraries (Try to install them with 'sudo fink install boost1.53.nopython')")
118   else()
119     message(FATAL_ERROR, "Failed to find Boost libraries")
120   endif()
121 endif()
122
123 # Checks for header libraries functions.
124 CHECK_LIBRARY_EXISTS(dl      dlopen                  "" HAVE_DLOPEN_IN_LIBDL)
125 CHECK_LIBRARY_EXISTS(execinfo backtrace              "" HAVE_BACKTRACE_IN_LIBEXECINFO)
126 CHECK_LIBRARY_EXISTS(pthread pthread_create          "" pthread)
127 CHECK_LIBRARY_EXISTS(pthread sem_init                "" HAVE_SEM_INIT_LIB)
128 CHECK_LIBRARY_EXISTS(pthread sem_open                "" HAVE_SEM_OPEN_LIB)
129 CHECK_LIBRARY_EXISTS(pthread sem_timedwait           "" HAVE_SEM_TIMEDWAIT_LIB)
130 CHECK_LIBRARY_EXISTS(pthread pthread_mutex_timedlock "" HAVE_MUTEX_TIMEDLOCK_LIB)
131 CHECK_LIBRARY_EXISTS(rt      clock_gettime           "" HAVE_POSIX_GETTIME)
132
133 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
134   set(CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE")
135 endif()
136
137 CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME)
138 CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
139 CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H)
140 CHECK_INCLUDE_FILE("valgrind/valgrind.h" HAVE_VALGRIND_VALGRIND_H)
141 CHECK_INCLUDE_FILE("socket.h" HAVE_SOCKET_H)
142 CHECK_INCLUDE_FILE("sys/socket.h" HAVE_SYS_SOCKET_H)
143 CHECK_INCLUDE_FILE("stat.h" HAVE_STAT_H)
144 CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
145 CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
146 CHECK_INCLUDE_FILE("winsock.h" HAVE_WINSOCK_H)
147 CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
148 CHECK_INCLUDE_FILE("windef.h" HAVE_WINDEF_H)
149 CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
150 CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
151 CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
152 CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
153 CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
154 CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
155 CHECK_INCLUDE_FILE("sys/sysctl.h" HAVE_SYS_SYSCTL_H)
156 CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
157 CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
158 CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
159 CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
160 CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
161 CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
162 CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
163 CHECK_INCLUDE_FILE("stdio.h" HAVE_STDIO_H)
164 CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
165
166 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
167 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
168 CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
169 CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
170 CHECK_FUNCTION_EXISTS(readv HAVE_READV)
171 CHECK_FUNCTION_EXISTS(popen HAVE_POPEN)
172 CHECK_FUNCTION_EXISTS(signal HAVE_SIGNAL)
173 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
174 CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
175 CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF)
176 CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF)
177 CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT)
178 CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
179 CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV)
180 CHECK_FUNCTION_EXISTS(strdup SIMGRID_HAVE_STRDUP)
181 CHECK_FUNCTION_EXISTS(_strdup SIMGRID_HAVE__STRDUP)
182
183 #Check if __thread is defined
184 execute_process(
185   COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_thread_storage.c"
186   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
187   RESULT_VARIABLE HAVE_thread_storage_run
188   )
189
190 if(HAVE_thread_storage_run)
191   set(HAVE_THREAD_LOCAL_STORAGE 1)
192 else()
193   set(HAVE_THREAD_LOCAL_STORAGE 0)
194 endif()
195
196 # Our usage of mmap is Linux-specific (flag MAP_ANONYMOUS), but kFreeBSD uses a GNU libc
197 IF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND NOT "${CMAKE_SYSTEM}" MATCHES "GNU" AND NOT  "${CMAKE_SYSTEM}" MATCHES "Darwin")
198   SET(HAVE_MMAP 0)
199   message(STATUS "Warning: MMAP is thought as non functional on this architecture (${CMAKE_SYSTEM})")
200 ENDIF()
201
202 if(HAVE_MMAP AND HAVE_THREAD_LOCAL_STORAGE)
203   SET(HAVE_MMALLOC 1)
204 else()
205   SET(HAVE_MMALLOC 0)
206 endif()
207
208 if(WIN32) #THOSE FILES ARE FUNCTIONS ARE NOT DETECTED BUT THEY SHOULD...
209   set(HAVE_UCONTEXT_H 1)
210   set(HAVE_MAKECONTEXT 1)
211   set(HAVE_SNPRINTF 1)
212   set(HAVE_VSNPRINTF 1)
213 endif()
214
215 set(CONTEXT_UCONTEXT 0)
216 SET(CONTEXT_THREADS 0)
217
218 if(enable_jedule)
219   SET(HAVE_JEDULE 1)
220 endif()
221
222 if(enable_latency_bound_tracking)
223   SET(HAVE_LATENCY_BOUND_TRACKING 1)
224 else()
225   if(enable_gtnets)
226     message(STATUS "Warning : Turning latency_bound_tracking to ON because GTNeTs is ON")
227     SET(enable_latency_bound_tracking ON)
228     SET(HAVE_LATENCY_BOUND_TRACKING 1)
229   else()
230     SET(HAVE_LATENCY_BOUND_TRACKING 0)
231   endif()
232 endif()
233
234 if(enable_mallocators)
235   SET(MALLOCATOR_IS_WANTED 1)
236 else()
237   SET(MALLOCATOR_IS_WANTED 0)
238 endif()
239
240 if(enable_model-checking AND HAVE_MMALLOC)
241   SET(HAVE_MC 1)
242   SET(MMALLOC_WANT_OVERRIDE_LEGACY 1)
243   include(FindLibunwind)
244   include(FindLibdw)
245 else()
246   if(enable_model-checking)
247     message(STATUS "Warning: support for model-checking has been disabled because HAVE_MMALLOC is false")
248   endif()
249   SET(HAVE_MC 0)
250   SET(HAVE_MMALLOC 0)
251   SET(MMALLOC_WANT_OVERRIDE_LEGACY 0)
252 endif()
253
254 if(enable_smpi)
255   include(FindGFortran)
256   SET(HAVE_SMPI 1)
257 endif()
258
259 #--------------------------------------------------------------------------------------------------
260 ### Check for some architecture dependent values
261 CHECK_TYPE_SIZE(int SIZEOF_INT)
262 CHECK_TYPE_SIZE(void* SIZEOF_VOIDP)
263
264 #--------------------------------------------------------------------------------------------------
265 ### Check for GNU dynamic linker
266 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
267 if (HAVE_DLFCN_H)
268     if(HAVE_DLOPEN_IN_LIBDL)
269       set(DL_LIBRARY "-ldl")
270     endif(HAVE_DLOPEN_IN_LIBDL)
271     execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_gnu_dynlinker.c ${DL_LIBRARY} -o test_gnu_ld
272       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
273       OUTPUT_VARIABLE HAVE_GNU_LD_compil
274     )
275     if(HAVE_GNU_LD_compil)
276       set(HAVE_GNU_LD 0)
277       message(STATUS "Warning: test program toward GNU ld failed to compile:")
278       message(STATUS "${HAVE_GNU_LD_comp_output}")
279     else()
280
281       execute_process(COMMAND ./test_gnu_ld
282           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
283           RESULT_VARIABLE HAVE_GNU_LD_run
284           OUTPUT_VARIABLE var_exec
285       )
286
287       if(NOT HAVE_GNU_LD_run)
288         set(HAVE_GNU_LD 1)
289         message(STATUS "We are using GNU dynamic linker")
290       else()
291         set(HAVE_GNU_LD 0)
292         message(STATUS "Warning: error while checking for GNU ld:")
293         message(STATUS "Test output: '${var_exec}'")
294         message(STATUS "Exit status: ${HAVE_GNU_LD_run}")
295       endif()
296       file(REMOVE test_gnu_ld)
297     endif()
298 endif()
299
300
301 #--------------------------------------------------------------------------------------------------
302 ### Initialize of CONTEXT THREADS
303
304 if(pthread)
305   set(pthread 1)
306 elseif(pthread)
307   set(pthread 0)
308 endif()
309
310 if(pthread)
311   ### Test that we have a way to create semaphores
312
313   if(HAVE_SEM_OPEN_LIB)
314     execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_open.c -lpthread -o sem_open
315     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
316     OUTPUT_VARIABLE HAVE_SEM_OPEN_compil
317     )
318
319     # Test sem_open by compiling:
320     if(HAVE_SEM_OPEN_compil)
321       set(HAVE_SEM_OPEN 0)
322       message(STATUS "Warning: sem_open not compilable")
323       message(STATUS "HAVE_SEM_OPEN_comp_output: ${HAVE_SEM_OPEN_comp_output}")
324     else()
325       set(HAVE_SEM_OPEN 1)
326       message(STATUS "sem_open is compilable")
327     endif()
328
329     # If we're not crosscompiling, we check by executing the program:
330     if (HAVE_SEM_OPEN AND NOT CMAKE_CROSSCOMPILING)
331       execute_process(COMMAND ./sem_open
332       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
333       RESULT_VARIABLE HAVE_SEM_OPEN_run
334       OUTPUT_VARIABLE var_compil
335       )
336       if (NOT HAVE_SEM_OPEN_run)
337         set(HAVE_SEM_OPEN 1)
338         message(STATUS "sem_open is executable")
339       else()
340         set(HAVE_SEM_OPEN 0)
341         if(EXISTS "${CMAKE_BINARY_DIR}/sem_open")
342           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open exists!")
343         else()
344           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open not exists!")
345         endif()
346         message(STATUS "Warning: sem_open not executable")
347         message(STATUS "Compilation output: '${var_compil}'")
348         message(STATUS "Exit result of sem_open: ${HAVE_SEM_OPEN_run}")
349       endif()
350     endif()
351     file(REMOVE sem_open)
352
353   else()
354     set(HAVE_SEM_OPEN 0)
355   endif()
356
357   if(HAVE_SEM_INIT_LIB)
358     execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_init.c -lpthread -o sem_init
359     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
360     RESULT_VARIABLE HAVE_SEM_INIT_run OUTPUT_VARIABLE HAVE_SEM_INIT_compil)
361
362     # Test sem_init by compiling:
363     if(HAVE_SEM_INIT_compil)
364       set(HAVE_SEM_INIT 0)
365       message(STATUS "Warning: sem_init not compilable")
366       message(STATUS "HAVE_SEM_INIT_comp_output: ${HAVE_SEM_OPEN_comp_output}")
367     else()
368       set(HAVE_SEM_INIT 1)
369       message(STATUS "sem_init is compilable")
370     endif()
371
372     # If we're not crosscompiling, we check by executing the program:
373     if (HAVE_SEM_INIT AND NOT CMAKE_CROSSCOMPILING)
374       execute_process(COMMAND ./sem_init
375       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
376       RESULT_VARIABLE HAVE_SEM_INIT_run
377       OUTPUT_VARIABLE var_compil
378       )
379       if (NOT HAVE_SEM_INIT_run)
380         set(HAVE_SEM_INIT 1)
381         message(STATUS "sem_init is executable")
382       else()
383         set(HAVE_SEM_INIT 0)
384         if(EXISTS "${CMAKE_BINARY_DIR}/sem_init")
385           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init exists!")
386         else()
387           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init not exists!")
388         endif()
389         message(STATUS "Warning: sem_init not executable")
390         message(STATUS "Compilation output: '${var_compil}'")
391         message(STATUS "Exit result of sem_init: ${HAVE_SEM_INIT_run}")
392       endif()
393     endif()
394     file(REMOVE sem_init)
395   endif()
396
397   if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
398     message(FATAL_ERROR "Semaphores are not usable (neither sem_open nor sem_init is both compilable and executable), but they are mandatory to threads (you may need to mount /dev).")
399   endif()
400
401   ### Test that we have a way to timewait for semaphores
402
403   if(HAVE_SEM_TIMEDWAIT_LIB)
404
405     execute_process(
406       COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_timedwait.c -lpthread"
407       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
408       OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run
409       )
410
411     if(HAVE_SEM_TIMEDWAIT_run)
412       set(HAVE_SEM_TIMEDWAIT 0)
413       message(STATUS "timedwait not compilable")
414     else()
415       set(HAVE_SEM_TIMEDWAIT 1)
416       message(STATUS "timedwait is compilable")
417     endif()
418   endif()
419
420   ### HAVE_MUTEX_TIMEDLOCK
421
422   if(HAVE_MUTEX_TIMEDLOCK_LIB)
423
424     execute_process(
425       COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_mutex_timedlock.c -lpthread"
426       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
427       OUTPUT_VARIABLE HAVE_MUTEX_TIMEDLOCK_run
428       )
429
430     if(HAVE_MUTEX_TIMEDLOCK_run)
431       set(HAVE_MUTEX_TIMEDLOCK 0)
432       message(STATUS "timedlock not compilable")
433     else()
434       message(STATUS "timedlock is compilable")
435       set(HAVE_MUTEX_TIMEDLOCK 1)
436     endif()
437   endif()
438 endif()
439
440 # AC_CHECK_MCSC(mcsc=yes, mcsc=no)
441 set(mcsc_flags "")
442 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
443   set(mcsc_flags -D_XOPEN_SOURCE)
444 endif()
445
446 if(WIN32)
447   if(ARCH_32_BITS)
448     set(mcsc_flags -D_XBT_WIN32 -D_I_X86_ -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt)
449   else()
450     set(mcsc_flags -D_XBT_WIN32 -D_AMD64_ -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt)
451   endif()
452 endif()
453
454 IF(CMAKE_CROSSCOMPILING)
455   IF(WIN32)
456     set(windows_context "yes")
457     set(IS_WINDOWS 1)
458   ENDIF()
459 ELSE()
460   file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
461   file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
462   set(MCSC_buildcmd ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c ${mcsc_flags} -o testprog)
463   execute_process(COMMAND ${MCSC_buildcmd}
464   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/
465   OUTPUT_VARIABLE COMPILE_mcsc_VAR ERROR_VARIABLE COMPILE_mcsc_VAR)
466
467   if(NOT COMPILE_mcsc_VAR)
468     message(STATUS "prog_AC_CHECK_MCSC.c is compilable")
469     execute_process(COMMAND ./testprog
470     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/
471     OUTPUT_VARIABLE var_compil)
472   else()
473     message(STATUS "prog_AC_CHECK_MCSC.c is not compilable. \nBuild command: ${MCSC_buildcmd}\nOutput\n${COMPILE_mcsc_VAR}")
474   endif()
475   file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
476
477   if(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
478     file(READ "${CMAKE_BINARY_DIR}/conftestval" mcsc)
479     STRING(REPLACE "\n" "" mcsc "${mcsc}")
480     if(mcsc)
481       set(mcsc "yes")
482       set(HAVE_UCONTEXT_H 1)
483     else()
484       set(mcsc "no")
485     endif()
486   else()
487     set(mcsc "no")
488   endif()
489
490   message(STATUS "mcsc: ${mcsc}")
491 ENDIF()
492
493 if(mcsc MATCHES "no" AND pthread)
494   if(HAVE_WINDOWS_H)
495     set(windows_context "yes")
496     set(IS_WINDOWS 1)
497   elseif(HAVE_WINDOWS_H)
498     message(FATAL_ERROR "no appropriate backend found")
499   endif()
500 endif()
501
502 #Only windows
503
504 if(WIN32)
505   if(NOT HAVE_WINDOWS_H)
506     message(FATAL_ERROR "no appropriate backend found windows")
507   endif()
508 endif()
509
510 if(windows_context MATCHES "yes")
511   message(STATUS "Context change to windows")
512 endif()
513
514 #If can have both context
515
516 if(mcsc)
517   set(CONTEXT_UCONTEXT 1)
518 endif()
519
520 if(pthread)
521   set(CONTEXT_THREADS 1)
522 endif()
523
524 ###############
525 ## GIT version check
526 ##
527 if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
528   execute_process(COMMAND git remote
529   COMMAND head -n 1
530   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
531   OUTPUT_VARIABLE remote
532   RESULT_VARIABLE ret
533   )
534   string(REPLACE "\n" "" remote "${remote}")
535   #message(STATUS "Git remote: ${remote}")
536   execute_process(COMMAND git config --get remote.${remote}.url
537   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
538   OUTPUT_VARIABLE url
539   RESULT_VARIABLE ret
540   )
541   string(REPLACE "\n" "" url "${url}")
542   #message(STATUS "Git url: ${url}")
543   if(url)
544     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=oneline --abbrev-commit -1
545     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
546     OUTPUT_VARIABLE GIT_VERSION
547     RESULT_VARIABLE ret
548     )
549     string(REPLACE "\n" "" GIT_VERSION "${GIT_VERSION}")
550     message(STATUS "Git version: ${GIT_VERSION}")
551     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --pretty=format:%ai .
552     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
553     OUTPUT_VARIABLE GIT_DATE
554     RESULT_VARIABLE ret
555     )
556     string(REPLACE "\n" "" GIT_DATE "${GIT_DATE}")
557     message(STATUS "Git date: ${GIT_DATE}")
558     string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
559     
560     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=format:%H -1
561                     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
562                     OUTPUT_VARIABLE SIMGRID_GITHASH
563                     RESULT_VARIABLE ret
564                     )
565     string(REPLACE "\n" "" SIMGRID_GITHASH "${SIMGRID_GITHASH}")
566                     
567   endif()
568 elseif(EXISTS ${CMAKE_HOME_DIRECTORY}/.gitversion)
569   FILE(STRINGS ${CMAKE_HOME_DIRECTORY}/.gitversion GIT_VERSION)
570 endif()
571
572 if(release)
573   set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING}\\nRelease build")
574 else()
575   set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING}\\nDevelopment build")
576 endif()
577 if(GIT_VERSION)
578   set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING} at commit ${GIT_VERSION}")
579 endif()
580 if(GIT_DATE)
581   set(SIMGRID_VERSION_STRING "${SIMGRID_VERSION_STRING} (${GIT_DATE})")
582 endif()
583 #--------------------------------------------------------------------------------------------------
584
585 set(makecontext_CPPFLAGS_2 "")
586 if(HAVE_MAKECONTEXT OR WIN32)
587   set(makecontext_CPPFLAGS "-DTEST_makecontext")
588   if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
589     set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE")
590   endif()
591
592   if(WIN32)
593     if(ARCH_32_BITS)
594       set(makecontext_CPPFLAGS "-DTEST_makecontext -D_I_X86_")
595     else()
596       set(makecontext_CPPFLAGS "-DTEST_makecontext -D_AMD64_")
597     endif()
598     set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt")
599   endif()
600
601   file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
602
603   if(CMAKE_CROSSCOMPILING)
604     set(RUN_makecontext_VAR "cross")
605     set(COMPILE_makecontext_VAR "cross")
606   else()
607     try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
608       ${CMAKE_BINARY_DIR}
609       ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c
610       COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}"
611       )
612   endif()
613
614   if(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
615     file(READ ${CMAKE_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
616     string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
617     string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
618     string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}")
619     string(REPLACE "," "" makecontext_addr "${MAKECONTEXT_ADDR}")
620     string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}")
621     set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
622     set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
623     message(STATUS "${pth_skaddr_makecontext}")
624     message(STATUS "${pth_sksize_makecontext}")
625   else()
626     # message(FATAL_ERROR "makecontext is not compilable")
627   endif()
628 endif()
629
630 #--------------------------------------------------------------------------------------------------
631
632 ### check for stackgrowth
633 if (NOT CMAKE_CROSSCOMPILING)
634   try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
635     ${CMAKE_BINARY_DIR}
636     ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c
637     RUN_OUTPUT_VARIABLE stack
638     )
639 endif()
640 if("${stack}" STREQUAL "down")
641   set(PTH_STACKGROWTH "-1")
642 elseif("${stack}" STREQUAL "up")
643   set(PTH_STACKGROWTH "1")
644 else()
645   if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
646     set(PTH_STACKGROWTH "-1")
647   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
648     set(PTH_STACKGROWTH "-1")
649   else()
650     message(ERROR "Could not figure the stack direction.")
651   endif()
652 endif()
653
654 ###############
655 ## System checks
656 ##
657
658 #SG_CONFIGURE_PART([System checks...])
659 #AC_PROG_CC(xlC gcc cc) -auto
660 #AM_SANITY_CHECK -auto
661
662 #AC_PROG_MAKE_SET
663
664 #AC_CHECK_VA_COPY
665
666 set(diff_va "va_copy((d),(s))"
667   "VA_COPY((d),(s))"
668   "__va_copy((d),(s))"
669   "__builtin_va_copy((d),(s))"
670   "do { (d) = (s)\; } while (0)"
671   "do { *(d) = *(s)\; } while (0)"
672   "memcpy((void *)&(d), (void *)&(s), sizeof(s))"
673   "memcpy((void *)(d), (void *)(s), sizeof(*(s)))"
674   )
675
676 foreach(fct ${diff_va})
677   write_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c" "#include <stdlib.h>
678 #include <stdarg.h>
679 #include <string.h>
680 #define DO_VA_COPY(d,s) ${fct}
681 void test(char *str, ...)
682 {
683   va_list ap, ap2;
684   int i;
685   va_start(ap, str);
686   DO_VA_COPY(ap2, ap);
687   for (i = 1; i <= 9; i++) {
688     int k = (int)va_arg(ap, int);
689     if (k != i)
690       abort();
691   }
692   DO_VA_COPY(ap, ap2);
693   for (i = 1; i <= 9; i++) {
694     int k = (int)va_arg(ap, int);
695     if (k != i)
696       abort();
697   }
698   va_end(ap);
699 }
700 int main(void)
701 {
702   test(\"test\", 1, 2, 3, 4, 5, 6, 7, 8, 9);
703   exit(0);
704 }"
705     )
706
707   execute_process(
708   COMMAND ${CMAKE_C_COMPILER} "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c"
709   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
710   RESULT_VARIABLE COMPILE_VA_NULL_VAR
711   OUTPUT_QUIET
712   ERROR_QUIET
713   )
714
715   if(NOT COMPILE_VA_NULL_VAR)
716     string(REGEX REPLACE "\;" "" fctbis ${fct})
717     if(${fctbis} STREQUAL "va_copy((d),(s))")
718       set(HAVE_VA_COPY 1)
719       set(ac_cv_va_copy "C99")
720       set(__VA_COPY_USE_C99 "va_copy((d),(s))")
721     endif()
722
723     if(${fctbis} STREQUAL "VA_COPY((d),(s))")
724       set(ac_cv_va_copy "GCM")
725       set(__VA_COPY_USE_GCM "VA_COPY((d),(s))")
726     endif()
727
728     if(${fctbis} STREQUAL "__va_copy((d),(s))")
729       set(ac_cv_va_copy "GCH")
730       set(__VA_COPY_USE_GCH "__va_copy((d),(s))")
731     endif()
732
733     if(${fctbis} STREQUAL "__builtin_va_copy((d),(s))")
734       set(ac_cv_va_copy "GCB")
735       set(__VA_COPY_USE_GCB "__builtin_va_copy((d),(s))")
736     endif()
737
738     if(${fctbis} STREQUAL "do { (d) = (s) } while (0)")
739       set(ac_cv_va_copy "ASS")
740       set(__VA_COPY_USE_ASS "do { (d) = (s); } while (0)")
741     endif()
742
743     if(${fctbis} STREQUAL "do { *(d) = *(s) } while (0)")
744       set(ac_cv_va_copy "ASP")
745       set(__VA_COPY_USE_ASP "do { *(d) = *(s); } while (0)")
746     endif()
747
748     if(${fctbis} STREQUAL "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
749       set(ac_cv_va_copy "CPS")
750       set(__VA_COPY_USE_CPS "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
751     endif()
752
753     if(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
754       set(ac_cv_va_copy "CPP")
755       set(__VA_COPY_USE_CPP "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
756     endif()
757
758     if(NOT STATUS_OK)
759       set(__VA_COPY_USE "__VA_COPY_USE_${ac_cv_va_copy}(d, s)")
760     endif()
761     set(STATUS_OK "1")
762
763   endif()
764
765 endforeach(fct ${diff_va})
766
767 #--------------------------------------------------------------------------------------------------
768 ### check for a working snprintf
769 if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
770   if(WIN32)
771     #set(HAVE_SNPRINTF 1)
772     #set(HAVE_VSNPRINTF 1)
773   endif()
774
775   if(CMAKE_CROSSCOMPILING)
776     set(RUN_SNPRINTF_FUNC "cross")
777     #set(PREFER_PORTABLE_SNPRINTF 1)
778   else()
779     try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR
780       ${CMAKE_BINARY_DIR}
781       ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_snprintf.c
782       )
783   endif()
784
785   if(CMAKE_CROSSCOMPILING)
786     set(RUN_VSNPRINTF_FUNC "cross")
787     set(PREFER_PORTABLE_VSNPRINTF 1)
788   else()
789     try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR
790       ${CMAKE_BINARY_DIR}
791       ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_vsnprintf.c
792       )
793   endif()
794
795   set(PREFER_PORTABLE_SNPRINTF 0)
796   if(RUN_VSNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
797     set(PREFER_PORTABLE_SNPRINTF 1)
798   endif()
799   if(RUN_SNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
800     set(PREFER_PORTABLE_SNPRINTF 1)
801   endif()
802 endif()
803
804 ### check for asprintf function familly
805 if(HAVE_ASPRINTF)
806   SET(simgrid_need_asprintf "")
807   SET(NEED_ASPRINTF 0)
808 else()
809   SET(simgrid_need_asprintf "#define SIMGRID_NEED_ASPRINTF 1")
810   SET(NEED_ASPRINTF 1)
811 endif()
812
813 if(HAVE_VASPRINTF)
814   SET(simgrid_need_vasprintf "")
815   SET(NEED_VASPRINTF 0)
816 else()
817   SET(simgrid_need_vasprintf "#define SIMGRID_NEED_VASPRINTF 1")
818   SET(NEED_VASPRINTF 1)
819 endif()
820
821 ### check for addr2line
822
823 find_path(ADDR2LINE NAMES addr2line     PATHS NO_DEFAULT_PATHS  )
824 if(ADDR2LINE)
825   set(ADDR2LINE "${ADDR2LINE}/addr2line")
826 endif()
827
828 ### Check if OSX can compile with ucontext (with gcc 4.[1-5] it is broken)
829 if(APPLE)
830   if(APPLE_NEED_GCC_VERSION GREATER COMPILER_C_VERSION_MAJOR_MINOR)
831     message(STATUS "Ucontext can't be used with this version of gcc (must be greater than 4.5)")
832     set(HAVE_UCONTEXT_H 0)
833   endif()
834 endif()
835
836 ### File to create
837
838 configure_file("${CMAKE_HOME_DIRECTORY}/src/context_sysv_config.h.in"
839   "${CMAKE_BINARY_DIR}/src/context_sysv_config.h" @ONLY IMMEDIATE)
840
841 SET( CMAKEDEFINE "#cmakedefine" )
842 configure_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/src/internal_config.h.in" "${CMAKE_BINARY_DIR}/src/internal_config.h" @ONLY IMMEDIATE)
843 configure_file("${CMAKE_BINARY_DIR}/src/internal_config.h" "${CMAKE_BINARY_DIR}/src/internal_config.h" @ONLY IMMEDIATE)
844 configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid_config.h.in" "${CMAKE_BINARY_DIR}/include/simgrid_config.h" @ONLY IMMEDIATE)
845
846 set(top_srcdir "${CMAKE_HOME_DIRECTORY}")
847 set(srcdir "${CMAKE_HOME_DIRECTORY}/src")
848 set(bindir "${CMAKE_BINARY_DIR}")
849
850 ### Script used when simgrid is installed
851 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
852 set(includeflag "-I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/smpi")
853 set(includedir "${CMAKE_INSTALL_PREFIX}/include")
854 set(libdir ${exec_prefix}/lib)
855 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_INSTALL_PREFIX}/lib")
856 if(GTNETS_LIB_PATH)
857   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${GTNETS_LIB_PATH}")
858 endif()
859 if(HAVE_NS3_LIB)
860   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${HAVE_NS3_LIB}")
861 endif()
862 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
863
864 file(READ ${CMAKE_HOME_DIRECTORY}/src/smpi/smpitools.sh SMPITOOLS_SH)
865 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/mpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/mpif.h @ONLY)
866 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/bin/smpicc @ONLY)
867 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicxx.in ${CMAKE_BINARY_DIR}/bin/smpicxx @ONLY)
868 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpiff.in ${CMAKE_BINARY_DIR}/bin/smpiff @ONLY)
869 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpif90.in ${CMAKE_BINARY_DIR}/bin/smpif90 @ONLY)
870 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_BINARY_DIR}/bin/smpirun @ONLY)
871
872 ### Script used when simgrid is compiling
873 set(includeflag "-I${CMAKE_HOME_DIRECTORY}/include -I${CMAKE_HOME_DIRECTORY}/include/smpi")
874 set(includeflag "${includeflag} -I${CMAKE_BINARY_DIR}/include -I${CMAKE_BINARY_DIR}/include/smpi")
875 set(includedir "${CMAKE_HOME_DIRECTORY}/include")
876 set(exec_prefix "${CMAKE_BINARY_DIR}/smpi_script/")
877 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_BINARY_DIR}/lib")
878 if(GTNETS_LIB_PATH)
879   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${GTNETS_LIB_PATH}")
880 endif()
881 if(HAVE_NS3_LIB)
882   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${HAVE_NS3_LIB}")
883 endif()
884 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
885 set(libdir "${CMAKE_BINARY_DIR}/lib")
886
887 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc @ONLY)
888 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicxx.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx @ONLY)
889 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpiff.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpiff @ONLY)
890 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpif90.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpif90 @ONLY)
891 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun @ONLY)
892
893 set(top_builddir ${CMAKE_HOME_DIRECTORY})
894
895 if(NOT WIN32)
896   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc)
897   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicxx)
898   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff)
899   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif90)
900   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun)
901   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc)
902   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx)
903   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpiff)
904   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpif90)
905   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun)
906 endif()
907
908 set(generated_headers_to_install
909   ${CMAKE_CURRENT_BINARY_DIR}/include/smpi/mpif.h
910   ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid_config.h
911   )
912
913 set(generated_headers
914   ${CMAKE_CURRENT_BINARY_DIR}/src/context_sysv_config.h
915   ${CMAKE_CURRENT_BINARY_DIR}/src/internal_config.h
916   )
917
918 set(generated_files_to_clean
919   ${generated_headers}
920   ${generated_headers_to_install}
921   ${CMAKE_BINARY_DIR}/bin/smpicc
922   ${CMAKE_BINARY_DIR}/bin/smpicxx
923   ${CMAKE_BINARY_DIR}/bin/smpiff
924   ${CMAKE_BINARY_DIR}/bin/smpif90
925   ${CMAKE_BINARY_DIR}/bin/smpirun
926   ${CMAKE_BINARY_DIR}/bin/colorize
927   ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
928   ${CMAKE_BINARY_DIR}/examples/smpi/tracing/smpi_traced.trace
929   )
930
931 if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
932   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions0.txt COPYONLY)
933   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions1.txt COPYONLY)
934   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_allReduce.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allReduce.txt COPYONLY)
935   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_barrier.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_barrier.txt COPYONLY)
936   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_bcast.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_bcast.txt COPYONLY)
937   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_with_isend.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_with_isend.txt COPYONLY)
938   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_alltoall.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoall.txt COPYONLY)
939   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_alltoallv.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoallv.txt COPYONLY)
940   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_waitall.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_waitall.txt COPYONLY)
941   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_reducescatter.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_reducescatter.txt COPYONLY)
942   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_gather.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_gather.txt COPYONLY)
943   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_allgatherv.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allgatherv.txt COPYONLY)
944   configure_file(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/hostfile ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile COPYONLY)
945   
946   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/description_file ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/description_file COPYONLY)
947   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/README ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/README COPYONLY)
948   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/smpi_replay.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/smpi_replay.txt COPYONLY)
949   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt COPYONLY)
950   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt COPYONLY)
951   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt COPYONLY)
952   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt COPYONLY)
953   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt COPYONLY)
954   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt COPYONLY)
955   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt COPYONLY)
956   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt COPYONLY)
957   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt COPYONLY)
958   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt COPYONLY)
959   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt COPYONLY)
960   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt COPYONLY)
961   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt COPYONLY)
962   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt COPYONLY)
963   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt COPYONLY)
964   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt COPYONLY)
965   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt COPYONLY)
966   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt COPYONLY)
967   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt COPYONLY)
968   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt COPYONLY)
969   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt COPYONLY)
970   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt COPYONLY)
971   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt COPYONLY)
972   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt COPYONLY)
973   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt COPYONLY)
974   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt COPYONLY)
975   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt COPYONLY)
976   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt COPYONLY)
977   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt COPYONLY)
978   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt COPYONLY)
979   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt COPYONLY)
980   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt COPYONLY)
981
982   set(generated_files_to_clean
983     ${generated_files_to_clean}
984     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions0.txt
985     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions1.txt
986     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allReduce.txt
987     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_barrier.txt
988     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_bcast.txt
989     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_with_isend.txt
990     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoall.txt
991     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoallv.txt
992     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_waitall.txt
993     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_gather.txt
994     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allgatherv.txt
995     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_reducescatter.txt
996     ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile
997     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/description_file
998     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/README
999     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/smpi_replay.txt
1000     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt
1001     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt
1002     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt
1003     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt
1004     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt
1005     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt
1006     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt
1007     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt
1008     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt
1009     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt
1010     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt
1011     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt
1012     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt
1013     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt
1014     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt
1015     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt
1016     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt
1017     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt
1018     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt
1019     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt
1020     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt
1021     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt
1022     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt
1023     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt
1024     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt
1025     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt
1026     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt
1027     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt
1028     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt
1029     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt
1030     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt
1031     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt
1032     )
1033 endif()
1034
1035 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
1036   "${generated_files_to_clean}")
1037
1038 IF(${ARCH_32_BITS})
1039   set(WIN_ARCH "32")
1040 ELSE()
1041   set(WIN_ARCH "64")
1042 ENDIF()
1043 configure_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/src/simgrid.nsi.in" "${CMAKE_BINARY_DIR}/simgrid.nsi" @ONLY IMMEDIATE)