Logo AND Algorithmique Numérique Distribuée

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