Logo AND Algorithmique Numérique Distribuée

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