Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[cmake] inline the nasty CompleteInFiles.cmake Cleanups needed
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 # Java requires 2.8.6
3 message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
4
5 project(SimGrid C CXX)
6
7 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
8 #     Check for the compiler        #
9 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
10
11 ### Need to set rc ccompiler before enable language
12 if(WIN32)
13   SET(CMAKE_RC_COMPILER "windres")
14 endif()
15
16 ## 
17 ## Check the C/C++ standard that we need
18 ##   See also tools/cmake/GCCFlags.cmake that sets our paranoid warning flags
19 if (MSVC)
20   message("-- You are compiling SimGrid with MicroSoft Visual C. Good luck.")
21
22   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
23   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
24 else() # gcc or clang
25   INCLUDE(CheckCCompilerFlag)
26   CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER)
27
28   ## Request full debugging flags
29   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
30   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
31   set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
32
33   if (CMAKE_COMPILER_IS_GNUCC)
34     if (COMPILER_CXX_VERSION_MAJOR_MINOR STRLESS "4.7")
35       message(FATAL_ERROR
36               "SimGrid needs at least g++ version 4.7 to compile "
37               "(c++11 support of previous versions is too limited).")
38     endif()
39   endif()
40
41   ## We need a decent support of the c++11 standard
42   include(CheckCXXCompilerFlag)
43   CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11)
44   if(COMPILER_SUPPORTS_CXX11)
45     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
46   else() 
47     message(FATAL_ERROR 
48             "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. "
49             "Please use a decent C++ compiler.")
50   endif()
51
52   ### And we need C11 standard, too
53   include(CheckCCompilerFlag)
54   CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_C11)
55   if(COMPILER_SUPPORTS_C11)
56     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
57   else()
58     message(FATAL_ERROR 
59             "The compiler ${CMAKE_C_COMPILER} has no C11 support. "
60             "Please use a decent C compiler "
61             "(note that c++11 support of ${CMAKE_CXX_COMPILER} seems ok).")
62   endif()
63   if(APPLE AND ("4.6" GREATER COMPILER_C_VERSION_MAJOR_MINOR))
64       ### gcc 4.[1-5] cannot compile ucontext on OSX
65       message(STATUS "Ucontext can't be used with this version of gcc (must be greater than 4.5)")
66       set(HAVE_UCONTEXT_H 0)
67   endif()
68 endif() # NOT MSVC
69
70 ### SMPI vs. Fortran
71 if ((NOT DEFINED enable_smpi OR enable_smpi) AND NOT APPLE) # smpi is enabled by default
72   # Call enable_language(Fortran) in order to load the build rules for
73   # this language, needed by teshsuite/smpi/mpich-test/.  Use
74   # CMAKE_FORCE_Fortran_COMPILER to bypass checks for a working
75   # compiler (smpiff don't exist at configure time).
76   include(CMakeForceCompiler)
77   if(NOT COMMAND CMAKE_FORCE_Fortran_COMPILER)
78     MACRO(CMAKE_FORCE_Fortran_COMPILER compiler id)
79       SET(CMAKE_Fortran_COMPILER "${compiler}")
80       SET(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
81       SET(CMAKE_Fortran_COMPILER_ID ${id})
82       SET(CMAKE_Fortran_COMPILER_WORKS TRUE)
83       SET(CMAKE_Fortran_COMPILER_FORCED TRUE)
84
85       # Set old compiler id variables.
86       IF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
87         SET(CMAKE_COMPILER_IS_GNUG77 1)
88       ENDIF("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
89     ENDMACRO(CMAKE_FORCE_Fortran_COMPILER)
90   endif()
91   CMAKE_FORCE_Fortran_COMPILER(smpiff smpiff)
92   enable_language(Fortran OPTIONAL)
93 endif()
94
95 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
96 #     Build the version number      #
97 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
98
99 set(SIMGRID_VERSION_MAJOR "3")
100 set(SIMGRID_VERSION_MINOR "13")
101 set(SIMGRID_VERSION_PATCH "0")
102 set(SIMGRID_VERSION_EXTRA "-devel") # Extra words to add to version string (e.g. -rc1)
103
104 set(SIMGRID_VERSION_DATE  "2015") # Year for copyright information
105
106 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
107   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
108 else()
109   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}.${SIMGRID_VERSION_PATCH}")
110 endif()
111
112 set(SIMGRID_VERSION_STRING "SimGrid version ${release_version}${SIMGRID_VERSION_EXTRA}")
113 set(SIMGRID_VERSION_BANNER
114   "SIMGRID_VERSION_STRING\\nCopyright (c) 2004-${SIMGRID_VERSION_DATE}. The Simgrid Team.")
115
116 set(libsimgrid_version "${release_version}")
117 set(libsimgrid-java_version "${release_version}")
118
119 ### SET THE LIBRARY EXTENSION 
120 if(APPLE) #MAC
121   set(LIB_EXE "dylib")
122 else()
123   if(WIN32) #WINDOWS
124     set(LIB_EXE "a")
125     set(BIN_EXE ".exe")
126   else() #UNIX
127     set(LIB_EXE "so")
128   endif()
129 endif()
130
131 if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
132   exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
133   exec_program("${CMAKE_CXX_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_CXX_VERSION")
134   string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
135   string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_CXX_VERSION "${COMPILER_CXX_VERSION}")
136
137   string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_VERSION_MAJOR_MINOR "${COMPILER_C_VERSION}")
138   string(REPLACE "${COMPILER_C_VERSION_MAJOR_MINOR}." "" COMPILER_C_VERSION_PATCH "${COMPILER_C_VERSION}")  
139 endif()
140
141 exec_program("${CMAKE_LINKER} --version" OUTPUT_VARIABLE "LINKER_VERSION")
142 string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}")
143
144 ### Find programs and paths
145 FIND_PROGRAM(GCOV_PATH gcov)
146 include(FindPerl)
147 if(NOT PERL_EXECUTABLE)
148   message(FATAL_ERROR "-- SimGrid cannot be compiled without Perl installed -- sorry. Bailling out.")
149 endif()
150
151 if (APPLE)
152   set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
153   set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
154 endif()
155
156 ### Set some variables for Cmake
157 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
158
159 set(INCLUDES
160   ${CMAKE_HOME_DIRECTORY}
161   ${CMAKE_HOME_DIRECTORY}/include
162   ${CMAKE_HOME_DIRECTORY}/src
163   ${CMAKE_HOME_DIRECTORY}/src/include
164   ${CMAKE_BINARY_DIR}
165   ${CMAKE_BINARY_DIR}/include
166   ${CMAKE_BINARY_DIR}/src
167   )
168
169 if(WIN32)
170   set(INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/include/xbt ${CMAKE_HOME_DIRECTORY}/src/xbt) #for win32_ucontext.[ch]
171 endif()
172
173 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
174   set(INCLUDES ${INCLUDES} /usr/include/)
175 endif()
176
177 ### Check 32bits or 64bits
178 INCLUDE (CheckTypeSize)
179 CHECK_TYPE_SIZE("int" SIZEOF_INT)
180 CHECK_TYPE_SIZE("long" SIZEOF_LONG)
181 CHECK_TYPE_SIZE("long long" SIZEOF_LONGLONG)
182 CHECK_TYPE_SIZE("void*" SIZEOF_VOIDSTAR)
183 message ("   Data model: (int)=${SIZEOF_INT} (long)=${SIZEOF_LONG} (long long)=${SIZEOF_LONGLONG} (void*)=${SIZEOF_VOIDSTAR}")
184 IF(SIZEOF_VOIDSTAR EQUAL 4)
185   SET(ARCH_32_BITS 1)
186 ELSE()
187   SET(ARCH_32_BITS 0)
188 ENDIF()
189
190 if(WIN32)
191
192   #Need env INCLUDE
193   set(CMAKE_INCLUDE_WIN "${CMAKE_C_COMPILER}")
194   set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}")
195   string(REGEX REPLACE "/bin/gcc.*" "/include"  CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}")
196   string(REGEX REPLACE "/bin/gcc.*" "/lib"  CMAKE_LIB_WIN "${CMAKE_LIB_WIN}")
197   set(INCLUDES ${INCLUDES} ${CMAKE_INCLUDE_WIN})
198
199   if(CMAKE_COMPILER_IS_GNUCC)
200     set(__GNUC__ 1)
201     exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
202     string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
203     string(REGEX MATCH "^[0-9]" COMPILER_C_MAJOR_VERSION "${COMPILER_C_VERSION}")
204     string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_MINOR_VERSION "${COMPILER_C_VERSION}")
205     string(REGEX REPLACE "^${COMPILER_C_MAJOR_VERSION}." "" COMPILER_C_MINOR_VERSION "${COMPILER_C_MINOR_VERSION}")
206     if(COMPILER_C_MAJOR_VERSION)
207       # set(__GNUC__ ${COMPILER_C_MAJOR_VERSION})
208     endif()
209     if(COMPILER_C_MINOR_VERSION)
210       # set(__GNUC_MINOR__ ${COMPILER_C_MINOR_VERSION})
211     endif()
212   endif()
213
214   set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITEW6432})
215   if(NSIS_WIN_VERSION MATCHES "")
216     set(NSIS_WIN_VERSION $ENV{PROCESSOR_ARCHITECTURE})
217   endif()
218   if(${NSIS_WIN_VERSION})
219     string(TOLOWER ${NSIS_WIN_VERSION} NSIS_WIN_VERSION)
220   endif()
221
222   set(_XBT_WIN32 1)
223
224   message(STATUS "C_COMPILER                    ${CMAKE_C_COMPILER} ${COMPILER_C_VERSION_MAJOR_MINOR}")
225   message(STATUS "CXX_COMPILER                  ${CMAKE_CXX_COMPILER} ${COMPILER_CXX_VERSION_MAJOR_MINOR}")
226   message(STATUS "CMAKE_RC_COMPILER             ${CMAKE_RC_COMPILER}")
227   message(STATUS "INCLUDE                       ${CMAKE_INCLUDE_WIN}")
228   message(STATUS "LIB                           ${CMAKE_LIB_WIN}")
229   message(STATUS "MAKE_PROGRAM                  ${CMAKE_MAKE_PROGRAM}")
230   message(STATUS "CMAKE_BUILD_TOOL              ${CMAKE_BUILD_TOOL}")
231   message(STATUS "LINKER                        ${CMAKE_LINKER}")
232   message(STATUS "CMAKE_GENERATOR               ${CMAKE_GENERATOR}")
233   message(STATUS "GNUC                          ${CMAKE_COMPILER_IS_GNUCC}")
234
235 endif()
236
237 include_directories(${INCLUDES})
238
239 ### Setup Options
240 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Option.cmake)
241
242 set(CMAKE_MODULE_PATH
243   ${CMAKE_MODULE_PATH}
244   ${CMAKE_HOME_DIRECTORY}/tools/cmake/Modules
245   )
246
247 # x86_64
248 # x86
249 # i.86
250
251 ### Determine the assembly flavor that we need today
252 include(CMakeDetermineSystem)
253 IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64")
254   IF(${ARCH_32_BITS})
255     message(STATUS "System processor: i686 (${CMAKE_SYSTEM_PROCESSOR}, 32 bits)")
256     set(PROCESSOR_i686 1)
257   ELSE()
258     message(STATUS "System processor: x86_64 (${CMAKE_SYSTEM_PROCESSOR}, 64 bits)")
259     set(PROCESSOR_x86_64 1)
260   ENDIF()
261   if (MSVC)
262     message(STATUS "Disable fast raw contextes on Microsoft Visual.")
263   else()
264     set(HAVE_RAWCTX 1)
265   endif()
266
267 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
268   message(STATUS "System processor: alpha")
269
270 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
271   # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
272   message(STATUS "System processor: arm")
273
274 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
275   # mips* machines are bi-endian mostly so processor does not tell
276   # endianess of the underlying system.
277   message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
278
279 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
280   message(STATUS "System processor: ppc64")
281
282 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
283   message(STATUS "System processor: ppc")
284
285 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
286   # Both flavours can run on the same processor
287   message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
288
289 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
290   message(STATUS "System processor: parisc" "parisc64")
291
292 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
293   # s390 binaries can run on s390x machines
294   message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
295
296 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
297   message(STATUS "System processor: sh")
298
299 ELSE() #PROCESSOR NOT FOUND
300   message(STATUS "PROCESSOR NOT FOUND: ${CMAKE_SYSTEM_PROCESSOR}")
301
302 ENDIF()
303
304 if(ARCH_32_BITS)
305   set(MPI_ADDRESS_SIZE 4)
306 else()
307   set(MPI_ADDRESS_SIZE 8)
308 endif()
309
310 include(CheckFunctionExists)
311 include(CheckTypeSize)
312 include(CheckIncludeFile)
313 include(CheckIncludeFiles)
314 include(CheckLibraryExists)
315 include(CheckSymbolExists)
316 include(TestBigEndian)
317 TEST_BIG_ENDIAN(BIGENDIAN)
318
319 include(FindGraphviz)
320 include(FindLibSigc++)
321
322 if(enable_java)
323   find_package(Java REQUIRED COMPONENTS Runtime Development)
324   find_package(JNI REQUIRED)
325   message("-- [Java] JNI found: ${JNI_FOUND}")
326   message("-- [Java] JNI include dirs: ${JNI_INCLUDE_DIRS}")
327   if(enable_maintainer_mode)
328     find_package(SWIG REQUIRED)
329     include(UseSWIG)
330     message("-- [Java] Swig found: ${SWIG_FOUND} (version ${SWIG_VERSION})")
331   endif()
332   set(HAVE_Java 1)
333 endif()
334 if(enable_scala)
335   find_package(Scala REQUIRED)
336   message("-- [Scala] scalac found: ${SCALA_COMPILE}")
337   set(HAVE_Scala 1)
338 endif()
339 if(enable_lua)
340   include(FindLuaSimgrid)
341 endif()
342
343 set(HAVE_NS3 0)
344 if(enable_ns3)
345   include(FindNS3)
346   if (NOT HAVE_NS3)
347     message(FATAL_ERROR "Cannot find NS3. Please install it (apt-get install ns3 libns3-dev) or disable that cmake option")
348   endif()
349 endif()
350
351 find_package(Boost 1.48)
352 if(Boost_FOUND)
353   include_directories(${Boost_INCLUDE_DIRS})
354 else()
355   if(APPLE)
356     message(FATAL_ERROR "Failed to find Boost libraries (Try to install them with 'sudo fink install boost1.53.nopython')")
357   else()
358     message(FATAL_ERROR "Failed to find Boost libraries."
359                         "Did you install libboost-dev and libboost-context-dev?"
360                         "(libboost-context-dev is optional)")
361   endif()
362 endif()
363
364 # Try again to see if we have libboost-context
365 find_package(Boost 1.42 COMPONENTS context)
366 set(Boost_FOUND 1) # We don't care of whether this component is missing
367
368 if(Boost_FOUND AND Boost_CONTEXT_FOUND)
369   # We should use feature detection for this instead:
370   if (Boost_VERSION LESS 105600)
371     message("Found Boost.Context API v1")
372     set(HAVE_BOOST_CONTEXT 1)
373   else()
374     message("Found Boost.Context API v2")
375     set(HAVE_BOOST_CONTEXT 2)
376   endif()
377 else()
378   message ("   boost        : found.")
379   message ("   boost-context: missing. Install libboost-context-dev for this optional feature.")
380   set(HAVE_BOOST_CONTEXT 0)
381 endif()
382
383 # Checks for header libraries functions.
384 CHECK_LIBRARY_EXISTS(dl      dlopen                  "" HAVE_DLOPEN_IN_LIBDL)
385 CHECK_LIBRARY_EXISTS(execinfo backtrace              "" HAVE_BACKTRACE_IN_LIBEXECINFO)
386 CHECK_LIBRARY_EXISTS(pthread pthread_create          "" HAVE_PTHREAD)
387 CHECK_LIBRARY_EXISTS(pthread sem_init                "" HAVE_SEM_INIT_LIB)
388 CHECK_LIBRARY_EXISTS(pthread sem_open                "" HAVE_SEM_OPEN_LIB)
389 CHECK_LIBRARY_EXISTS(pthread sem_timedwait           "" HAVE_SEM_TIMEDWAIT_LIB)
390 CHECK_LIBRARY_EXISTS(pthread pthread_mutex_timedlock "" HAVE_MUTEX_TIMEDLOCK_LIB)
391 CHECK_LIBRARY_EXISTS(rt      clock_gettime           "" HAVE_POSIX_GETTIME)
392
393 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
394   set(CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE")
395 elseif(MINGW)
396   add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
397   set(CMAKE_REQUIRED_DEFINITIONS "-D__USE_MINGW_ANSI_STDIO=1")
398 else()
399   set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
400 endif()
401
402 CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
403 CHECK_INCLUDE_FILE("valgrind/valgrind.h" HAVE_VALGRIND_VALGRIND_H)
404 CHECK_INCLUDE_FILE("socket.h" HAVE_SOCKET_H)
405 CHECK_INCLUDE_FILE("stat.h" HAVE_STAT_H)
406 CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
407 CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
408 CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
409 CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
410 CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
411 CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
412 CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
413 CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
414 CHECK_INCLUDE_FILE("sys/sysctl.h" HAVE_SYS_SYSCTL_H)
415 CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
416 CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
417 CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
418 CHECK_INCLUDE_FILE("stdio.h" HAVE_STDIO_H)
419 CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
420
421 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
422 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
423 CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
424 CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
425 CHECK_FUNCTION_EXISTS(readv HAVE_READV)
426 CHECK_FUNCTION_EXISTS(popen HAVE_POPEN)
427 CHECK_FUNCTION_EXISTS(signal HAVE_SIGNAL)
428
429 CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
430 CHECK_SYMBOL_EXISTS(vsnprintf stdio.h HAVE_VSNPRINTF)
431 CHECK_SYMBOL_EXISTS(asprintf stdio.h HAVE_ASPRINTF)
432 CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF)
433
434 if(MINGW) 
435   # The detection of asprintf fails on MinGW, assumingly because it's
436   # defined as an inline function in stdio.h instead of a regular
437   # function. So force the result to be 1 despite of the test.
438   set(HAVE_ASPRINTF 1)
439   set(HAVE_VASPRINTF 1)
440 endif()
441
442 CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT)
443 CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV)
444
445 CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
446
447 #Check if __thread is defined
448 execute_process(
449   COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_thread_storage.c"
450   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
451   RESULT_VARIABLE HAVE_thread_storage_run
452   )
453
454 if(HAVE_thread_storage_run)
455   set(HAVE_THREAD_LOCAL_STORAGE 1)
456 else()
457   set(HAVE_THREAD_LOCAL_STORAGE 0)
458 endif()
459
460 # Our usage of mmap is Linux-specific (flag MAP_ANONYMOUS), but kFreeBSD uses a GNU libc
461 IF(HAVE_MMAP AND
462    NOT "${CMAKE_SYSTEM}" MATCHES "Linux" AND 
463    NOT "${CMAKE_SYSTEM}" MATCHES "kFreeBSD" AND 
464    NOT "${CMAKE_SYSTEM}" MATCHES "GNU" AND 
465    NOT  "${CMAKE_SYSTEM}" MATCHES "Darwin")
466   SET(HAVE_MMAP 0)
467   message(STATUS "Warning: MMAP is thought as non functional on this architecture (${CMAKE_SYSTEM})")
468 ENDIF()
469
470 if(HAVE_MMAP AND HAVE_THREAD_LOCAL_STORAGE)
471   SET(HAVE_MMALLOC 1)
472 else()
473   SET(HAVE_MMALLOC 0)
474 endif()
475
476
477 if(WIN32) # Those files are not detected despite being present
478   set(HAVE_UCONTEXT_H 1)
479   set(HAVE_MAKECONTEXT 1)
480   set(HAVE_SNPRINTF 1)
481   set(HAVE_VSNPRINTF 1)
482 endif()
483
484 set(CONTEXT_UCONTEXT 0)
485 SET(CONTEXT_THREADS 0)
486
487 if(enable_jedule)
488   SET(HAVE_JEDULE 1)
489 endif()
490
491 if(enable_latency_bound_tracking)
492   SET(HAVE_LATENCY_BOUND_TRACKING 1)
493 else()
494   SET(HAVE_LATENCY_BOUND_TRACKING 0)
495 endif()
496
497 if(enable_mallocators)
498   SET(MALLOCATOR_IS_WANTED 1)
499 else()
500   SET(MALLOCATOR_IS_WANTED 0)
501 endif()
502
503 if(enable_model-checking AND HAVE_MMALLOC)
504   SET(HAVE_MC 1)
505   SET(MMALLOC_WANT_OVERRIDE_LEGACY 1)
506   include(FindLibunwind)
507   include(FindLibdw)
508 else()
509   if(enable_model-checking)
510     message(STATUS "Warning: support for model-checking has been disabled because HAVE_MMALLOC is false")
511   endif()
512   SET(HAVE_MC 0)
513   SET(HAVE_MMALLOC 0)
514   SET(MMALLOC_WANT_OVERRIDE_LEGACY 0)
515 endif()
516
517 if(enable_smpi)
518   include(FindGFortran)
519   #really checks for objdump for privatization
520   find_package(BinUtils QUIET)
521   SET(HAVE_SMPI 1)
522
523   if( NOT "${CMAKE_OBJDUMP}" MATCHES "CMAKE_OBJDUMP-NOTFOUND" AND HAVE_MMAP)
524     SET(HAVE_PRIVATIZATION 1)
525   else()
526     SET(HAVE_PRIVATIZATION 0)
527   endif()
528 endif()
529
530 #--------------------------------------------------------------------------------------------------
531 ### Check for GNU dynamic linker
532 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
533 if (HAVE_DLFCN_H)
534     if(HAVE_DLOPEN_IN_LIBDL)
535       set(DL_LIBRARY "-ldl")
536     endif(HAVE_DLOPEN_IN_LIBDL)
537     execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_gnu_dynlinker.c ${DL_LIBRARY} -o test_gnu_ld
538       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
539       OUTPUT_VARIABLE HAVE_GNU_LD_compil
540     )
541     if(HAVE_GNU_LD_compil)
542       set(HAVE_GNU_LD 0)
543       message(STATUS "Warning: test program toward GNU ld failed to compile:")
544       message(STATUS "${HAVE_GNU_LD_comp_output}")
545     else()
546
547       execute_process(COMMAND ./test_gnu_ld
548           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
549           RESULT_VARIABLE HAVE_GNU_LD_run
550           OUTPUT_VARIABLE var_exec
551       )
552
553       if(NOT HAVE_GNU_LD_run)
554         set(HAVE_GNU_LD 1)
555         message(STATUS "We are using GNU dynamic linker")
556       else()
557         set(HAVE_GNU_LD 0)
558         message(STATUS "Warning: error while checking for GNU ld:")
559         message(STATUS "Test output: '${var_exec}'")
560         message(STATUS "Exit status: ${HAVE_GNU_LD_run}")
561       endif()
562       file(REMOVE test_gnu_ld)
563     endif()
564 endif()
565
566
567 #--------------------------------------------------------------------------------------------------
568 ### Initialize of CONTEXT THREADS
569
570 if(HAVE_PTHREAD)
571   ### Test that we have a way to create semaphores
572
573   if(HAVE_SEM_OPEN_LIB)
574     execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_sem_open.c -lpthread -o sem_open
575     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
576     OUTPUT_VARIABLE HAVE_SEM_OPEN_compil
577     )
578
579     # Test sem_open by compiling:
580     if(HAVE_SEM_OPEN_compil)
581       set(HAVE_SEM_OPEN 0)
582       message(STATUS "Warning: sem_open not compilable")
583       message(STATUS "HAVE_SEM_OPEN_comp_output: ${HAVE_SEM_OPEN_comp_output}")
584     else()
585       set(HAVE_SEM_OPEN 1)
586       message(STATUS "sem_open is compilable")
587     endif()
588
589     # If we're not crosscompiling, we check by executing the program:
590     if (HAVE_SEM_OPEN AND NOT CMAKE_CROSSCOMPILING)
591       execute_process(COMMAND ./sem_open
592       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
593       RESULT_VARIABLE HAVE_SEM_OPEN_run
594       OUTPUT_VARIABLE var_compil
595       )
596       if (NOT HAVE_SEM_OPEN_run)
597         set(HAVE_SEM_OPEN 1)
598         message(STATUS "sem_open is executable")
599       else()
600         set(HAVE_SEM_OPEN 0)
601         if(EXISTS "${CMAKE_BINARY_DIR}/sem_open")
602           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open exists!")
603         else()
604           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_open not exists!")
605         endif()
606         message(STATUS "Warning: sem_open not executable")
607         message(STATUS "Compilation output: '${var_compil}'")
608         message(STATUS "Exit result of sem_open: ${HAVE_SEM_OPEN_run}")
609       endif()
610     endif()
611     file(REMOVE sem_open)
612
613   else()
614     set(HAVE_SEM_OPEN 0)
615   endif()
616
617   if(HAVE_SEM_INIT_LIB)
618     execute_process(COMMAND ${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_sem_init.c -lpthread -o sem_init
619     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
620     RESULT_VARIABLE HAVE_SEM_INIT_run OUTPUT_VARIABLE HAVE_SEM_INIT_compil)
621
622     # Test sem_init by compiling:
623     if(HAVE_SEM_INIT_compil)
624       set(HAVE_SEM_INIT 0)
625       message(STATUS "Warning: sem_init not compilable")
626       message(STATUS "HAVE_SEM_INIT_comp_output: ${HAVE_SEM_OPEN_comp_output}")
627     else()
628       set(HAVE_SEM_INIT 1)
629       message(STATUS "sem_init is compilable")
630     endif()
631
632     # If we're not crosscompiling, we check by executing the program:
633     if (HAVE_SEM_INIT AND NOT CMAKE_CROSSCOMPILING)
634       execute_process(COMMAND ./sem_init
635       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
636       RESULT_VARIABLE HAVE_SEM_INIT_run
637       OUTPUT_VARIABLE var_compil
638       )
639       if (NOT HAVE_SEM_INIT_run)
640         set(HAVE_SEM_INIT 1)
641         message(STATUS "sem_init is executable")
642       else()
643         set(HAVE_SEM_INIT 0)
644         if(EXISTS "${CMAKE_BINARY_DIR}/sem_init")
645           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init exists!")
646         else()
647           message(STATUS "Bin ${CMAKE_BINARY_DIR}/sem_init not exists!")
648         endif()
649         message(STATUS "Warning: sem_init not executable")
650         message(STATUS "Compilation output: '${var_compil}'")
651         message(STATUS "Exit result of sem_init: ${HAVE_SEM_INIT_run}")
652       endif()
653     endif()
654     file(REMOVE sem_init)
655   endif()
656
657   if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
658     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).")
659   endif()
660
661   ### Test that we have a way to timewait for semaphores
662
663   if(HAVE_SEM_TIMEDWAIT_LIB)
664
665     execute_process(
666       COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_sem_timedwait.c -lpthread"
667       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
668       OUTPUT_VARIABLE HAVE_SEM_TIMEDWAIT_run
669       )
670
671     if(HAVE_SEM_TIMEDWAIT_run)
672       set(HAVE_SEM_TIMEDWAIT 0)
673       message(STATUS "timedwait not compilable")
674     else()
675       set(HAVE_SEM_TIMEDWAIT 1)
676       message(STATUS "timedwait is compilable")
677     endif()
678   endif()
679
680   ### HAVE_MUTEX_TIMEDLOCK
681
682   if(HAVE_MUTEX_TIMEDLOCK_LIB)
683
684     execute_process(
685       COMMAND "${CMAKE_C_COMPILER} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_mutex_timedlock.c -lpthread"
686       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
687       OUTPUT_VARIABLE HAVE_MUTEX_TIMEDLOCK_run
688       )
689
690     if(HAVE_MUTEX_TIMEDLOCK_run)
691       set(HAVE_MUTEX_TIMEDLOCK 0)
692       message(STATUS "timedlock not compilable")
693     else()
694       message(STATUS "timedlock is compilable")
695       set(HAVE_MUTEX_TIMEDLOCK 1)
696     endif()
697   endif()
698 endif()
699
700 # This is needed for ucontext on MacOS X:
701 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
702   add_definitions(-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE)
703 endif()
704
705 if(WIN32)
706   # We always provide our own implementation of ucontext on Windows.
707   try_compile(HAVE_UCONTEXT
708     ${CMAKE_BINARY_DIR}
709     ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_AC_CHECK_MCSC.c
710     COMPILE_DEFINITIONS _XBT_WIN32
711     INCLUDE_DIRECTORIES
712       ${CMAKE_HOME_DIRECTORY}/src/include
713       ${CMAKE_HOME_DIRECTORY}/src/xbt
714   )
715 else()
716   # We always provide our own implementation of ucontext on Windows.
717   try_compile(HAVE_UCONTEXT
718     ${CMAKE_BINARY_DIR}
719     ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_AC_CHECK_MCSC.c)
720 endif()
721
722 #If can have both context
723
724 if(HAVE_UCONTEXT)
725   set(CONTEXT_UCONTEXT 1)
726   message("-- Support for ucontext factory")
727 endif()
728
729 if(HAVE_PTHREAD)
730   set(CONTEXT_THREADS 1)
731   message("-- Support for thread context factory")
732 endif()
733
734 ###############
735 ## GIT version check
736 ##
737 if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
738   execute_process(COMMAND git remote
739   COMMAND head -n 1
740   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
741   OUTPUT_VARIABLE remote
742   RESULT_VARIABLE ret
743   )
744   string(REPLACE "\n" "" remote "${remote}")
745   #message(STATUS "Git remote: ${remote}")
746   execute_process(COMMAND git config --get remote.${remote}.url
747   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
748   OUTPUT_VARIABLE url
749   RESULT_VARIABLE ret
750   )
751   string(REPLACE "\n" "" url "${url}")
752   #message(STATUS "Git url: ${url}")
753   if(url)
754     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=oneline --abbrev-commit -1
755     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
756     OUTPUT_VARIABLE GIT_VERSION
757     RESULT_VARIABLE ret
758     )
759     string(REPLACE "\n" "" GIT_VERSION "${GIT_VERSION}")
760     message(STATUS "Git version: ${GIT_VERSION}")
761     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --pretty=format:%ai .
762     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
763     OUTPUT_VARIABLE GIT_DATE
764     RESULT_VARIABLE ret
765     )
766     string(REPLACE "\n" "" GIT_DATE "${GIT_DATE}")
767     message(STATUS "Git date: ${GIT_DATE}")
768     string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
769     
770     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=format:%H -1
771                     WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
772                     OUTPUT_VARIABLE SIMGRID_GITHASH
773                     RESULT_VARIABLE ret
774                     )
775     string(REPLACE "\n" "" SIMGRID_GITHASH "${SIMGRID_GITHASH}")
776                     
777   endif()
778 elseif(EXISTS ${CMAKE_HOME_DIRECTORY}/.gitversion)
779   FILE(STRINGS ${CMAKE_HOME_DIRECTORY}/.gitversion GIT_VERSION)
780 endif()
781
782 if(release)
783   set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER}\\nRelease build")
784 else()
785   set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER}\\nDevelopment build")
786 endif()
787 if(GIT_VERSION)
788   set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER} at commit ${GIT_VERSION}")
789 endif()
790 if(GIT_DATE)
791   set(SIMGRID_VERSION_BANNER "${SIMGRID_VERSION_BANNER} (${GIT_DATE})")
792 endif()
793 #--------------------------------------------------------------------------------------------------
794
795 set(makecontext_CPPFLAGS_2 "")
796 if(HAVE_MAKECONTEXT OR WIN32)
797   set(makecontext_CPPFLAGS "-DTEST_makecontext")
798   if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
799     set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE=700")
800   endif()
801
802   if(WIN32)
803     if(ARCH_32_BITS)
804       set(makecontext_CPPFLAGS "-DTEST_makecontext -D_I_X86_")
805     else()
806       set(makecontext_CPPFLAGS "-DTEST_makecontext -D_AMD64_")
807     endif()
808     set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt")
809   endif()
810
811   file(REMOVE ${CMAKE_BINARY_DIR}/conftestval)
812
813   if(CMAKE_CROSSCOMPILING)
814     set(RUN_makecontext_VAR "cross")
815     set(COMPILE_makecontext_VAR "cross")
816   else()
817     try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
818       ${CMAKE_BINARY_DIR}
819       ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stacksetup.c
820       COMPILE_DEFINITIONS "${makecontext_CPPFLAGS} ${makecontext_CPPFLAGS_2}"
821       )
822   endif()
823
824   if(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
825     file(READ ${CMAKE_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
826     string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
827     string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
828     string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}")
829     string(REPLACE "," "" makecontext_addr "${MAKECONTEXT_ADDR}")
830     string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}")
831     set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
832     set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
833     message(STATUS "${pth_skaddr_makecontext}")
834     message(STATUS "${pth_sksize_makecontext}")
835   else()
836     # message(FATAL_ERROR "makecontext is not compilable")
837   endif()
838 endif()
839
840 #--------------------------------------------------------------------------------------------------
841
842 ### check for stackgrowth
843 if (NOT CMAKE_CROSSCOMPILING)
844   try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
845     ${CMAKE_BINARY_DIR}
846     ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stackgrowth.c
847     RUN_OUTPUT_VARIABLE stack
848     )
849 endif()
850 if("${stack}" STREQUAL "down")
851   set(PTH_STACKGROWTH "-1")
852 elseif("${stack}" STREQUAL "up")
853   set(PTH_STACKGROWTH "1")
854 else()
855   if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
856     set(PTH_STACKGROWTH "-1")
857   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
858     set(PTH_STACKGROWTH "-1")
859   else()
860     message(ERROR "Could not figure the stack direction.")
861   endif()
862 endif()
863
864 ###############
865 ## System checks
866 ##
867
868 #SG_CONFIGURE_PART([System checks...])
869 #AC_PROG_CC(xlC gcc cc) -auto
870 #AM_SANITY_CHECK -auto
871
872 #AC_PROG_MAKE_SET
873
874 #AC_CHECK_VA_COPY
875
876 set(diff_va "va_copy((d),(s))"
877   "VA_COPY((d),(s))"
878   "__va_copy((d),(s))"
879   "__builtin_va_copy((d),(s))"
880   "do { (d) = (s)\; } while (0)"
881   "do { *(d) = *(s)\; } while (0)"
882   "memcpy((void *)&(d), (void *)&(s), sizeof(s))"
883   "memcpy((void *)(d), (void *)(s), sizeof(*(s)))"
884   )
885
886 foreach(fct ${diff_va})
887   write_file("${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_va_copy.c" "#include <stdlib.h>
888 #include <stdarg.h>
889 #include <string.h>
890 #define DO_VA_COPY(d,s) ${fct}
891 void test(char *str, ...)
892 {
893   va_list ap, ap2;
894   int i;
895   va_start(ap, str);
896   DO_VA_COPY(ap2, ap);
897   for (i = 1; i <= 9; i++) {
898     int k = (int)va_arg(ap, int);
899     if (k != i)
900       abort();
901   }
902   DO_VA_COPY(ap, ap2);
903   for (i = 1; i <= 9; i++) {
904     int k = (int)va_arg(ap, int);
905     if (k != i)
906       abort();
907   }
908   va_end(ap);
909 }
910 int main(void)
911 {
912   test(\"test\", 1, 2, 3, 4, 5, 6, 7, 8, 9);
913   exit(0);
914 }"
915     )
916
917   execute_process(
918   COMMAND ${CMAKE_C_COMPILER} "${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_va_copy.c"
919   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
920   RESULT_VARIABLE COMPILE_VA_NULL_VAR
921   OUTPUT_QUIET
922   ERROR_QUIET
923   )
924
925   if(NOT COMPILE_VA_NULL_VAR)
926     string(REGEX REPLACE "\;" "" fctbis ${fct})
927     if(${fctbis} STREQUAL "va_copy((d),(s))")
928       set(HAVE_VA_COPY 1)
929       set(ac_cv_va_copy "C99")
930       set(__VA_COPY_USE_C99 "va_copy((d),(s))")
931     endif()
932
933     if(${fctbis} STREQUAL "VA_COPY((d),(s))")
934       set(ac_cv_va_copy "GCM")
935       set(__VA_COPY_USE_GCM "VA_COPY((d),(s))")
936     endif()
937
938     if(${fctbis} STREQUAL "__va_copy((d),(s))")
939       set(ac_cv_va_copy "GCH")
940       set(__VA_COPY_USE_GCH "__va_copy((d),(s))")
941     endif()
942
943     if(${fctbis} STREQUAL "__builtin_va_copy((d),(s))")
944       set(ac_cv_va_copy "GCB")
945       set(__VA_COPY_USE_GCB "__builtin_va_copy((d),(s))")
946     endif()
947
948     if(${fctbis} STREQUAL "do { (d) = (s) } while (0)")
949       set(ac_cv_va_copy "ASS")
950       set(__VA_COPY_USE_ASS "do { (d) = (s); } while (0)")
951     endif()
952
953     if(${fctbis} STREQUAL "do { *(d) = *(s) } while (0)")
954       set(ac_cv_va_copy "ASP")
955       set(__VA_COPY_USE_ASP "do { *(d) = *(s); } while (0)")
956     endif()
957
958     if(${fctbis} STREQUAL "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
959       set(ac_cv_va_copy "CPS")
960       set(__VA_COPY_USE_CPS "memcpy((void *)&(d), (void *)&(s), sizeof(s))")
961     endif()
962
963     if(${fctbis} STREQUAL "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
964       set(ac_cv_va_copy "CPP")
965       set(__VA_COPY_USE_CPP "memcpy((void *)(d), (void *)(s), sizeof(*(s)))")
966     endif()
967
968     if(NOT STATUS_OK)
969       set(__VA_COPY_USE "__VA_COPY_USE_${ac_cv_va_copy}(d, s)")
970     endif()
971     set(STATUS_OK "1")
972
973   endif()
974
975 endforeach(fct ${diff_va})
976
977 #--------------------------------------------------------------------------------------------------
978 ### check for a working snprintf
979 if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
980   if(WIN32)
981     #set(HAVE_SNPRINTF 1)
982     #set(HAVE_VSNPRINTF 1)
983   endif()
984
985   if(CMAKE_CROSSCOMPILING)
986     set(RUN_SNPRINTF_FUNC "cross")
987     #set(PREFER_PORTABLE_SNPRINTF 1)
988   else()
989     try_run(RUN_SNPRINTF_FUNC_VAR COMPILE_SNPRINTF_FUNC_VAR
990       ${CMAKE_BINARY_DIR}
991       ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_snprintf.c
992       )
993   endif()
994
995   if(CMAKE_CROSSCOMPILING)
996     set(RUN_VSNPRINTF_FUNC "cross")
997     set(PREFER_PORTABLE_VSNPRINTF 1)
998   else()
999     try_run(RUN_VSNPRINTF_FUNC_VAR COMPILE_VSNPRINTF_FUNC_VAR
1000       ${CMAKE_BINARY_DIR}
1001       ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_vsnprintf.c
1002       )
1003   endif()
1004
1005   set(PREFER_PORTABLE_SNPRINTF 0)
1006   if(RUN_VSNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
1007     set(PREFER_PORTABLE_SNPRINTF 1)
1008   endif()
1009   if(RUN_SNPRINTF_FUNC_VAR MATCHES "FAILED_TO_RUN")
1010     set(PREFER_PORTABLE_SNPRINTF 1)
1011   endif()
1012 endif()
1013
1014 ### check for asprintf function familly
1015 if(HAVE_ASPRINTF)
1016   SET(simgrid_need_asprintf "")
1017   SET(NEED_ASPRINTF 0)
1018 else()
1019   SET(simgrid_need_asprintf "#define SIMGRID_NEED_ASPRINTF 1")
1020   SET(NEED_ASPRINTF 1)
1021 endif()
1022
1023 if(HAVE_VASPRINTF)
1024   SET(simgrid_need_vasprintf "")
1025   SET(NEED_VASPRINTF 0)
1026 else()
1027   SET(simgrid_need_vasprintf "#define SIMGRID_NEED_VASPRINTF 1")
1028   SET(NEED_VASPRINTF 1)
1029 endif()
1030
1031 ### check for addr2line
1032
1033 find_path(ADDR2LINE NAMES addr2line     PATHS NO_DEFAULT_PATHS  )
1034 if(ADDR2LINE)
1035   set(ADDR2LINE "${ADDR2LINE}/addr2line")
1036 endif()
1037
1038 ### File to create
1039
1040 configure_file("${CMAKE_HOME_DIRECTORY}/src/context_sysv_config.h.in"
1041   "${CMAKE_BINARY_DIR}/src/context_sysv_config.h" @ONLY IMMEDIATE)
1042
1043 SET( CMAKEDEFINE "#cmakedefine" )
1044 configure_file("${CMAKE_HOME_DIRECTORY}/tools/cmake/src/internal_config.h.in" "${CMAKE_BINARY_DIR}/src/internal_config.h" @ONLY IMMEDIATE)
1045 configure_file("${CMAKE_BINARY_DIR}/src/internal_config.h" "${CMAKE_BINARY_DIR}/src/internal_config.h" @ONLY IMMEDIATE)
1046 configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid_config.h.in" "${CMAKE_BINARY_DIR}/include/simgrid_config.h" @ONLY IMMEDIATE)
1047
1048 set(top_srcdir "${CMAKE_HOME_DIRECTORY}")
1049 set(srcdir "${CMAKE_HOME_DIRECTORY}/src")
1050 set(bindir "${CMAKE_BINARY_DIR}")
1051
1052 ### Script used when simgrid is installed
1053 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
1054 set(includeflag "-I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/smpi")
1055 set(includedir "${CMAKE_INSTALL_PREFIX}/include")
1056 set(libdir ${exec_prefix}/lib)
1057 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_INSTALL_PREFIX}/lib")
1058 if(NS3_LIBRARY_PATH)
1059   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${NS3_LIBRARY_PATH}")
1060 endif()
1061 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
1062
1063 file(READ ${CMAKE_HOME_DIRECTORY}/src/smpi/smpitools.sh SMPITOOLS_SH)
1064 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/mpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/mpif.h @ONLY)
1065 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/bin/smpicc @ONLY)
1066 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicxx.in ${CMAKE_BINARY_DIR}/bin/smpicxx @ONLY)
1067 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpiff.in ${CMAKE_BINARY_DIR}/bin/smpiff @ONLY)
1068 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpif90.in ${CMAKE_BINARY_DIR}/bin/smpif90 @ONLY)
1069 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_BINARY_DIR}/bin/smpirun @ONLY)
1070
1071 ### Script used when simgrid is compiling
1072 set(includeflag "-I${CMAKE_HOME_DIRECTORY}/include -I${CMAKE_HOME_DIRECTORY}/include/smpi")
1073 set(includeflag "${includeflag} -I${CMAKE_BINARY_DIR}/include -I${CMAKE_BINARY_DIR}/include/smpi")
1074 set(includedir "${CMAKE_HOME_DIRECTORY}/include")
1075 set(exec_prefix "${CMAKE_BINARY_DIR}/smpi_script/")
1076 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_BINARY_DIR}/lib")
1077 if(NS3_LIBRARY_PATH)
1078   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${NS3_LIBRARY_PATH}")
1079 endif()
1080 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
1081 set(libdir "${CMAKE_BINARY_DIR}/lib")
1082
1083 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicc.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc @ONLY)
1084 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpicxx.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx @ONLY)
1085 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpiff.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpiff @ONLY)
1086 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpif90.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpif90 @ONLY)
1087 configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpirun.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun @ONLY)
1088
1089 set(top_builddir ${CMAKE_HOME_DIRECTORY})
1090
1091 if(NOT WIN32)
1092   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc)
1093   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicxx)
1094   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff)
1095   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif90)
1096   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun)
1097   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc)
1098   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx)
1099   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpiff)
1100   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpif90)
1101   execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun)
1102 endif()
1103
1104 set(generated_headers_to_install
1105   ${CMAKE_CURRENT_BINARY_DIR}/include/smpi/mpif.h
1106   ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid_config.h
1107   )
1108
1109 set(generated_headers
1110   ${CMAKE_CURRENT_BINARY_DIR}/src/context_sysv_config.h
1111   ${CMAKE_CURRENT_BINARY_DIR}/src/internal_config.h
1112   )
1113
1114 set(generated_files_to_clean
1115   ${generated_headers}
1116   ${generated_headers_to_install}
1117   ${CMAKE_BINARY_DIR}/bin/smpicc
1118   ${CMAKE_BINARY_DIR}/bin/smpicxx
1119   ${CMAKE_BINARY_DIR}/bin/smpiff
1120   ${CMAKE_BINARY_DIR}/bin/smpif90
1121   ${CMAKE_BINARY_DIR}/bin/smpirun
1122   ${CMAKE_BINARY_DIR}/bin/colorize
1123   ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
1124   ${CMAKE_BINARY_DIR}/examples/smpi/tracing/smpi_traced.trace
1125   )
1126
1127 if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
1128   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions0.txt COPYONLY)
1129   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions1.txt COPYONLY)
1130   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_allReduce.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allReduce.txt COPYONLY)
1131   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_barrier.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_barrier.txt COPYONLY)
1132   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_bcast.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_bcast.txt COPYONLY)
1133   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_with_isend.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_with_isend.txt COPYONLY)
1134   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_alltoall.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoall.txt COPYONLY)
1135   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_alltoallv.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoallv.txt COPYONLY)
1136   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_waitall.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_waitall.txt COPYONLY)
1137   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_reducescatter.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_reducescatter.txt COPYONLY)
1138   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_gather.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_gather.txt COPYONLY)
1139   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_allgatherv.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allgatherv.txt COPYONLY)
1140   configure_file(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/hostfile ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile COPYONLY)
1141   
1142   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/description_file ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/description_file COPYONLY)
1143   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/README ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/README COPYONLY)
1144   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/smpi_replay.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/smpi_replay.txt COPYONLY)
1145   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt COPYONLY)
1146   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt COPYONLY)
1147   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt COPYONLY)
1148   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt COPYONLY)
1149   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt COPYONLY)
1150   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt COPYONLY)
1151   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt COPYONLY)
1152   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt COPYONLY)
1153   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt COPYONLY)
1154   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt COPYONLY)
1155   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt COPYONLY)
1156   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt COPYONLY)
1157   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt COPYONLY)
1158   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt COPYONLY)
1159   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt COPYONLY)
1160   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt COPYONLY)
1161   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt COPYONLY)
1162   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt COPYONLY)
1163   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt COPYONLY)
1164   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt COPYONLY)
1165   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt COPYONLY)
1166   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt COPYONLY)
1167   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt COPYONLY)
1168   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt COPYONLY)
1169   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt COPYONLY)
1170   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt COPYONLY)
1171   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt COPYONLY)
1172   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt COPYONLY)
1173   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt COPYONLY)
1174   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt COPYONLY)
1175   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt COPYONLY)
1176   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt COPYONLY)
1177
1178   set(generated_files_to_clean
1179     ${generated_files_to_clean}
1180     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions0.txt
1181     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions1.txt
1182     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allReduce.txt
1183     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_barrier.txt
1184     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_bcast.txt
1185     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_with_isend.txt
1186     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoall.txt
1187     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoallv.txt
1188     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_waitall.txt
1189     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_gather.txt
1190     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allgatherv.txt
1191     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_reducescatter.txt
1192     ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile
1193     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/description_file
1194     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/README
1195     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/smpi_replay.txt
1196     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt
1197     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt
1198     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt
1199     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt
1200     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt
1201     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt
1202     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt
1203     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt
1204     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt
1205     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt
1206     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt
1207     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt
1208     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt
1209     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt
1210     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt
1211     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt
1212     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt
1213     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt
1214     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt
1215     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt
1216     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt
1217     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt
1218     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt
1219     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt
1220     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt
1221     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt
1222     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt
1223     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt
1224     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt
1225     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt
1226     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt
1227     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt
1228     )
1229 endif()
1230
1231 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
1232   "${generated_files_to_clean}")
1233
1234 IF(${ARCH_32_BITS})
1235   set(WIN_ARCH "32")
1236 ELSE()
1237   set(WIN_ARCH "64")
1238 ENDIF()
1239 configure_file("${CMAKE_HOME_DIRECTORY}/tools/cmake/src/simgrid.nsi.in" "${CMAKE_BINARY_DIR}/simgrid.nsi" @ONLY IMMEDIATE)
1240
1241 ### Define source packages for Libs
1242 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/DefinePackages.cmake)
1243
1244 ### Build some Maintainer files
1245 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MaintainerMode.cmake)
1246 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/UnitTesting.cmake)
1247
1248 ### Setup gcc & clang flags
1249 if (NOT MSVC)
1250   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/GCCFlags.cmake)
1251 endif()
1252
1253 ### Make Libs
1254 if(NOT WIN32)
1255   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeLib.cmake)
1256 else()
1257   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeLibWin.cmake)
1258 endif()
1259
1260 if(enable_java)
1261   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Java.cmake)
1262 endif()
1263
1264 ### Make tests
1265 if(enable_memcheck_xml)
1266   set(enable_memcheck true)
1267 endif()
1268
1269 INCLUDE(CTest)
1270 ENABLE_TESTING()
1271 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Tests.cmake)
1272 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/CTestConfig.cmake)
1273
1274 ### Define subdirectories
1275 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeExe.cmake)
1276
1277 ### Setup the distrib
1278 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Distrib.cmake)
1279
1280 ### Build the doc (Windows downloads the doc instead of regenerating)
1281 #
1282 if(NOT WIN32)
1283   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Documentation.cmake)
1284 else()
1285   find_program(WGET_PROGRAM  NAMES wget)
1286   message(STATUS "wget: ${WGET_PROGRAM}")
1287   if(WGET_PROGRAM)
1288     ADD_CUSTOM_TARGET(simgrid_documentation
1289       COMMENT "Downloading the SimGrid documentation..."
1290       COMMAND ${WGET_PROGRAM} -r -np -nH -nd http://simgrid.gforge.inria.fr/simgrid/${release_version}/doc/
1291       WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/html
1292     )
1293   endif()
1294 endif()
1295
1296 ### Print ARGS
1297 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/PrintArgs.cmake)
1298
1299 INCLUDE(Dart)