Logo AND Algorithmique Numérique Distribuée

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