Logo AND Algorithmique Numérique Distribuée

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