Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add more debug messages and add flag _I_X86 on windows platform
[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     file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
338     file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
339     exec_program(
340                  "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c ${mcsc_flags} -o testprog"
341                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/
342                  OUTPUT_VARIABLE COMPILE_mcsc_VAR)
343
344     if(NOT COMPILE_mcsc_VAR)
345         message(STATUS "prog_AC_CHECK_MCSC.c is compilable")
346         exec_program("${CMAKE_BINARY_DIR}/testprog" OUTPUT_VARIABLE var_compil)
347     else(NOT COMPILE_mcsc_VAR)
348         message(STATUS "prog_AC_CHECK_MCSC.c is not compilable")
349     endif(NOT COMPILE_mcsc_VAR)
350     file(REMOVE "${CMAKE_BINARY_DIR}/testprog*")
351     
352         if(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
353                 file(READ "${CMAKE_BINARY_DIR}/conftestval" mcsc)
354                 STRING(REPLACE "\n" "" mcsc "${mcsc}")
355                 if(mcsc)
356                         set(mcsc "yes")
357                         set(HAVE_UCONTEXT_H 1)
358                 else(mcsc)
359                         set(mcsc "no")
360                 endif(mcsc)
361     else(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
362                 set(mcsc "no")
363         endif(EXISTS "${CMAKE_BINARY_DIR}/conftestval")
364         
365         message(STATUS "mcsc: ${mcsc}")   
366 ENDIF(CMAKE_CROSSCOMPILING)
367
368 if(mcsc MATCHES "no" AND pthread)
369         if(HAVE_WINDOWS_H)
370                 set(windows_context "yes")
371                 set(IS_WINDOWS 1)
372         elseif(HAVE_WINDOWS_H)
373                 message(FATAL_ERROR "no appropriate backend found")
374         endif(HAVE_WINDOWS_H)
375 endif(mcsc MATCHES "no" AND pthread)
376
377 #Only windows
378
379 if(WIN32)
380         if(NOT HAVE_WINDOWS_H)
381                 message(FATAL_ERROR "no appropriate backend found windows")
382         endif(NOT HAVE_WINDOWS_H)
383 endif(WIN32)
384
385 if(windows_context MATCHES "yes")
386         message(STATUS "Context change to windows")
387 endif(windows_context MATCHES "yes")
388
389 #If can have both context
390
391 if(mcsc)
392         set(CONTEXT_UCONTEXT 1)
393 endif(mcsc)
394
395 if(pthread)
396         set(CONTEXT_THREADS 1)
397 endif(pthread)
398
399
400 ###############
401 ## SVN version check
402 ##
403 if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32)
404 exec_program("git remote | head -n 1" OUTPUT_VARIABLE remote RETURN_VALUE ret)
405 exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
406
407 if(url)
408         exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
409         message(STATUS "Git version: ${GIT_VERSION}")
410         exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
411         message(STATUS "Git date: ${GIT_DATE}")
412         string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
413         STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
414         STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
415         STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
416 endif(url)
417 endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32)
418
419 ###################################
420 ## SimGrid and GRAS specific checks
421 ##
422
423 IF(NOT CMAKE_CROSSCOMPILING)
424 # Check architecture signature begin
425 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
426         ${CMAKE_BINARY_DIR}
427         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_ARCH.c
428         RUN_OUTPUT_VARIABLE var1
429         )
430 if(BIGENDIAN)
431   set(val_big "B${var1}")
432   set(GRAS_BIGENDIAN 1)
433 else(BIGENDIAN)
434   set(val_big "l${var1}")
435   set(GRAS_BIGENDIAN 0)
436 endif(BIGENDIAN)
437
438 # The syntax of this magic string is given in src/gras/DataDesc/ddt_convert.c
439 # It kinda matches the values that the gras_arch_desc_t structure can take
440
441 # Basically, the syntax is one char l or B for endianness (little or Big)
442 #   then there is a bunch of blocks separated by _.  
443 # C block is for char, I block for integers, P block for pointers and
444 #   D block for floating points
445 # For each block there is an amount of chuncks separated by :, each of
446 #   them describing a data size. For example there is only one chunk
447 #   in the char block, because no architecture provide several sizes
448 #   of chars. In integer block, there is 4 chunks: "short int", "int",
449 #   "long int", "long long int". There is 2 pointer chunks for data
450 #   pointers and pointers on functions (thanks to the AMD64 madness).
451 #   Thee two floating points chuncks are for "float" and "double".
452 # Each chunk is of the form datasize/minimal_alignment_size
453
454 # These informations are used to convert a data stream from one
455 #    formalism to another. Only the GRAS_ARCH is transfered in the
456 #    stream, and it it of cruxial importance to keep these detection
457 #    information here synchronized with the data hardcoded in the
458 #    source in src/gras/DataDesc/ddt_convert.c 
459
460 # If you add something here (like a previously unknown architecture),
461 #    please add it to the source code too. 
462 # Please do not modify stuff here since it'd break the GRAS protocol.
463 #     If you really need to change stuff, please also bump
464 #    GRAS_PROTOCOL_VERSION in src/gras/Msg/msg_interface.h
465
466 SET(GRAS_THISARCH "none")
467
468 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:")
469         #gras_arch=0; gras_size=32; gras_arch_name=little32_1;
470         SET(GRAS_ARCH_32_BITS 1)
471         SET(GRAS_THISARCH 0)
472 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:")
473 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:")
474         #gras_arch=1; gras_size=32; gras_arch_name=little32_2;
475         SET(GRAS_ARCH_32_BITS 1)
476         SET(GRAS_THISARCH 1)
477 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:")
478 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:") 
479         #gras_arch=2; gras_size=32; gras_arch_name=little32_4;
480         SET(GRAS_ARCH_32_BITS 1)
481         SET(GRAS_THISARCH 2)
482 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:")
483 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:") 
484         #gras_arch=3; gras_size=32; gras_arch_name=little32_8;
485         SET(GRAS_ARCH_32_BITS 1)
486         SET(GRAS_THISARCH 3)
487 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:") 
488 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:") 
489         #gras_arch=4; gras_size=64; gras_arch_name=little64;
490         SET(GRAS_ARCH_32_BITS 0)
491         SET(GRAS_THISARCH 4)
492 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:")
493 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:") 
494         #gras_arch=5; gras_size=64; gras_arch_name=little64_2;
495         SET(GRAS_ARCH_32_BITS 0)
496         SET(GRAS_THISARCH 5)
497 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:")
498
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/8:") 
500         #gras_arch=6; gras_size=32; gras_arch_name=big32_8;
501         SET(GRAS_ARCH_32_BITS 1)
502         SET(GRAS_THISARCH 6)
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/8:")
504 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:") 
505         #gras_arch=7; gras_size=32; gras_arch_name=big32_8_4;
506         SET(GRAS_ARCH_32_BITS 1)
507         SET(GRAS_THISARCH 7)
508 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:")
509 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:") 
510         #gras_arch=8; gras_size=32; gras_arch_name=big32_4;
511         SET(GRAS_ARCH_32_BITS 1)
512         SET(GRAS_THISARCH 8)
513 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:")
514 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:") 
515         #gras_arch=9; gras_size=32; gras_arch_name=big32_2;
516         SET(GRAS_ARCH_32_BITS 1)
517         SET(GRAS_THISARCH 9)
518 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:") 
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/8:") 
520         #gras_arch=10; gras_size=64; gras_arch_name=big64;
521         SET(GRAS_ARCH_32_BITS 0)
522         SET(GRAS_THISARCH 10)
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/8:")
524 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:") 
525         #gras_arch=11; gras_size=64; gras_arch_name=big64_8_4;
526         SET(GRAS_ARCH_32_BITS 0)
527         SET(GRAS_THISARCH 11)
528 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:") 
529
530 if(GRAS_THISARCH MATCHES "none")
531     message(STATUS "architecture: ${val_big}")
532     message(FATAL_ERROR "GRAS_THISARCH is empty: '${GRAS_THISARCH}'")  
533 endif(GRAS_THISARCH MATCHES "none")
534
535 # Check architecture signature end
536 try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR
537         ${CMAKE_BINARY_DIR}
538         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_GRAS_CHECK_STRUCT_COMPACTION.c
539         RUN_OUTPUT_VARIABLE var2
540         )
541 separate_arguments(var2)
542 foreach(var_tmp ${var2})
543         set(${var_tmp} 1)
544 endforeach(var_tmp ${var2})
545
546 # Check for [SIZEOF_MAX]
547 try_run(RUN_SM_VAR COMPILE_SM_VAR
548         ${CMAKE_BINARY_DIR}
549         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_max_size.c
550         RUN_OUTPUT_VARIABLE var3
551         )
552 message(STATUS "SIZEOF_MAX ${var3}")
553 SET(SIZEOF_MAX ${var3})
554 ENDIF(NOT CMAKE_CROSSCOMPILING)
555
556 #--------------------------------------------------------------------------------------------------
557
558 set(makecontext_CPPFLAGS_2 "")
559 if(HAVE_MAKECONTEXT OR WIN32)
560         set(makecontext_CPPFLAGS "-DTEST_makecontext")
561         if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
562                 set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE")
563         endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
564         
565     if(WIN32)
566         if(ARCH_32_BITS)
567             set(makecontext_CPPFLAGS "-DTEST_makecontext -D_I_X86_")
568             else(ARCH_32_BITS)
569             set(makecontext_CPPFLAGS "-DTEST_makecontext -D_AMD64_")
570             endif(ARCH_32_BITS)
571             set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/include/xbt -I${CMAKE_HOME_DIRECTORY}/src/xbt")
572         endif(WIN32)
573
574     file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
575         
576         try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
577                 ${CMAKE_BINARY_DIR}
578                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stacksetup.c
579                 COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}"
580                 )
581
582     if(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
583         file(READ ${CMAKE_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
584         string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
585         string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
586         string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}")
587         string(REPLACE "," "" makecontext_addr "${MAKECONTEXT_ADDR}")
588         string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}")   
589         set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
590         set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
591         message(STATUS "${pth_skaddr_makecontext}")
592         message(STATUS "${pth_sksize_makecontext}")
593         else(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
594 #           message(FATAL_ERROR "makecontext is not compilable")
595         endif(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
596 endif(HAVE_MAKECONTEXT OR WIN32)
597
598 #--------------------------------------------------------------------------------------------------
599
600 ### check for stackgrowth
601 if (NOT CMAKE_CROSSCOMPILING)
602         try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
603                 ${CMAKE_BINARY_DIR}
604                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_stackgrowth.c
605                 )
606 file(READ "${CMAKE_BINARY_DIR}/conftestval" stack)
607 if(stack MATCHES "down")
608         set(PTH_STACKGROWTH "-1")
609 endif(stack MATCHES "down")
610 if(stack MATCHES "up")
611         set(PTH_STACKGROWTH "1")
612 endif(stack MATCHES "up")
613
614 endif(NOT CMAKE_CROSSCOMPILING)
615 ###############
616 ## System checks
617 ##
618
619 #SG_CONFIGURE_PART([System checks...])
620 #AC_PROG_CC(xlC gcc cc) -auto
621 #AM_SANITY_CHECK -auto
622
623 #AC_PROG_MAKE_SET
624
625
626 #AC_PRINTF_NULL
627 try_run(RUN_PRINTF_NULL_VAR COMPILE_PRINTF_NULL_VAR
628         ${CMAKE_BINARY_DIR}
629         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_printf_null.c
630         )
631
632 if(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
633 SET(PRINTF_NULL_WORKING "0")
634 else(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
635 SET(PRINTF_NULL_WORKING "1")
636 endif(RUN_PRINTF_NULL_VAR MATCHES "FAILED_TO_RUN")
637
638 #AC_CHECK_VA_COPY
639
640 set(diff_va "va_copy((d),(s))"
641 "VA_COPY((d),(s))"
642 "__va_copy((d),(s))"
643 "__builtin_va_copy((d),(s))"
644 "do { (d) = (s)\; } while (0)"
645 "do { *(d) = *(s)\; } while (0)"
646 "memcpy((void *)&(d), (void *)&(s), sizeof(s))"
647 "memcpy((void *)(d), (void *)(s), sizeof(*(s)))"
648 )
649
650 foreach(fct ${diff_va})
651         write_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c" "#include <stdlib.h>
652         #include <stdarg.h>
653         #include <string.h>
654         #define DO_VA_COPY(d,s) ${fct}
655         void test(char *str, ...)
656         {
657             va_list ap, ap2;
658             int i;
659             va_start(ap, str);
660             DO_VA_COPY(ap2, ap);
661             for (i = 1; i <= 9; i++) {
662                 int k = (int)va_arg(ap, int);
663                 if (k != i)
664                     abort();
665             }
666             DO_VA_COPY(ap, ap2);
667             for (i = 1; i <= 9; i++) {
668                 int k = (int)va_arg(ap, int);
669                 if (k != i)
670                     abort();
671             }
672             va_end(ap);
673         }
674         int main(void)
675         {
676             test(\"test\", 1, 2, 3, 4, 5, 6, 7, 8, 9);
677             exit(0);
678         }"
679         )
680         try_compile(COMPILE_VA_NULL_VAR
681         ${CMAKE_BINARY_DIR}
682         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_va_copy.c
683         )
684         if(COMPILE_VA_NULL_VAR)
685                 string(REGEX REPLACE "\;" "" fctbis ${fct})
686                 if(${fctbis} STREQUAL "va_copy((d),(s))")
687                         set(HAVE_VA_COPY 1)
688                         set(ac_cv_va_copy "C99")
689                         set(__VA_COPY_USE_C99 "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 "GCM")
694                         set(__VA_COPY_USE_GCM "VA_COPY((d),(s))")
695                 endif(${fctbis} STREQUAL "VA_COPY((d),(s))")
696
697                 if(${fctbis} STREQUAL "__va_copy((d),(s))")
698                         set(ac_cv_va_copy "GCH")
699                         set(__VA_COPY_USE_GCH "__va_copy((d),(s))")
700                 endif(${fctbis} STREQUAL "__va_copy((d),(s))")
701
702                 if(${fctbis} STREQUAL "__builtin_va_copy((d),(s))")
703                         set(ac_cv_va_copy "GCB")
704                         set(__VA_COPY_USE_GCB "__builtin_va_copy((d),(s))")
705                 endif(${fctbis} STREQUAL "__builtin_va_copy((d),(s))")
706
707                 if(${fctbis} STREQUAL "do { (d) = (s) } while (0)")
708                         set(ac_cv_va_copy "ASS")
709                         set(__VA_COPY_USE_ASS "do { (d) = (s); } while (0)")
710                 endif(${fctbis} STREQUAL "do { (d) = (s) } while (0)")
711
712                 if(${fctbis} STREQUAL "do { *(d) = *(s) } while (0)")
713                         set(ac_cv_va_copy "ASP")
714                         set(__VA_COPY_USE_ASP "do { *(d) = *(s); } while (0)")
715                 endif(${fctbis} STREQUAL "do { *(d) = *(s) } while (0)")
716
717                 if(${fctbis} STREQUAL "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
718                         set(ac_cv_va_copy "CPS")
719                         set(__VA_COPY_USE_CPS "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
720                 endif(${fctbis} STREQUAL "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
721
722                 if(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
723                         set(ac_cv_va_copy "CPP")
724                         set(__VA_COPY_USE_CPP "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
725                 endif(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
726                                 
727                 if(NOT STATUS_OK)
728                 set(__VA_COPY_USE "__VA_COPY_USE_${ac_cv_va_copy}(d, s)")
729                 endif(NOT STATUS_OK)
730                 set(STATUS_OK "1")
731                 
732         endif(COMPILE_VA_NULL_VAR)
733         
734 endforeach(fct ${diff_va})
735
736 #--------------------------------------------------------------------------------------------------
737 ### check for getline
738 try_compile(COMPILE_RESULT_VAR
739         ${CMAKE_BINARY_DIR}
740         ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_getline.c
741         )
742
743 if(NOT COMPILE_RESULT_VAR)
744 SET(need_getline "#define SIMGRID_NEED_GETLINE 1")
745 SET(SIMGRID_NEED_GETLINE 1)
746 else(NOT COMPILE_RESULT_VAR)
747 SET(need_getline "")
748 SET(SIMGRID_NEED_GETLINE 0)
749 endif(NOT COMPILE_RESULT_VAR)
750
751 ### check for a working snprintf
752 if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
753     if(WIN32)
754         #set(HAVE_SNPRINTF 1)
755         #set(HAVE_VSNPRINTF 1)
756     endif(WIN32)
757     
758         if(CMAKE_CROSSCOMPILING)
759                 set(RUN_SNPRINTF_FUNC "cross")
760                 #set(PREFER_PORTABLE_SNPRINTF 1)
761         else(CMAKE_CROSSCOMPILING)
762             try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR
763                 ${CMAKE_BINARY_DIR}
764                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_snprintf.c
765             )   
766         endif(CMAKE_CROSSCOMPILING)
767
768         if(CMAKE_CROSSCOMPILING)
769                 set(RUN_VSNPRINTF_FUNC "cross")
770                 set(PREFER_PORTABLE_VSNPRINTF 1)
771         else(CMAKE_CROSSCOMPILING)
772            try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR
773                 ${CMAKE_BINARY_DIR}
774                 ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_vsnprintf.c
775            )
776         endif(CMAKE_CROSSCOMPILING)
777         
778         set(PREFER_PORTABLE_SNPRINTF 0)
779         if(RUN_VSNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
780                 set(PREFER_PORTABLE_SNPRINTF 1)
781         endif(RUN_VSNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
782         if(RUN_SNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
783                 set(PREFER_PORTABLE_SNPRINTF 1)
784         endif(RUN_SNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
785 endif(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
786
787 ### check for asprintf function familly
788 if(HAVE_ASPRINTF)
789         SET(simgrid_need_asprintf "")
790         SET(NEED_ASPRINTF 0)
791 else(HAVE_ASPRINTF)
792         SET(simgrid_need_asprintf "#define SIMGRID_NEED_ASPRINTF 1")
793         SET(NEED_ASPRINTF 1)
794 endif(HAVE_ASPRINTF)
795
796 if(HAVE_VASPRINTF)
797         SET(simgrid_need_vasprintf "")
798         SET(NEED_VASPRINTF 0)
799 else(HAVE_VASPRINTF)
800         SET(simgrid_need_vasprintf "#define SIMGRID_NEED_VASPRINTF 1")
801         SET(NEED_VASPRINTF 1)
802 endif(HAVE_VASPRINTF)
803
804 ### check for addr2line
805
806 find_path(ADDR2LINE NAMES addr2line     PATHS NO_DEFAULT_PATHS  )
807 if(ADDR2LINE)
808 set(ADDR2LINE "${ADDR2LINE}/addr2line")
809 endif(ADDR2LINE)
810
811
812
813 ### Check if OSX can compile with ucontext (with gcc 4.[1-5] it is broken)
814 if(APPLE)
815     if(APPLE_NEED_GCC_VERSION GREATER COMPILER_C_VERSION_MAJOR_MINOR)
816         message(STATUS "Ucontext can't be used with this version of gcc (must be greater than 4.5)")
817         set(HAVE_UCONTEXT_H 0)
818     endif(APPLE_NEED_GCC_VERSION GREATER COMPILER_C_VERSION_MAJOR_MINOR)
819 endif(APPLE)
820
821 ### File to create
822
823 configure_file("${CMAKE_HOME_DIRECTORY}/src/context_sysv_config.h.in"                   "${CMAKE_BINARY_DIR}/src/context_sysv_config.h" @ONLY IMMEDIATE)
824
825 SET( CMAKEDEFINE "#cmakedefine" )
826 configure_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/gras_config.h.in"      "${CMAKE_BINARY_DIR}/src/gras_config.h" @ONLY IMMEDIATE)
827 configure_file("${CMAKE_BINARY_DIR}/src/gras_config.h"                  "${CMAKE_BINARY_DIR}/src/gras_config.h" @ONLY IMMEDIATE)
828 configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid_config.h.in"            "${CMAKE_BINARY_DIR}/include/simgrid_config.h" @ONLY IMMEDIATE)
829
830 set(top_srcdir "${CMAKE_HOME_DIRECTORY}")
831 set(srcdir "${CMAKE_HOME_DIRECTORY}/src")
832
833 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
834 set(includedir ${CMAKE_INSTALL_PREFIX}/include)
835 set(top_builddir ${CMAKE_HOME_DIRECTORY})
836 set(libdir ${exec_prefix}/lib)
837 set(CMAKE_LINKARGS "${CMAKE_BINARY_DIR}/lib")
838 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:${GTNETS_LIB_PATH}:${HAVE_NS3_LIB}:$LD_LIBRARY_PATH")
839
840 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/smpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/smpif.h @ONLY)
841 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/bin/smpicc @ONLY)
842 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpif2c.in ${CMAKE_BINARY_DIR}/bin/smpif2c @ONLY)
843 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpiff.in ${CMAKE_BINARY_DIR}/bin/smpiff @ONLY)
844 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_BINARY_DIR}/bin/smpirun @ONLY)
845
846 if(NOT WIN32)
847 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc" OUTPUT_VARIABLE OKITOKI)
848 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif2c" OUTPUT_VARIABLE OKITOKI)
849 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff" OUTPUT_VARIABLE OKITOKI)
850 exec_program("chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun" OUTPUT_VARIABLE OKITOKI)
851 endif(NOT WIN32)
852
853 set(generated_headers_to_install
854         ${CMAKE_CURRENT_BINARY_DIR}/include/smpi/smpif.h
855         ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid_config.h
856 )
857
858 set(generated_headers
859     ${CMAKE_CURRENT_BINARY_DIR}/src/context_sysv_config.h
860     ${CMAKE_CURRENT_BINARY_DIR}/src/gras_config.h
861 )
862
863 set(generated_files_to_clean
864 ${generated_headers}
865 ${generated_headers_to_install}
866 ${CMAKE_BINARY_DIR}/bin/smpicc
867 ${CMAKE_BINARY_DIR}/bin/smpif2c
868 ${CMAKE_BINARY_DIR}/bin/smpiff
869 ${CMAKE_BINARY_DIR}/bin/smpirun
870 ${CMAKE_BINARY_DIR}/bin/colorize
871 ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
872 ${CMAKE_BINARY_DIR}/examples/smpi/smpi_traced.trace
873 ${CMAKE_BINARY_DIR}/src/supernovae_sg.c
874 ${CMAKE_BINARY_DIR}/src/supernovae_gras.c
875 ${CMAKE_BINARY_DIR}/src/supernovae_smpi.c
876 )
877
878 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
879 else("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
880         configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/hostfile ${CMAKE_BINARY_DIR}/examples/smpi/hostfile COPYONLY)
881         configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/small_platform.xml ${CMAKE_BINARY_DIR}/examples/msg/small_platform.xml COPYONLY)
882         configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/small_platform_with_routers.xml ${CMAKE_BINARY_DIR}/examples/msg/small_platform_with_routers.xml COPYONLY)
883         configure_file(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing/platform.xml ${CMAKE_BINARY_DIR}/examples/msg/tracing/platform.xml COPYONLY)
884         
885         set(generated_files_to_clean
886                 ${generated_files_to_clean}
887                 ${CMAKE_BINARY_DIR}/examples/smpi/hostfile
888                 ${CMAKE_BINARY_DIR}/examples/msg/small_platform.xml
889                 ${CMAKE_BINARY_DIR}/examples/msg/small_platform_with_routers.xml
890                 ${CMAKE_BINARY_DIR}/examples/msg/tracing/platform.xml
891                 )
892 endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
893
894 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
895 "${generated_files_to_clean}")
896
897
898 IF(${ARCH_32_BITS})
899   set(WIN_ARCH "32")
900 ELSE(${ARCH_32_BITS})
901     set(WIN_ARCH "64")
902 ENDIF(${ARCH_32_BITS})
903 configure_file("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/simgrid.nsi.in"        "${CMAKE_BINARY_DIR}/simgrid.nsi" @ONLY IMMEDIATE)