Logo AND Algorithmique Numérique Distribuée

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