Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : new function MC_diff to display all informations about a system state
[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 IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
11     IF(${ARCH_32_BITS})
12         set(PROCESSOR_i686 1)
13         set(SIMGRID_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
14         message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
15     ELSE(${ARCH_32_BITS})
16         message(STATUS "System processor: amd64")
17         set(SIMGRID_SYSTEM_PROCESSOR "amd64")
18         set(PROCESSOR_x86_64 1)
19         set(PROCESSOR_i686 0)
20     ENDIF(${ARCH_32_BITS})          
21     set(HAVE_RAWCTX 1)
22     
23 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
24     message(STATUS "System processor: alpha")
25     
26 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
27     # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
28     message(STATUS "System processor: arm")
29     
30 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
31     # mips* machines are bi-endian mostly so processor does not tell
32     # endianess of the underlying system.
33     message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
34     
35 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
36     message(STATUS "System processor: ppc64")
37     
38 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
39     message(STATUS "System processor: ppc")
40     
41 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
42     # Both flavours can run on the same processor
43     message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
44     
45 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
46     message(STATUS "System processor: parisc" "parisc64")
47     
48 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
49     # s390 binaries can run on s390x machines
50     message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
51     
52 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
53     message(STATUS "System processor: sh")
54     
55 ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") #PROCESSOR NOT fIND
56     message(STATUS "PROCESSOR NOT FOUND: ${CMAKE_SYSTEM_PROCESSOR}")
57     
58 ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
59
60 message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
61
62 include(CheckFunctionExists)
63 include(CheckTypeSize)
64 include(CheckIncludeFile)
65 include(CheckIncludeFiles)
66 include(CheckLibraryExists)
67 include(TestBigEndian)
68 TEST_BIG_ENDIAN(BIGENDIAN)
69
70 include(FindGraphviz)
71 include(FindPCRE)
72
73 set(HAVE_GTNETS 0)
74 if(enable_gtnets)       
75         include(FindGTnets)
76 endif(enable_gtnets)
77 if(enable_smpi)
78         include(FindF2c)
79         if(HAVE_F2C_H)
80         SET(HAVE_SMPI 1)
81     endif(HAVE_F2C_H)
82 endif(enable_smpi)
83 if(enable_lua)
84         include(FindLua51Simgrid)
85 endif(enable_lua)
86 set(HAVE_NS3 0)
87 if(enable_ns3)
88         include(FindNS3)
89 endif(enable_ns3)
90
91 # Checks for header libraries functions.
92 CHECK_LIBRARY_EXISTS(pthread    pthread_create                  "" pthread)
93 CHECK_LIBRARY_EXISTS(pthread    sem_init                                "" HAVE_SEM_INIT_LIB)
94 CHECK_LIBRARY_EXISTS(pthread    sem_open                                "" HAVE_SEM_OPEN_LIB)
95 CHECK_LIBRARY_EXISTS(pthread    sem_timedwait                   "" HAVE_SEM_TIMEDWAIT_LIB)
96 CHECK_LIBRARY_EXISTS(pthread    pthread_mutex_timedlock "" HAVE_MUTEX_TIMEDLOCK_LIB)
97 CHECK_LIBRARY_EXISTS(rt                 clock_gettime                   "" HAVE_POSIX_GETTIME)
98
99 CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME)
100 CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
101 CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H)
102 CHECK_INCLUDE_FILE("valgrind/valgrind.h" HAVE_VALGRIND_VALGRIND_H)
103 CHECK_INCLUDE_FILE("socket.h" HAVE_SOCKET_H)
104 CHECK_INCLUDE_FILE("sys/socket.h" HAVE_SYS_SOCKET_H)
105 CHECK_INCLUDE_FILE("stat.h" HAVE_STAT_H)
106 CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
107 CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
108 CHECK_INCLUDE_FILE("winsock.h" HAVE_WINSOCK_H)
109 CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
110 CHECK_INCLUDE_FILE("WinDef.h" HAVE_WINDEF_H)
111 CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
112 CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
113 CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
114 CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
115 CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
116 CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
117 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
118 CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
119 CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
120 CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
121 CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
122 CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
123 CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
124 CHECK_INCLUDE_FILE("stdio.h" HAVE_STDIO_H)
125 CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
126
127 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
128 CHECK_FUNCTION_EXISTS(usleep HAVE_USLEEP)
129 CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
130 CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
131 CHECK_FUNCTION_EXISTS(readv HAVE_READV)
132 CHECK_FUNCTION_EXISTS(popen HAVE_POPEN)
133 CHECK_FUNCTION_EXISTS(signal HAVE_SIGNAL)
134 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
135 CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
136 CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF)
137 CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF)
138 CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT)
139 CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
140 CHECK_FUNCTION_EXISTS(mergesort HAVE_MERGESORT)
141
142 #Check if __thread is defined
143 execute_process(
144 COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_thread_storage.c"
145 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
146 OUTPUT_VARIABLE HAVE_thread_storage_run
147 )
148
149 if(HAVE_thread_storage_run)
150         set(HAVE_THREAD_LOCAL_STORAGE 0)
151 else(HAVE_thread_storage_run)
152         set(HAVE_THREAD_LOCAL_STORAGE 1)
153 endif(HAVE_thread_storage_run)
154
155 # Our usage of mmap is Linux-specific (flag MAP_ANONYMOUS), but kFreeBSD uses a GNU libc
156 IF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND NOT "${CMAKE_SYSTEM}" MATCHES "GNU")
157   SET(HAVE_MMAP 0)
158   message(STATUS "Warning: MMAP is thought as non functional on this architecture (${CMAKE_SYSTEM})")
159 ENDIF(NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND NOT "${CMAKE_SYSTEM}" MATCHES "GNU")
160
161 if(WIN32) #THOSE FILES ARE FUNCTIONS ARE NOT DETECTED BUT THEY SHOULD...
162     set(HAVE_UCONTEXT_H 1)
163     set(HAVE_MAKECONTEXT 1)
164     set(HAVE_SNPRINTF 1)
165     set(HAVE_VSNPRINTF 1)
166 endif(WIN32)
167
168 set(CONTEXT_UCONTEXT 0)
169 SET(CONTEXT_THREADS 0)
170 SET(HAVE_TRACING 0)
171
172 if(enable_tracing)
173         SET(HAVE_TRACING 1)
174 endif(enable_tracing)
175
176 if(enable_jedule)
177         SET(HAVE_JEDULE 1)
178 endif(enable_jedule)
179
180 if(enable_latency_bound_tracking)
181         SET(HAVE_LATENCY_BOUND_TRACKING 1)
182 else(enable_latency_bound_tracking)
183   if(enable_gtnets)
184     message(STATUS "Warning : Turning latency_bound_tracking to ON because GTNeTs is ON")
185     SET(enable_latency_bound_tracking ON)
186     SET(HAVE_LATENCY_BOUND_TRACKING 1)
187   else(enable_gtnets)
188     SET(HAVE_LATENCY_BOUND_TRACKING 0)
189   endif(enable_gtnets)
190 endif(enable_latency_bound_tracking)
191
192 if(enable_model-checking AND HAVE_MMAP)
193         SET(HAVE_MC 1)
194         SET(MMALLOC_WANT_OVERIDE_LEGACY 1)
195 else(enable_model-checking AND HAVE_MMAP)
196         SET(HAVE_MC 0)
197         SET(MMALLOC_WANT_OVERIDE_LEGACY 0)
198 endif(enable_model-checking AND HAVE_MMAP)
199
200 #--------------------------------------------------------------------------------------------------
201 ### Check for some architecture dependent values
202 CHECK_TYPE_SIZE(int SIZEOF_INT)
203 CHECK_TYPE_SIZE(void* SIZEOF_VOIDP)
204
205
206 #--------------------------------------------------------------------------------------------------
207 ### Initialize of CONTEXT THREADS
208
209 if(pthread)
210         set(pthread 1)
211 elseif(pthread)
212         set(pthread 0)
213 endif(pthread)
214
215 if(pthread)
216         ### Test that we have a way to create semaphores
217
218     if(HAVE_SEM_OPEN_LIB)
219     
220         exec_program(
221         "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_open.c -lpthread -o testprog"
222         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
223         OUTPUT_VARIABLE HAVE_SEM_OPEN_compil
224         )
225     
226         if(HAVE_SEM_OPEN_compil)
227                 set(HAVE_SEM_OPEN 0)
228                 message(STATUS "Warning: sem_open not compilable")
229                 message(STATUS "HAVE_SEM_OPEN_comp_output: ${HAVE_SEM_OPEN_comp_output}")       
230         else(HAVE_SEM_OPEN_compil)
231                 set(HAVE_SEM_OPEN 1)
232             message(STATUS "sem_open is compilable")
233         endif(HAVE_SEM_OPEN_compil)
234         
235         exec_program("${CMAKE_BINARY_DIR}/testprog" RETURN_VALUE HAVE_SEM_OPEN_run OUTPUT_VARIABLE var_compil)
236         file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
237         
238         if(NOT HAVE_SEM_OPEN_run)
239             set(HAVE_SEM_OPEN 1)
240             message(STATUS "sem_open is executable")
241         else(NOT HAVE_SEM_OPEN_run)
242                 set(HAVE_SEM_OPEN 0)
243             message(STATUS "Warning: sem_open not executable")          
244         endif(NOT HAVE_SEM_OPEN_run)    
245     
246     else(HAVE_SEM_OPEN_LIB)
247                 set(HAVE_SEM_OPEN 0)
248         endif(HAVE_SEM_OPEN_LIB)
249
250         if(HAVE_SEM_INIT_LIB)
251         exec_program(
252         "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_init.c -lpthread -o testprog"
253         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
254         OUTPUT_VARIABLE HAVE_SEM_INIT_compil
255         )
256     
257         if(HAVE_SEM_INIT_compil)
258                 set(HAVE_SEM_INIT 0)
259                 message(STATUS "Warning: sem_init not compilable")
260                 message(STATUS "HAVE_SEM_INIT_comp_output: ${HAVE_SEM_OPEN_comp_output}")       
261         else(HAVE_SEM_INIT_compil)
262                 set(HAVE_SEM_INIT 1)
263             message(STATUS "sem_init is compilable")
264         endif(HAVE_SEM_INIT_compil)
265
266         exec_program("${CMAKE_BINARY_DIR}/testprog" RETURN_VALUE HAVE_SEM_INIT_run OUTPUT_VARIABLE var_compil)
267         file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
268         
269         if(NOT HAVE_SEM_INIT_run)
270             set(HAVE_SEM_INIT 1)
271             message(STATUS "sem_init is executable")
272         else(NOT HAVE_SEM_INIT_run)
273                 set(HAVE_SEM_INIT 0)
274             message(STATUS "Warning: sem_init not executable")
275         endif(NOT HAVE_SEM_INIT_run)    
276         endif(HAVE_SEM_INIT_LIB)
277
278         if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
279                 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).")
280         endif(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
281
282         ### Test that we have a way to timewait for semaphores
283
284         if(HAVE_SEM_TIMEDWAIT_LIB)
285
286         execute_process(
287         COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_sem_timedwait.c -lpthread"
288         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
289         OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run
290         )
291         
292                 if(HAVE_SEM_TIMEDWAIT_run)
293                         set(HAVE_SEM_TIMEDWAIT 0)
294                         message(STATUS "timedwait not compilable")
295                 else(HAVE_SEM_TIMEDWAIT_run)
296                         set(HAVE_SEM_TIMEDWAIT 1)
297             message(STATUS "timedwait is compilable")
298                 endif(HAVE_SEM_TIMEDWAIT_run)
299         endif(HAVE_SEM_TIMEDWAIT_LIB)
300
301         ### HAVE_MUTEX_TIMEDLOCK
302
303         if(HAVE_MUTEX_TIMEDLOCK_LIB)
304
305         execute_process(
306         COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_mutex_timedlock.c -lpthread"
307         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
308         OUTPUT_VARIABLE HAVE_MUTEX_TIMEDLOCK_run
309         )
310
311                 if(HAVE_MUTEX_TIMEDLOCK_run)
312                         set(HAVE_MUTEX_TIMEDLOCK 0)
313                         message(STATUS "timedlock not compilable")
314                 else(HAVE_MUTEX_TIMEDLOCK_run)
315                         message(STATUS "timedlock is compilable")
316                         set(HAVE_MUTEX_TIMEDLOCK 1)
317                 endif(HAVE_MUTEX_TIMEDLOCK_run)
318         endif(HAVE_MUTEX_TIMEDLOCK_LIB)
319 endif(pthread)
320
321 # AC_CHECK_MCSC(mcsc=yes, mcsc=no) 
322 set(mcsc_flags "")
323 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
324         set(mcsc_flags "-D_XOPEN_SOURCE")
325 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
326
327 if(WIN32)
328         set(mcsc_flags "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/include/xbt -I${CMAKE_HOME_DIRECTORY}/src/xbt")
329 endif(WIN32)
330
331 IF(CMAKE_CROSSCOMPILING)
332         IF(WIN32)
333                 set(windows_context "yes")
334                 set(IS_WINDOWS 1)       
335         ENDIF(WIN32)
336 ELSE(CMAKE_CROSSCOMPILING)
337     exec_program(
338                  "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c ${mcsc_flags} -o testprog"
339                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/
340                  OUTPUT_VARIABLE COMPILE_mcsc_VAR)
341
342     file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
343     if(NOT COMPILE_mcsc_VAR)
344         exec_program("${CMAKE_BINARY_DIR}/testprog" OUTPUT_VARIABLE var_compil)
345     endif(NOT COMPILE_mcsc_VAR)
346     file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
347     
348         if(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
349                 file(READ "${CMAKE_BINARY_DIR}/conftestval" mcsc)
350                 STRING(REPLACE "\n" "" mcsc "${mcsc}")
351                 if(mcsc)
352                         set(mcsc "yes")
353                         set(HAVE_UCONTEXT_H 1)
354                 else(mcsc)
355                         set(mcsc "no")
356                 endif(mcsc)
357     else(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
358                 set(mcsc "no")
359         endif(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
360         
361         message(STATUS "mcsc: ${mcsc}")   
362 ENDIF(CMAKE_CROSSCOMPILING)
363
364 if(mcsc MATCHES "no" AND pthread)
365         if(HAVE_WINDOWS_H)
366                 set(windows_context "yes")
367                 set(IS_WINDOWS 1)
368         elseif(HAVE_WINDOWS_H)
369                 message(FATAL_ERROR "no appropriate backend found")
370         endif(HAVE_WINDOWS_H)
371 endif(mcsc MATCHES "no" AND pthread)
372
373 #Only windows
374
375 if(WIN32)
376         if(NOT HAVE_WINDOWS_H)
377                 message(FATAL_ERROR "no appropriate backend found windows")
378         endif(NOT HAVE_WINDOWS_H)
379 endif(WIN32)
380
381 if(windows_context MATCHES "yes")
382         message(STATUS "Context change to windows")
383 endif(windows_context MATCHES "yes")
384
385 #If can have both context
386
387 if(mcsc)
388         set(CONTEXT_UCONTEXT 1)
389 endif(mcsc)
390
391 if(pthread)
392         set(CONTEXT_THREADS 1)
393 endif(pthread)
394
395
396 ###############
397 ## SVN version check
398 ##
399 if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32)
400 exec_program("git remote | head -n 1" OUTPUT_VARIABLE remote RETURN_VALUE ret)
401 exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
402
403 if(url)
404         exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
405         message(STATUS "Git version: ${GIT_VERSION}")
406         exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
407         message(STATUS "Git date: ${GIT_DATE}")
408         string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
409         STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
410         STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
411         STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
412 endif(url)
413 endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32)
414
415 ###################################
416 ## SimGrid and GRAS specific checks
417 ##
418
419 IF(NOT CMAKE_CROSSCOMPILING)
420 # Check architecture signature begin
421 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
422         ${CMAKE_BINARY_DIR}
423         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_ARCH.c
424         RUN_OUTPUT_VARIABLE var1
425         )
426 if(BIGENDIAN)
427   set(val_big "B${var1}")
428   set(GRAS_BIGENDIAN 1)
429 else(BIGENDIAN)
430   set(val_big "l${var1}")
431   set(GRAS_BIGENDIAN 0)
432 endif(BIGENDIAN)
433
434 # The syntax of this magic string is given in src/gras/DataDesc/ddt_convert.c
435 # It kinda matches the values that the gras_arch_desc_t structure can take
436
437 # Basically, the syntax is one char l or B for endianness (little or Big)
438 #   then there is a bunch of blocks separated by _.  
439 # C block is for char, I block for integers, P block for pointers and
440 #   D block for floating points
441 # For each block there is an amount of chuncks separated by :, each of
442 #   them describing a data size. For example there is only one chunk
443 #   in the char block, because no architecture provide several sizes
444 #   of chars. In integer block, there is 4 chunks: "short int", "int",
445 #   "long int", "long long int". There is 2 pointer chunks for data
446 #   pointers and pointers on functions (thanks to the AMD64 madness).
447 #   Thee two floating points chuncks are for "float" and "double".
448 # Each chunk is of the form datasize/minimal_alignment_size
449
450 # These informations are used to convert a data stream from one
451 #    formalism to another. Only the GRAS_ARCH is transfered in the
452 #    stream, and it it of cruxial importance to keep these detection
453 #    information here synchronized with the data hardcoded in the
454 #    source in src/gras/DataDesc/ddt_convert.c 
455
456 # If you add something here (like a previously unknown architecture),
457 #    please add it to the source code too. 
458 # Please do not modify stuff here since it'd break the GRAS protocol.
459 #     If you really need to change stuff, please also bump
460 #    GRAS_PROTOCOL_VERSION in src/gras/Msg/msg_interface.h
461
462 SET(GRAS_THISARCH "none")
463
464 if(val_big MATCHES "l_C:1/1:_I:2/1:4/1:4/1:8/1:_P:4/1:4/1:_D:4/1:8/1:")
465         #gras_arch=0; gras_size=32; gras_arch_name=little32_1;
466         SET(GRAS_ARCH_32_BITS 1)
467         SET(GRAS_THISARCH 0)
468 endif(val_big MATCHES "l_C:1/1:_I:2/1:4/1:4/1:8/1:_P:4/1:4/1:_D:4/1:8/1:")
469 if(val_big MATCHES "l_C:1/1:_I:2/2:4/2:4/2:8/2:_P:4/2:4/2:_D:4/2:8/2:")
470         #gras_arch=1; gras_size=32; gras_arch_name=little32_2;
471         SET(GRAS_ARCH_32_BITS 1)
472         SET(GRAS_THISARCH 1)
473 endif(val_big MATCHES "l_C:1/1:_I:2/2:4/2:4/2:8/2:_P:4/2:4/2:_D:4/2:8/2:")
474 if(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/4:_P:4/4:4/4:_D:4/4:8/4:") 
475         #gras_arch=2; gras_size=32; gras_arch_name=little32_4;
476         SET(GRAS_ARCH_32_BITS 1)
477         SET(GRAS_THISARCH 2)
478 endif(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/4:_P:4/4:4/4:_D:4/4:8/4:")
479 if(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/8:") 
480         #gras_arch=3; gras_size=32; gras_arch_name=little32_8;
481         SET(GRAS_ARCH_32_BITS 1)
482         SET(GRAS_THISARCH 3)
483 endif(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/8:") 
484 if(val_big MATCHES "l_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/8:") 
485         #gras_arch=4; gras_size=64; gras_arch_name=little64;
486         SET(GRAS_ARCH_32_BITS 0)
487         SET(GRAS_THISARCH 4)
488 endif(val_big MATCHES "l_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/8:")
489 if(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/8:_P:8/8:8/8:_D:4/4:8/8:") 
490         #gras_arch=5; gras_size=64; gras_arch_name=little64_2;
491         SET(GRAS_ARCH_32_BITS 0)
492         SET(GRAS_THISARCH 5)
493 endif(val_big MATCHES "l_C:1/1:_I:2/2:4/4:4/4:8/8:_P:8/8:8/8:_D:4/4:8/8:")
494
495 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/8:") 
496         #gras_arch=6; gras_size=32; gras_arch_name=big32_8;
497         SET(GRAS_ARCH_32_BITS 1)
498         SET(GRAS_THISARCH 6)
499 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/8:")
500 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/4:") 
501         #gras_arch=7; gras_size=32; gras_arch_name=big32_8_4;
502         SET(GRAS_ARCH_32_BITS 1)
503         SET(GRAS_THISARCH 7)
504 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/8:_P:4/4:4/4:_D:4/4:8/4:")
505 if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/4:_P:4/4:4/4:_D:4/4:8/4:") 
506         #gras_arch=8; gras_size=32; gras_arch_name=big32_4;
507         SET(GRAS_ARCH_32_BITS 1)
508         SET(GRAS_THISARCH 8)
509 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:4/4:8/4:_P:4/4:4/4:_D:4/4:8/4:")
510 if(val_big MATCHES "B_C:1/1:_I:2/2:4/2:4/2:8/2:_P:4/2:4/2:_D:4/2:8/2:") 
511         #gras_arch=9; gras_size=32; gras_arch_name=big32_2;
512         SET(GRAS_ARCH_32_BITS 1)
513         SET(GRAS_THISARCH 9)
514 endif(val_big MATCHES "B_C:1/1:_I:2/2:4/2:4/2:8/2:_P:4/2:4/2:_D:4/2:8/2:") 
515 if(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/8:") 
516         #gras_arch=10; gras_size=64; gras_arch_name=big64;
517         SET(GRAS_ARCH_32_BITS 0)
518         SET(GRAS_THISARCH 10)
519 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/8:")
520 if(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:") 
521         #gras_arch=11; gras_size=64; gras_arch_name=big64_8_4;
522         SET(GRAS_ARCH_32_BITS 0)
523         SET(GRAS_THISARCH 11)
524 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:") 
525
526 if(GRAS_THISARCH MATCHES "none")
527     message(STATUS "architecture: ${val_big}")
528     message(FATAL_ERROR "GRAS_THISARCH is empty: '${GRAS_THISARCH}'")  
529 endif(GRAS_THISARCH MATCHES "none")
530
531 # Check architecture signature end
532 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
533         ${CMAKE_BINARY_DIR}
534         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_CHECK_STRUCT_COMPACTION.c
535         RUN_OUTPUT_VARIABLE var2
536         )
537 separate_arguments(var2)
538 foreach(var_tmp ${var2})
539         set(${var_tmp} 1)
540 endforeach(var_tmp ${var2})
541
542 # Check for [SIZEOF_MAX]
543 try_run(RUN_SM_VAR COMPILE_SM_VAR
544         ${CMAKE_BINARY_DIR}
545         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_max_size.c
546         RUN_OUTPUT_VARIABLE var3
547         )
548 message(STATUS "SIZEOF_MAX ${var3}")
549 SET(SIZEOF_MAX ${var3})
550 ENDIF(NOT CMAKE_CROSSCOMPILING)
551
552 #--------------------------------------------------------------------------------------------------
553
554 set(makecontext_CPPFLAGS_2 "")
555 if(HAVE_MAKECONTEXT OR WIN32)
556         set(makecontext_CPPFLAGS "-DTEST_makecontext")
557         if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
558                 set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE")
559         endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
560         
561     if(WIN32)
562         if(ARCH_32_BITS)
563             set(makecontext_CPPFLAGS "-DTEST_makecontext")
564             else(ARCH_32_BITS)
565             set(makecontext_CPPFLAGS "-DTEST_makecontext -D_AMD64_")
566             endif(ARCH_32_BITS)
567             set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/include/xbt -I${CMAKE_HOME_DIRECTORY}/src/xbt")
568         endif(WIN32)
569
570     file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
571         
572         try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
573                 ${CMAKE_BINARY_DIR}
574                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c
575                 COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}"
576                 )
577
578     if(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
579         file(READ ${CMAKE_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
580         string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
581         string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
582         string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}")
583         string(REPLACE "," "" makecontext_addr "${MAKECONTEXT_ADDR}")
584         string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}")   
585         set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
586         set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
587         message(STATUS "${pth_skaddr_makecontext}")
588         message(STATUS "${pth_sksize_makecontext}")
589         else(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
590 #           message(FATAL_ERROR "makecontext is not compilable")
591         endif(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
592 endif(HAVE_MAKECONTEXT OR WIN32)
593
594 #--------------------------------------------------------------------------------------------------
595
596 ### check for stackgrowth
597 if (NOT CMAKE_CROSSCOMPILING)
598         try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
599                 ${CMAKE_BINARY_DIR}
600                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c
601                 )
602 file(READ "${CMAKE_BINARY_DIR}/conftestval" stack)
603 if(stack MATCHES "down")
604         set(PTH_STACKGROWTH "-1")
605 endif(stack MATCHES "down")
606 if(stack MATCHES "up")
607         set(PTH_STACKGROWTH "1")
608 endif(stack MATCHES "up")
609
610 endif(NOT CMAKE_CROSSCOMPILING)
611 ###############
612 ## System checks
613 ##
614
615 #SG_CONFIGURE_PART([System checks...])
616 #AC_PROG_CC(xlC gcc cc) -auto
617 #AM_SANITY_CHECK -auto
618
619 #AC_PROG_MAKE_SET
620
621
622 #AC_PRINTF_NULL
623 try_run(RUN_PRINTF_NULL_VAR COMPILE_PRINTF_NULL_VAR
624         ${CMAKE_BINARY_DIR}
625         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_printf_null.c
626         )
627
628 if(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
629 SET(PRINTF_NULL_WORKING "0")
630 else(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
631 SET(PRINTF_NULL_WORKING "1")
632 endif(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
633
634 #AC_CHECK_VA_COPY
635
636 set(diff_va "va_copy((d),(s))"
637 "VA_COPY((d),(s))"
638 "__va_copy((d),(s))"
639 "__builtin_va_copy((d),(s))"
640 "do { (d) = (s)\; } while (0)"
641 "do { *(d) = *(s)\; } while (0)"
642 "memcpy((void *)&(d), (void *)&(s), sizeof(s))"
643 "memcpy((void *)(d), (void *)(s), sizeof(*(s)))"
644 )
645
646 foreach(fct ${diff_va})
647         write_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c" "#include <stdlib.h>
648         #include <stdarg.h>
649         #include <string.h>
650         #define DO_VA_COPY(d,s) ${fct}
651         void test(char *str, ...)
652         {
653             va_list ap, ap2;
654             int i;
655             va_start(ap, str);
656             DO_VA_COPY(ap2, ap);
657             for (i = 1; i <= 9; i++) {
658                 int k = (int)va_arg(ap, int);
659                 if (k != i)
660                     abort();
661             }
662             DO_VA_COPY(ap, ap2);
663             for (i = 1; i <= 9; i++) {
664                 int k = (int)va_arg(ap, int);
665                 if (k != i)
666                     abort();
667             }
668             va_end(ap);
669         }
670         int main(void)
671         {
672             test(\"test\", 1, 2, 3, 4, 5, 6, 7, 8, 9);
673             exit(0);
674         }"
675         )
676         try_compile(COMPILE_VA_NULL_VAR
677         ${CMAKE_BINARY_DIR}
678         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c
679         )
680         if(COMPILE_VA_NULL_VAR)
681                 string(REGEX REPLACE "\;" "" fctbis ${fct})
682                 if(${fctbis} STREQUAL "va_copy((d),(s))")
683                         set(HAVE_VA_COPY 1)
684                         set(ac_cv_va_copy "C99")
685                         set(__VA_COPY_USE_C99 "va_copy((d),(s))")       
686                 endif(${fctbis} STREQUAL "va_copy((d),(s))")
687
688                 if(${fctbis} STREQUAL "VA_COPY((d),(s))")
689                         set(ac_cv_va_copy "GCM")
690                         set(__VA_COPY_USE_GCM "VA_COPY((d),(s))")
691                 endif(${fctbis} STREQUAL "VA_COPY((d),(s))")
692
693                 if(${fctbis} STREQUAL "__va_copy((d),(s))")
694                         set(ac_cv_va_copy "GCH")
695                         set(__VA_COPY_USE_GCH "__va_copy((d),(s))")
696                 endif(${fctbis} STREQUAL "__va_copy((d),(s))")
697
698                 if(${fctbis} STREQUAL "__builtin_va_copy((d),(s))")
699                         set(ac_cv_va_copy "GCB")
700                         set(__VA_COPY_USE_GCB "__builtin_va_copy((d),(s))")
701                 endif(${fctbis} STREQUAL "__builtin_va_copy((d),(s))")
702
703                 if(${fctbis} STREQUAL "do { (d) = (s) } while (0)")
704                         set(ac_cv_va_copy "ASS")
705                         set(__VA_COPY_USE_ASS "do { (d) = (s); } while (0)")
706                 endif(${fctbis} STREQUAL "do { (d) = (s) } while (0)")
707
708                 if(${fctbis} STREQUAL "do { *(d) = *(s) } while (0)")
709                         set(ac_cv_va_copy "ASP")
710                         set(__VA_COPY_USE_ASP "do { *(d) = *(s); } while (0)")
711                 endif(${fctbis} STREQUAL "do { *(d) = *(s) } while (0)")
712
713                 if(${fctbis} STREQUAL "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
714                         set(ac_cv_va_copy "CPS")
715                         set(__VA_COPY_USE_CPS "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
716                 endif(${fctbis} STREQUAL "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
717
718                 if(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
719                         set(ac_cv_va_copy "CPP")
720                         set(__VA_COPY_USE_CPP "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
721                 endif(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
722                                 
723                 if(NOT STATUS_OK)
724                 set(__VA_COPY_USE "__VA_COPY_USE_${ac_cv_va_copy}(d, s)")
725                 endif(NOT STATUS_OK)
726                 set(STATUS_OK "1")
727                 
728         endif(COMPILE_VA_NULL_VAR)
729         
730 endforeach(fct ${diff_va})
731
732 #--------------------------------------------------------------------------------------------------
733 ### check for getline
734 try_compile(COMPILE_RESULT_VAR
735         ${CMAKE_BINARY_DIR}
736         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_getline.c
737         )
738
739 if(NOT COMPILE_RESULT_VAR)
740 SET(need_getline "#define SIMGRID_NEED_GETLINE 1")
741 SET(SIMGRID_NEED_GETLINE 1)
742 else(NOT COMPILE_RESULT_VAR)
743 SET(need_getline "")
744 SET(SIMGRID_NEED_GETLINE 0)
745 endif(NOT COMPILE_RESULT_VAR)
746
747 ### check for a working snprintf
748 if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
749     if(WIN32)
750         #set(HAVE_SNPRINTF 1)
751         #set(HAVE_VSNPRINTF 1)
752     endif(WIN32)
753     
754         if(CMAKE_CROSSCOMPILING)
755                 set(RUN_SNPRINTF_FUNC "cross")
756                 #set(PREFER_PORTABLE_SNPRINTF 1)
757         else(CMAKE_CROSSCOMPILING)
758             try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR
759                 ${CMAKE_BINARY_DIR}
760                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_snprintf.c
761             )   
762         endif(CMAKE_CROSSCOMPILING)
763
764         if(CMAKE_CROSSCOMPILING)
765                 set(RUN_VSNPRINTF_FUNC "cross")
766                 set(PREFER_PORTABLE_VSNPRINTF 1)
767         else(CMAKE_CROSSCOMPILING)
768            try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR
769                 ${CMAKE_BINARY_DIR}
770                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_vsnprintf.c
771            )
772         endif(CMAKE_CROSSCOMPILING)
773         
774         set(PREFER_PORTABLE_SNPRINTF 0)
775         if(RUN_VSNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
776                 set(PREFER_PORTABLE_SNPRINTF 1)
777         endif(RUN_VSNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
778         if(RUN_SNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
779                 set(PREFER_PORTABLE_SNPRINTF 1)
780         endif(RUN_SNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
781 endif(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
782
783 ### check for asprintf function familly
784 if(HAVE_ASPRINTF)
785         SET(simgrid_need_asprintf "")
786         SET(NEED_ASPRINTF 0)
787 else(HAVE_ASPRINTF)
788         SET(simgrid_need_asprintf "#define SIMGRID_NEED_ASPRINTF 1")
789         SET(NEED_ASPRINTF 1)
790 endif(HAVE_ASPRINTF)
791
792 if(HAVE_VASPRINTF)
793         SET(simgrid_need_vasprintf "")
794         SET(NEED_VASPRINTF 0)
795 else(HAVE_VASPRINTF)
796         SET(simgrid_need_vasprintf "#define SIMGRID_NEED_VASPRINTF 1")
797         SET(NEED_VASPRINTF 1)
798 endif(HAVE_VASPRINTF)
799
800 ### check for addr2line
801
802 find_path(ADDR2LINE NAMES addr2line     PATHS NO_DEFAULT_PATHS  )
803 if(ADDR2LINE)
804 set(ADDR2LINE "${ADDR2LINE}/addr2line")
805 endif(ADDR2LINE)
806
807
808
809 ### Check if OSX can compile with ucontext (with gcc 4.[1-5] it is broken)
810 if(APPLE)
811     if(APPLE_NEED_GCC_VERSION GREATER COMPILER_C_VERSION_MAJOR_MINOR)
812         message(STATUS "Ucontext can't be used with this version of gcc (must be greater than 4.5)")
813         set(HAVE_UCONTEXT_H 0)
814     endif(APPLE_NEED_GCC_VERSION GREATER COMPILER_C_VERSION_MAJOR_MINOR)
815 endif(APPLE)
816
817 ### File to create
818
819 configure_file("${CMAKE_HOME_DIRECTORY}/src/context_sysv_config.h.in"                   "${CMAKE_BINARY_DIR}/src/context_sysv_config.h" @ONLY IMMEDIATE)
820
821 SET( CMAKEDEFINE "#cmakedefine" )
822 configure_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/gras_config.h.in"      "${CMAKE_BINARY_DIR}/src/gras_config.h" @ONLY IMMEDIATE)
823 configure_file("${CMAKE_BINARY_DIR}/src/gras_config.h"                  "${CMAKE_BINARY_DIR}/src/gras_config.h" @ONLY IMMEDIATE)
824 configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid_config.h.in"            "${CMAKE_BINARY_DIR}/include/simgrid_config.h" @ONLY IMMEDIATE)
825
826 set(top_srcdir "${CMAKE_HOME_DIRECTORY}")
827 set(srcdir "${CMAKE_HOME_DIRECTORY}/src")
828
829 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
830 set(includedir ${CMAKE_INSTALL_PREFIX}/include)
831 set(top_builddir ${CMAKE_HOME_DIRECTORY})
832 set(libdir ${exec_prefix}/lib)
833 set(CMAKE_LINKARGS "${CMAKE_BINARY_DIR}/lib")
834 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:${GTNETS_LIB_PATH}:${HAVE_NS3_LIB}:$LD_LIBRARY_PATH")
835
836 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/smpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/smpif.h @ONLY)
837 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/bin/smpicc @ONLY)
838 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpif2c.in ${CMAKE_BINARY_DIR}/bin/smpif2c @ONLY)
839 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpiff.in ${CMAKE_BINARY_DIR}/bin/smpiff @ONLY)
840 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_BINARY_DIR}/bin/smpirun @ONLY)
841
842 if(NOT WIN32)
843 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc" OUTPUT_VARIABLE OKITOKI)
844 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif2c" OUTPUT_VARIABLE OKITOKI)
845 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff" OUTPUT_VARIABLE OKITOKI)
846 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun" OUTPUT_VARIABLE OKITOKI)
847 endif(NOT WIN32)
848
849 set(generated_headers_to_install
850         ${CMAKE_CURRENT_BINARY_DIR}/include/smpi/smpif.h
851         ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid_config.h
852 )
853
854 set(generated_headers
855     ${CMAKE_CURRENT_BINARY_DIR}/src/context_sysv_config.h
856     ${CMAKE_CURRENT_BINARY_DIR}/src/gras_config.h
857 )
858
859 set(generated_files_to_clean
860 ${generated_headers}
861 ${generated_headers_to_install}
862 ${CMAKE_BINARY_DIR}/bin/smpicc
863 ${CMAKE_BINARY_DIR}/bin/smpif2c
864 ${CMAKE_BINARY_DIR}/bin/smpiff
865 ${CMAKE_BINARY_DIR}/bin/smpirun
866 ${CMAKE_BINARY_DIR}/bin/colorize
867 ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
868 ${CMAKE_BINARY_DIR}/examples/smpi/smpi_traced.trace
869 ${CMAKE_BINARY_DIR}/src/supernovae_sg.c
870 ${CMAKE_BINARY_DIR}/src/supernovae_gras.c
871 ${CMAKE_BINARY_DIR}/src/supernovae_smpi.c
872 )
873
874 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
875 else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
876         configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/hostfile ${CMAKE_BINARY_DIR}/examples/smpi/hostfile COPYONLY)
877         configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/small_platform.xml ${CMAKE_BINARY_DIR}/examples/msg/small_platform.xml COPYONLY)
878         configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/small_platform_with_routers.xml ${CMAKE_BINARY_DIR}/examples/msg/small_platform_with_routers.xml COPYONLY)
879         configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing/platform.xml ${CMAKE_BINARY_DIR}/examples/msg/tracing/platform.xml COPYONLY)
880         
881         set(generated_files_to_clean
882                 ${generated_files_to_clean}
883                 ${CMAKE_BINARY_DIR}/examples/smpi/hostfile
884                 ${CMAKE_BINARY_DIR}/examples/msg/small_platform.xml
885                 ${CMAKE_BINARY_DIR}/examples/msg/small_platform_with_routers.xml
886                 ${CMAKE_BINARY_DIR}/examples/msg/tracing/platform.xml
887                 )
888 endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
889
890 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
891 "${generated_files_to_clean}")
892
893
894 IF(${ARCH_32_BITS})
895   set(WIN_ARCH "32")
896 ELSE(${ARCH_32_BITS})
897     set(WIN_ARCH "64")
898 ENDIF(${ARCH_32_BITS})
899 configure_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/simgrid.nsi.in"        "${CMAKE_BINARY_DIR}/simgrid.nsi" @ONLY IMMEDIATE)