Logo AND Algorithmique Numérique Distribuée

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