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