Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify how we check for C++11 and friends
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.8)
2 message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
3 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/tools/cmake/Modules)
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 INCLUDE(CheckCCompilerFlag)
20 CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER)
21
22 ## Request full debugging flags
23 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
24 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
25 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
26
27 if (CMAKE_COMPILER_IS_GNUCC)    
28   if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
29     message(FATAL_ERROR
30             "SimGrid needs at least g++ version 4.7 to compile but you have ${CMAKE_CXX_COMPILER_VERSION}."
31             "You need a sufficient support of c++11 to compile SimGrid.")
32   endif()
33 endif()
34
35 ## We need a decent support of the C++11 and C11 standards
36 set(CMAKE_CXX_STANDARD 11)
37 set(CMAKE_CXX_STANDARD_REQUIRED ON)
38
39 set(CMAKE_C_STANDARD 11)
40 set(CMAKE_C_STANDARD_REQUIRED ON)
41
42 ### Check threading support
43 set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
44 find_package(Threads)
45
46 ### Setup Options
47 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Option.cmake)
48
49 ### SMPI vs. Fortran
50 if ((NOT DEFINED enable_smpi) OR enable_smpi) 
51   # First unset the compiler in case we're re-running cmake over a previous
52   # configuration where it was saved as smpiff
53   unset(CMAKE_Fortran_COMPILER)
54   
55   SET(SMPI_FORTRAN 0)
56   if(enable_fortran)
57     enable_language(Fortran OPTIONAL)
58   endif()
59   
60   if(CMAKE_Fortran_COMPILER)
61
62     # Fortran compiler detected: save it, then replace by smpiff
63     set(SMPI_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "The real Fortran compiler")
64
65         # Set flags/libs to be used in smpiff
66     if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
67       set(SMPI_Fortran_FLAGS "\"-fpic\" \"-ff2c\" \"-fno-second-underscore\"")
68       set(SMPI_Fortran_LIBS "\"-lgfortran\"")
69       set(SMPI_GFORTRAN 1)
70     elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
71       set(SMPI_Fortran_FLAGS "\"-fPIC\" \"-nofor-main\"")
72       set(SMPI_Fortran_LIBS "\"-lifcore\"")
73       set(SMPI_IFORT 1)
74     elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI|Flang") # flang
75       set(SMPI_Fortran_FLAGS "\"-fPIC\"")
76       set(SMPI_Fortran_LIBS "")
77       set(SMPI_FLANG 1)
78     endif()
79
80     set(SMPI_FORTRAN 1)
81   endif(CMAKE_Fortran_COMPILER)
82
83 endif()
84
85 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
86 #     Build the version number      #
87 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
88
89 set(SIMGRID_VERSION_MAJOR "3")
90 set(SIMGRID_VERSION_MINOR "21")
91 set(SIMGRID_VERSION_PATCH "90")
92 set(SIMGRID_VERSION_EXTRA "-DEVEL") # Extra words to add to version string (e.g. -rc1)
93
94 set(SIMGRID_VERSION_DATE  "2018") # Year for copyright information
95
96 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
97   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
98 else()
99   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}.${SIMGRID_VERSION_PATCH}")
100 endif()
101
102 set(SIMGRID_VERSION_STRING "SimGrid version ${release_version}${SIMGRID_VERSION_EXTRA}")
103
104 set(libsimgrid_version "${release_version}")
105 set(libsimgrid-java_version "${release_version}")
106
107 ### SET THE LIBRARY EXTENSION 
108 if(APPLE)
109   set(LIB_EXE "dylib")
110 elseif(WIN32)
111   set(LIB_EXE "a")
112   set(BIN_EXE ".exe")
113 else()
114   set(LIB_EXE "so")
115 endif()
116
117 execute_process(COMMAND ${CMAKE_LINKER} -version OUTPUT_VARIABLE LINKER_VERSION ERROR_VARIABLE LINKER_VERSION)
118 string(REGEX MATCH "[0-9].[0-9]*" LINKER_VERSION "${LINKER_VERSION}")
119
120 ### Set the library providing dlopen
121 if("${CMAKE_SYSTEM_NAME}" MATCHES "kFreeBSD|Linux")
122   find_library(DL_LIBRARY dl)
123 endif()
124
125 ### Find programs and paths
126 FIND_PROGRAM(GCOV_PATH gcov)
127 include(FindPerl)
128 if(NOT PERL_FOUND)
129   message(FATAL_ERROR "Please install Perl to compile SimGrid.")
130 endif()
131
132 # tesh.py needs python 3 (or the module python-subprocess32 on python2.8+)
133 set(PythonInterp_FIND_VERSION 3)
134 set(PythonInterp_FIND_VERSION_COUNT 1)
135 set(PythonInterp_FIND_VERSION_MAJOR 3)
136 include(FindPythonInterp)
137 if(NOT PYTHONINTERP_FOUND)
138   message(FATAL_ERROR "Please install Python (version 3 or higher).")
139 endif()
140
141 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
142
143 ### Compute the include paths
144
145 # Only include public headers by default
146 include_directories(
147    ${CMAKE_BINARY_DIR}/include
148    ${CMAKE_HOME_DIRECTORY}/include
149 )
150
151 # Compute the ones that should be added when compiling the library
152 set(INTERNAL_INCLUDES
153   ${CMAKE_BINARY_DIR}
154   ${CMAKE_HOME_DIRECTORY}
155   ${CMAKE_HOME_DIRECTORY}/src/include
156   )
157
158 if(enable_smpi)
159   set (INTERNAL_INCLUDES ${INTERNAL_INCLUDES} ${CMAKE_HOME_DIRECTORY}/src/smpi/include)
160 endif()
161
162 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
163   set(INTERNAL_INCLUDES ${INTERNAL_INCLUDES} /usr/include/)
164 endif()
165
166 if(WIN32)
167   set(CMAKE_INCLUDE_WIN "${CMAKE_C_COMPILER}")
168   set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}")
169   string(REGEX REPLACE "/bin/gcc.*" "/include"  CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}")
170   string(REGEX REPLACE "/bin/gcc.*" "/lib"  CMAKE_LIB_WIN "${CMAKE_LIB_WIN}")
171   set(INTERNAL_INCLUDES ${INTERNAL_INCLUDES} ${CMAKE_INCLUDE_WIN})
172   unset(CMAKE_INCLUDE_WIN)
173 endif()
174
175 # library dependency cannot start with a space (CMP0004), so initialize it with something that is never desactivated.
176 set(SIMGRID_DEP "-lm") 
177
178 ### Determine the assembly flavor that we need today
179 set(HAVE_RAW_CONTEXTS 0)
180 include(CMakeDetermineSystem)
181 IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64")
182   IF(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32 bits
183     message(STATUS "System processor: i686 (${CMAKE_SYSTEM_PROCESSOR}, 32 bits)")
184     set(SIMGRID_PROCESSOR_i686 1)
185     set(SIMGRID_PROCESSOR_x86_64 0)
186   ELSE()
187     message(STATUS "System processor: x86_64 (${CMAKE_SYSTEM_PROCESSOR}, 64 bits)")
188     set(SIMGRID_PROCESSOR_i686 0)
189     set(SIMGRID_PROCESSOR_x86_64 1)
190   ENDIF()
191   if (WIN32)
192     message(STATUS "Disable fast raw contexts on Windows.")
193   else()
194     set(HAVE_RAW_CONTEXTS 1)
195   endif()
196 ELSE()
197   set(SIMGRID_PROCESSOR_i686 0)
198   set(SIMGRID_PROCESSOR_x86_64 0)
199 ENDIF()
200
201 include(CheckFunctionExists)
202 include(CheckTypeSize)
203 include(CheckIncludeFile)
204 include(CheckIncludeFiles)
205 include(CheckLibraryExists)
206 include(CheckSymbolExists)
207
208 set(HAVE_GRAPHVIZ 0)
209 include(FindGraphviz)
210
211 set(SIMGRID_HAVE_LUA 0)
212 if(enable_lua)
213   include(FindLuaSimgrid)
214 endif()
215
216 set(SIMGRID_HAVE_NS3 0)
217 if(enable_ns3)
218   include(FindNS3)
219   if (SIMGRID_HAVE_NS3)
220     set(SIMGRID_HAVE_NS3 1)
221     foreach(lib core csma point-to-point internet network applications)
222       set(SIMGRID_DEP "${SIMGRID_DEP} -lns${NS3_VERSION}-${lib}${NS3_SUFFIX}")
223     endforeach()
224   else()
225     message(FATAL_ERROR "Cannot find NS3. Please install it (apt-get install ns3 libns3-dev) or disable that cmake option")
226   endif()
227 endif()
228
229 if(WIN32)
230   set(Boost_USE_STATIC_LIBS 1)
231 endif()
232
233 set(HAVE_PAPI 0)
234 if(enable_smpi_papi)
235   include(FindPAPI)
236   if (NOT HAVE_PAPI)
237     message(FATAL_ERROR "Cannot find PAPI. Please install it (apt-get install papi-tools libpapi-dev) or disable PAPI bindings.")
238   endif()
239 endif()
240
241 # Not finding this is perfectly OK
242 find_package(Boost 1.59 COMPONENTS unit_test_framework)
243 if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
244   message(STATUS "Enabling the Boost-based unit tests.")
245 else()
246   message(STATUS "Disabling the Boost-based unit tests -- please install libboost-test-dev (>= v1.59).")
247 endif()
248
249
250 find_package(Boost 1.48)
251 if(Boost_FOUND)
252   include_directories(${Boost_INCLUDE_DIRS})
253 else()
254   if(APPLE)
255     message(FATAL_ERROR "Boost libraries not found. Try to install them with 'sudo fink install boost1.53.nopython' (check the exact name with 'fink list boost') or 'sudo brew install boost'")
256   else()
257     message(FATAL_ERROR "Boost libraries not found. Install libboost-dev (>= 1.48.0).")
258   endif()
259 endif()
260
261 find_package(Boost COMPONENTS context)
262 set(Boost_FOUND 1) # This component is optional
263 if(Boost_CONTEXT_FOUND)
264   message(STATUS "Found Boost.Context")
265   set(HAVE_BOOST_CONTEXTS 1)
266 else()
267   message ("   boost        : found.")
268   message ("   boost-context: missing. Install libboost-context-dev for this optional feature.")
269   set(HAVE_BOOST_CONTEXTS 0)
270 endif()
271
272 # Checks for header libraries functions.
273 CHECK_LIBRARY_EXISTS(rt      clock_gettime           "" HAVE_POSIX_GETTIME)
274
275 set(HAVE_PTHREAD_SETAFFINITY 0)
276 CHECK_LIBRARY_EXISTS(pthread pthread_setaffinity_np  "" HAVE_PTHREAD_SETAFFINITY)
277
278 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
279   set(CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE")
280 elseif(MINGW)
281   # Use the GNU version of unusual modifiers like PRIx64
282   add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
283   set(CMAKE_REQUIRED_DEFINITIONS "-D__USE_MINGW_ANSI_STDIO=1")
284 else()
285   set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
286 endif()
287
288 CHECK_INCLUDE_FILE("valgrind/valgrind.h" HAVE_VALGRIND_H)
289 CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
290 CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
291 CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
292 CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
293 CHECK_INCLUDE_FILE("sys/sysctl.h" HAVE_SYS_SYSCTL_H)
294 CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
295 CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
296
297 CHECK_FUNCTION_EXISTS(backtrace HAVE_BACKTRACE)
298 CHECK_FUNCTION_EXISTS(dlfunc HAVE_DLFUNC)
299 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
300 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
301 CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
302 CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
303 CHECK_FUNCTION_EXISTS(popen HAVE_POPEN)
304 CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV)
305 CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
306 CHECK_FUNCTION_EXISTS(mremap HAVE_MREMAP)
307
308 CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF)
309 if(MINGW)
310   # The detection of vasprintf fails on MinGW, assumingly because it's
311   # defined as an inline function in stdio.h instead of a regular
312   # function. So force the result to be 1 despite of the test.
313   set(HAVE_VASPRINTF 1)
314 endif()
315
316 CHECK_INCLUDE_FILE("sys/sendfile.h" HAVE_SENDFILE_H)
317 CHECK_FUNCTION_EXISTS(sendfile HAVE_SENDFILE)
318 if(HAVE_SENDFILE_H AND HAVE_SENDFILE)
319   set(HAVE_SENDFILE 1)
320 else()
321   set(HAVE_SENDFILE 0)
322 endif()
323
324 if(enable_model-checking AND NOT "${CMAKE_SYSTEM}" MATCHES "Linux|FreeBSD")
325   message(WARNING "Support for model-checking has not been enabled on ${CMAKE_SYSTEM}: disabling it")
326   set(enable_model-checking FALSE)
327 endif()
328
329 if(HAVE_MMAP)
330   SET(HAVE_MMALLOC 1)
331 else()
332   SET(HAVE_MMALLOC 0)
333   if(enable_model-checking)
334     message(STATUS "Warning: support for model-checking has been disabled because you are missing either mmap or __thread.")
335   endif()
336   SET(enable_model-checking 0)
337 endif()
338
339 if(enable_jedule)
340   set(SIMGRID_HAVE_JEDULE 1)
341 else()
342   set(SIMGRID_HAVE_JEDULE 0)
343 endif()
344
345 if(enable_mallocators)
346   SET(SIMGRID_HAVE_MALLOCATOR 1)
347 else()
348   SET(SIMGRID_HAVE_MALLOCATOR 0)
349 endif()
350
351 include(FindLibunwind)
352 if(HAVE_LIBUNWIND)
353   SET(SIMGRID_DEP "${SIMGRID_DEP} ${LIBUNWIND_LIBRARIES}")
354 else()
355   if(enable_model-checking)
356     message(FATAL_ERROR "Please install libunwind-dev libdw-dev libelf-dev libevent-dev if you want to compile the SimGrid model checker.")
357   endif()
358 endif()
359
360 if(enable_model-checking)
361   find_package(Libdw REQUIRED)
362   find_package(Libelf REQUIRED)
363   find_package(Libevent REQUIRED)
364   include_directories(${LIBDW_INCLUDE_DIR} ${LIBELF_INCLUDE_DIR} ${LIBEVENT_INCLUDE_DIR})
365   set(SIMGRID_DEP "${SIMGRID_DEP} ${LIBEVENT_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBDW_LIBRARIES}")
366   set(SIMGRID_HAVE_MC 1)
367   if("${CMAKE_SYSTEM}" MATCHES "FreeBSD" AND enable_java)
368     message(WARNING "FreeBSD + Model-Checking + Java = too much for now. Disabling java")
369     set(enable_java FALSE)
370   endif()
371 else()
372   SET(SIMGRID_HAVE_MC 0)  
373   set(HAVE_MMALLOC 0)
374 endif()
375 mark_as_advanced(PATH_LIBDW_H)
376 mark_as_advanced(PATH_LIBDW_LIB)
377
378 if (enable_model-checking AND enable_ns3)
379   message(FATAL_ERROR "Cannot activate both model-checking and NS3 bindings: NS3 pull too much dependencies for the MC to work")
380 endif()
381
382 if(enable_smpi)
383   SET(HAVE_SMPI 1)
384   if("${CMAKE_SYSTEM}" MATCHES "Darwin|FreeBSD|Linux")
385     SET(USE_LIBUTIL 0)
386     SET(HAVE_PRIVATIZATION 1)
387   else()
388     message (STATUS "Warning:  no support for SMPI automatic privatization on this platform")
389     SET(HAVE_PRIVATIZATION 0)
390   endif()
391 else()
392   SET(HAVE_SMPI 0)
393 endif()
394
395 #--------------------------------------------------------------------------------------------------
396 ### Initialize of CONTEXT THREADS
397
398 set(HAVE_THREAD_CONTEXTS 0)
399 if(CMAKE_USE_PTHREADS_INIT)
400   ### Test that we have a way to create semaphores
401
402   set(HAVE_SEM_OPEN 0)
403   CHECK_LIBRARY_EXISTS(pthread sem_open "" HAVE_SEM_OPEN_LIB)
404   if(HAVE_SEM_OPEN_LIB)
405     try_run(semopen_retval semopen_compilable
406             ${CMAKE_BINARY_DIR}
407             ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_sem_open.c
408             LINK_LIBRARIES pthread
409             COMPILE_OUTPUT_VARIABLE semopen_compilmsg
410             RUN_OUTPUT_VARIABLE semopen_runmsg)
411     
412     if(semopen_compilable)
413       if(NOT semopen_retval) #¬†error if not 0
414         message(STATUS "sem_open is compilable and executable")
415         set(HAVE_SEM_OPEN 1)
416       else()
417         message(STATUS "Warning: sem_open seems compilable but not executable")
418         message(STATUS "Compilation output: ${semopen_compilmsg}")
419         message(STATUS "Execution output: ${semopen_runmsg}")
420         message(STATUS "Exit value: ${semopen_retval}")
421       endif()
422     else()
423       message(STATUS "Warning: sem_open not compilable")
424       message(STATUS "Compilation output: ${semopen_compilmsg}")
425     endif()
426     unset(semopen_compilable)
427     unset(semopen_retval)
428     unset(semopen_runmsg)
429     unset(semopen_compilmsg)
430   endif()
431
432   set(HAVE_SEM_INIT 0)  
433   if(NOT APPLE) # OS X El Capitan deprecates this function
434     CHECK_LIBRARY_EXISTS(pthread sem_init "" HAVE_SEM_INIT_LIB)
435   endif()
436   if(HAVE_SEM_INIT_LIB)
437     try_run(seminit_retval seminit_compilable
438             ${CMAKE_BINARY_DIR}
439             ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_sem_init.c
440             LINK_LIBRARIES pthread
441             COMPILE_OUTPUT_VARIABLE seminit_compilmsg
442             RUN_OUTPUT_VARIABLE seminit_runmsg)
443     
444     if(seminit_compilable)
445       if(NOT seminit_retval) #¬†error if not 0
446         message(STATUS "sem_init is compilable and executable")
447         set(HAVE_SEM_INIT 1)
448       else()
449         message(STATUS "Warning: sem_init seems compilable but not executable")
450         message(STATUS "Compilation output: ${seminit_compilmsg}")
451         message(STATUS "Execution output: ${seminit_runmsg}")
452         message(STATUS "Exit value: ${seminit_retval}")
453       endif()
454     else()
455       message(STATUS "Warning: sem_init not compilable")
456       message(STATUS "Compilation output: ${seminit_compilmsg}")
457     endif()
458     unset(seminit_compilable)
459     unset(seminit_retval)
460     unset(seminit_runmsg)
461     unset(seminit_compilmsg)
462   endif()
463
464   if(NOT HAVE_SEM_OPEN AND NOT HAVE_SEM_INIT)
465     message(FATAL_ERROR "Semaphores are not usable (failed to use both sem_open and sem_init), but they are mandatory to threads (you may need to mount /dev).")
466   endif()
467
468   set(HAVE_THREAD_CONTEXTS 1)
469   message(STATUS "Support for thread context factory ok.")
470 endif()
471
472 set(HAVE_UCONTEXT_CONTEXTS 0)
473 if(NOT HAVE_UCONTEXT_H)
474   message(STATUS "No ucontext factory: <ucontext.h> not found.")
475 elseif(APPLE)
476   message(STATUS "No ucontext factory: Apple don't want us to use them.")
477   set(HAVE_UCONTEXT_H 0)
478 else()
479   try_compile(compile_makecontext ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_makecontext.c
480     OUTPUT_VARIABLE compile_makecontext_output)
481
482   #If can have both context
483   if(compile_makecontext)
484     set(HAVE_UCONTEXT_CONTEXTS 1)
485     message(STATUS "Support for ucontext factory ok.")
486   else()
487     message(STATUS "Error: <ucontext.h> exists, but makecontext is not compilable. Compilation output:\n ${compile_makecontext_output}")
488     message(STATUS "No ucontext factory: makecontext() is not compilable.")
489   endif()
490
491   # Stack setup (size and address)
492   try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
493     ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stacksetup.c
494     RUN_OUTPUT_VARIABLE stack_setup)
495
496   LIST(LENGTH stack_setup stack_setup_len)
497   if("${stack_setup_len}" STREQUAL "2")
498     LIST(GET stack_setup 0 makecontext_addr)
499     LIST(GET stack_setup 1 makecontext_size)
500     set(sg_makecontext_stack_addr "#define sg_makecontext_stack_addr(skaddr) (${makecontext_addr})")
501     set(sg_makecontext_stack_size "#define sg_makecontext_stack_size(sksize) (${makecontext_size})")
502   else()
503     message(FATAL_ERROR "Could not figure out the stack setup. Compil: ${RUN_makecontext_VAR}. Exec: ${COMPILE_makecontext_VAR}. Output: ${stack_setup}")
504   endif()
505 endif()
506
507 # Stack growth direction (upward or downward). Used for the following contexts: SysV, raw, Boost
508 try_run(RUN_stackgrowth_VAR COMPILE_stackgrowth_VAR
509   ${CMAKE_BINARY_DIR}
510   ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stackgrowth.c
511   RUN_OUTPUT_VARIABLE stack
512   COPY_FILE test_stackgrowth)
513
514 if("${stack}" STREQUAL "down")
515   set(PTH_STACKGROWTH "-1")
516 elseif("${stack}" STREQUAL "up")
517   set(PTH_STACKGROWTH "1")
518 else()
519   if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
520     set(PTH_STACKGROWTH "-1")
521   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
522     set(PTH_STACKGROWTH "-1")
523   else()
524     message(FATAL_ERROR "Could not figure out the stack direction. Test prog returned: ${stack}; CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}.")
525   endif()
526 endif()
527 # If the test ran well, remove the test binary
528 file(REMOVE test_stackgrowth)
529 #--------------------------------------------------------------------------------------------------
530
531 ### check for addr2line
532 find_path(ADDR2LINE NAMES addr2line     PATHS NO_DEFAULT_PATHS)
533 if(ADDR2LINE)
534   set(ADDR2LINE "${ADDR2LINE}/addr2line")
535 endif()
536
537 ###############
538 ## GIT version check
539 ##
540 if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
541   execute_process(
542      COMMAND git remote
543      COMMAND head -n 1
544      WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
545      OUTPUT_VARIABLE remote
546      OUTPUT_STRIP_TRAILING_WHITESPACE)
547   #message(STATUS "Git remote: ${remote}")
548   execute_process(COMMAND git config --get remote.${remote}.url
549      WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
550      OUTPUT_VARIABLE url
551      OUTPUT_STRIP_TRAILING_WHITESPACE)
552   #message(STATUS "Git url: ${url}")
553   if(url)
554     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=oneline --abbrev-commit -1
555        WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
556        OUTPUT_VARIABLE GIT_VERSION
557        OUTPUT_STRIP_TRAILING_WHITESPACE)
558     message(STATUS "Git version: ${GIT_VERSION}")
559
560     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --pretty=format:%ai .
561        WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
562        OUTPUT_VARIABLE GIT_DATE 
563        OUTPUT_STRIP_TRAILING_WHITESPACE)
564     message(STATUS "Git date: ${GIT_DATE}")
565     string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
566
567     execute_process(COMMAND git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --pretty=format:%H -1
568        WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.git/
569        OUTPUT_VARIABLE SIMGRID_GITHASH
570        OUTPUT_STRIP_TRAILING_WHITESPACE)
571   endif()
572 elseif(EXISTS ${CMAKE_HOME_DIRECTORY}/.gitversion)
573   FILE(STRINGS ${CMAKE_HOME_DIRECTORY}/.gitversion GIT_VERSION)
574 else()
575   set(GIT_VERSION "none, release version")
576 endif()
577
578 ### Setup gcc & clang flags
579 if (NOT MSVC)
580   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/GCCFlags.cmake)
581 endif()
582
583 ### Generate the required headers and scripts
584 #############################################
585
586 # Avoid triggering a (full) rebuild by touching the files if they did not really change
587 configure_file("${CMAKE_HOME_DIRECTORY}/tools/cmake/src/internal_config.h.in" "${CMAKE_BINARY_DIR}/src/internal_config.h.generated"    @ONLY IMMEDIATE)
588 configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid/config.h.in"          "${CMAKE_BINARY_DIR}/include/simgrid/config.h.generated" @ONLY IMMEDIATE)
589 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/src/internal_config.h.generated ${CMAKE_BINARY_DIR}/src/internal_config.h)
590 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/simgrid/config.h.generated ${CMAKE_BINARY_DIR}/include/simgrid/config.h)
591 file(REMOVE ${CMAKE_BINARY_DIR}/src/internal_config.h.generated)
592 file(REMOVE ${CMAKE_BINARY_DIR}/include/simgrid/config.h.generated)
593
594 # We need two versions of the SMPI scripts because they contain the path to the library
595 # so, it depends of whether SimGrid is installed, or run from the sources (during the build)
596
597 file(READ ${CMAKE_HOME_DIRECTORY}/src/smpi/smpitools.sh SMPITOOLS_SH) # Definitions shared amongst all SMPI scripts, inlined in each of them
598
599 ### SMPI script used when simgrid is installed
600 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
601 set(includeflag "-I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/smpi")
602 set(includedir "${CMAKE_INSTALL_PREFIX}/include")
603 set(libdir ${exec_prefix}/lib)
604 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_INSTALL_PREFIX}/lib")
605 if(NS3_LIBRARY_PATH)
606   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${NS3_LIBRARY_PATH}")
607 endif()
608 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
609 set(SMPIMAIN ${libdir}/simgrid/smpimain)
610
611 configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/mpif.h.in ${CMAKE_BINARY_DIR}/include/smpi/mpif.h @ONLY)
612 #configure mpif.f90 to build mpi.mod
613 if(SMPI_FORTRAN)
614   set(MODULE_MPIF_IN "module mpi")
615   set(MODULE_MPIF_OUT "end module mpi")
616   configure_file(${CMAKE_HOME_DIRECTORY}/include/smpi/mpif.h.in ${CMAKE_BINARY_DIR}/src/smpi/mpif.f90.generated @ONLY)
617   execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/src/smpi/mpif.f90.generated ${CMAKE_BINARY_DIR}/src/smpi/mpif.f90)
618   set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include/smpi)
619   add_library(mpi SHARED ${CMAKE_BINARY_DIR}/src/smpi/mpif.f90)
620 endif()
621
622 foreach(script cc cxx ff f90 run)
623   configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpi${script}.in ${CMAKE_BINARY_DIR}/bin/smpi${script} @ONLY)
624 endforeach()
625
626 ### SMPI scripts used when compiling simgrid 
627 set(exec_prefix "${CMAKE_BINARY_DIR}/smpi_script/")
628 set(includeflag "-I${CMAKE_HOME_DIRECTORY}/include -I${CMAKE_HOME_DIRECTORY}/include/smpi")
629 set(includeflag "${includeflag} -I${CMAKE_BINARY_DIR}/include -I${CMAKE_BINARY_DIR}/include/smpi")
630 set(includedir "${CMAKE_HOME_DIRECTORY}/include")
631 set(libdir "${CMAKE_BINARY_DIR}/lib")
632 set(CMAKE_SMPI_COMMAND "export LD_LIBRARY_PATH=\"${CMAKE_BINARY_DIR}/lib")
633 if(NS3_LIBRARY_PATH)
634   set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:${NS3_LIBRARY_PATH}")
635 endif()
636 set(CMAKE_SMPI_COMMAND "${CMAKE_SMPI_COMMAND}:\${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\"")
637 set(SMPIMAIN ${CMAKE_BINARY_DIR}/lib/simgrid/smpimain)
638
639 foreach(script cc cxx ff f90 run)
640   configure_file(${CMAKE_HOME_DIRECTORY}/src/smpi/smpi${script}.in ${CMAKE_BINARY_DIR}/smpi_script/bin/smpi${script} @ONLY)
641 endforeach()
642
643 if(NOT WIN32)
644   foreach(script cc cxx ff f90 run)
645     execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpi${script})
646     execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/smpi_script/bin/smpi${script})
647   endforeach()
648 endif()
649
650 set(generated_headers_to_install
651   ${CMAKE_CURRENT_BINARY_DIR}/include/smpi/mpif.h
652   ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid/config.h
653   )
654
655 set(generated_headers  ${CMAKE_CURRENT_BINARY_DIR}/src/internal_config.h )
656
657 set(generated_files_to_clean
658   ${generated_headers}
659   ${generated_headers_to_install}
660   ${CMAKE_BINARY_DIR}/bin/smpicc
661   ${CMAKE_BINARY_DIR}/bin/smpicxx
662   ${CMAKE_BINARY_DIR}/bin/smpiff
663   ${CMAKE_BINARY_DIR}/bin/smpif90
664   ${CMAKE_BINARY_DIR}/bin/smpirun
665   ${CMAKE_BINARY_DIR}/bin/colorize
666   ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
667   ${CMAKE_BINARY_DIR}/examples/smpi/tracing/smpi_traced.trace
668   )
669
670 if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
671   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions0.txt COPYONLY)
672   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions1.txt COPYONLY)
673   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_allreduce.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allreduce.txt COPYONLY)
674   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_barrier.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_barrier.txt COPYONLY)
675   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_bcast.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_bcast.txt COPYONLY)
676   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_with_isend.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_with_isend.txt COPYONLY)
677   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_alltoall.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoall.txt COPYONLY)
678   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_alltoallv.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoallv.txt COPYONLY)
679   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_waitall.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_waitall.txt COPYONLY)
680   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_reducescatter.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_reducescatter.txt COPYONLY)
681   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_gather.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_gather.txt COPYONLY)
682   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay/actions_allgatherv.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allgatherv.txt COPYONLY)
683   configure_file(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/hostfile ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile COPYONLY)
684   configure_file(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/hostfile_cluster ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile_cluster COPYONLY)
685   configure_file(${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/hostfile_coll ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile_coll COPYONLY)
686
687   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/description_file ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/description_file COPYONLY)
688   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/README ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/README COPYONLY)
689   configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple/smpi_replay.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/smpi_replay.txt COPYONLY)
690   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)
691   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)
692   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)
693   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)
694   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)
695   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)
696   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)
697   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)
698   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)
699   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)
700   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)
701   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)
702   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)
703   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)
704   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)
705   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)
706   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)
707   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)
708   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)
709   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)
710   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)
711   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)
712   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)
713   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)
714   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)
715   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)
716   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)
717   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)
718   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)
719   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)
720   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)
721   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)
722
723 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/compute_only.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/compute_only.txt COPYONLY)
724 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/compute_only/actions0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/compute_only/actions0.txt COPYONLY)
725 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/compute_only/actions1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/compute_only/actions1.txt COPYONLY)
726 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/empty.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/empty.txt COPYONLY)
727 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/empty/actions0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/empty/actions0.txt COPYONLY)
728 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/empty/actions1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/empty/actions1.txt COPYONLY)
729 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/mixed.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/mixed.txt COPYONLY)
730 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/mixed/actions0.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/mixed/actions0.txt COPYONLY)
731 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/mixed/actions1.txt ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/mixed/actions1.txt COPYONLY)
732 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/workload_compute ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute COPYONLY)
733 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/workload_compute_consecutive ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute_consecutive COPYONLY)
734 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/workload_compute_consecutive2 ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute_consecutive2 COPYONLY)
735 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/workload_compute_simple ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute_simple COPYONLY)
736 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time COPYONLY)
737 configure_file(${CMAKE_HOME_DIRECTORY}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time_and_resources ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time_and_resources COPYONLY)
738
739   set(generated_files_to_clean
740     ${generated_files_to_clean}
741     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions0.txt
742     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions1.txt
743     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allreduce.txt
744     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_barrier.txt
745     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_bcast.txt
746     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_with_isend.txt
747     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoall.txt
748     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_alltoallv.txt
749     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_waitall.txt
750     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_gather.txt
751     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_allgatherv.txt
752     ${CMAKE_BINARY_DIR}/examples/smpi/replay/actions_reducescatter.txt
753     ${CMAKE_BINARY_DIR}/teshsuite/smpi/hostfile
754     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/description_file
755     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/README
756     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/smpi_replay.txt
757     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace0.txt
758     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace1.txt
759     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace2.txt
760     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace3.txt
761     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace4.txt
762     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace5.txt
763     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace6.txt
764     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace7.txt
765     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace8.txt
766     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace9.txt
767     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace10.txt
768     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace11.txt
769     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace12.txt
770     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace13.txt
771     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace14.txt
772     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace15.txt
773     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace16.txt
774     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace17.txt
775     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace18.txt
776     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace19.txt
777     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace20.txt
778     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace21.txt
779     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace22.txt
780     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace23.txt
781     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace24.txt
782     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace25.txt
783     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace26.txt
784     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace27.txt
785     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace28.txt
786     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace29.txt
787     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace30.txt
788     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple/ti_traces_32_1/ti_trace31.txt
789     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/compute_only.txt
790     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/compute_only/actions0.txt
791     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/compute_only/actions1.txt
792     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/empty.txt
793     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/empty/actions0.txt
794     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/empty/actions1.txt
795     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/mixed.txt
796     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/mixed/actions0.txt
797     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/mixed/actions1.txt
798     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.tesh
799     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute
800     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute_consecutive
801     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute_consecutive2
802     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_compute_simple
803     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_empty1
804     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_empty2
805     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_empty2_same_resources
806     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_empty2_same_time
807     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_empty2_same_time_and_resources
808     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed1
809     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2
810     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_resources
811     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time
812     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time_and_resources
813     ${CMAKE_BINARY_DIR}/examples/smpi/replay_multiple_manual_deploy/workload_nojob
814     )
815 endif()
816
817 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
818   "${generated_files_to_clean}")
819
820 ### Define source packages for Libs
821 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/DefinePackages.cmake)
822
823 ### Build some Maintainer files
824 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MaintainerMode.cmake)
825 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/UnitTesting.cmake)
826
827 ### Make Libs
828 if(NOT WIN32)
829   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeLib.cmake)
830 else()
831   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/MakeLibWin.cmake)
832 endif()
833
834 if(enable_java)
835   include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Java.cmake)
836 endif()
837
838 ### Make tests
839 if(enable_memcheck_xml)
840   set(enable_memcheck true)
841 endif()
842
843 INCLUDE(CTest)
844 ENABLE_TESTING()
845 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Tests.cmake)
846 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/CTestConfig.cmake)
847
848 ### Define subdirectories
849 foreach(cmakefile ${CMAKEFILES_TXT})
850   string(REPLACE "/CMakeLists.txt" "" repository ${cmakefile})
851   add_subdirectory("${CMAKE_HOME_DIRECTORY}/${repository}")
852 endforeach()
853
854 ### Setup the distrib
855 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Distrib.cmake)
856
857 ### Build the docs if asked to
858 include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Documentation.cmake)
859
860 ### Print the result of configuration
861 message("")
862 message("##########################################")
863 message("#### Content of src/internal_config.h ####")
864 message("##########################################")
865 file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/src/internal_config.h config_output)
866 LIST(REMOVE_AT config_output 0 1 2 3 4 5 6 7 8 9 10) # Pass the file header
867 foreach(line ${config_output})
868   message("   ${line}")
869 endforeach()
870 message("##########################################")
871 message("####   Content of simgrid/config.h    ####")
872 message("##########################################")
873 file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid/config.h config_output)
874 LIST(REMOVE_AT config_output 0 1 2 3 4 5 6 7 8 9 -1) # Pass the file header
875 foreach(line ${config_output})
876   message("   ${line}")
877 endforeach()
878 message("##########################################")
879 message("####   End of configuration headers   ####")
880 message("##########################################")
881
882 message("\nConfiguration of package `simgrid':")
883 message("        Home directory ..............: ${CMAKE_HOME_DIRECTORY}")
884 message("        Build Name ..................: ${BUILDNAME}")
885 message("        Cmake Generator .............: ${CMAKE_GENERATOR}")
886 message("        Site ........................: ${SITE}")
887 message("        Install prefix ..............: ${CMAKE_INSTALL_PREFIX}")
888 if(release)
889   message("        Release .....................: simgrid-${release_version}${SIMGRID_VERSION_EXTRA} (release build)")
890 else()
891   message("        Release .....................: simgrid-${release_version}${SIMGRID_VERSION_EXTRA} (development build)")
892 endif()
893 message("")
894 message("        Compiler: C .................: ${CMAKE_C_COMPILER} (id: ${CMAKE_C_COMPILER_ID})")
895 message("                version .............: ${CMAKE_C_COMPILER_VERSION}")
896 message("                is gnu ..............: ${CMAKE_COMPILER_IS_GNUCC}")
897 message("        Compiler: C++ ...............: ${CMAKE_CXX_COMPILER} (id: ${CMAKE_CXX_COMPILER_ID})")
898 message("                version .............: ${CMAKE_CXX_COMPILER_VERSION}")
899 if(${Java_FOUND})
900   message("        Compiler: Javac .............: ${Java_JAVAC_EXECUTABLE}")
901   message("                version .............: ${Java_VERSION_STRING}")
902 endif()
903 if(CMAKE_Fortran_COMPILER)
904   message("        Compiler: Fortran ...........: ${SMPI_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})")
905   message("                version .............: ${CMAKE_Fortran_COMPILER_VERSION}")
906 endif()
907 message("        Linker: .....................: ${CMAKE_LINKER}")
908 message("                version .............: ${LINKER_VERSION}")
909 message("        Make program: ...............: ${CMAKE_MAKE_PROGRAM}")
910 message("")
911 message("        CFlags ......................: ${CMAKE_C_FLAGS}")
912 message("        CXXFlags ....................: ${CMAKE_CXX_FLAGS}")
913 message("        LDFlags .....................: ${CMAKE_C_LINK_FLAGS}")
914 message("        with LTO ....................: ${enable_lto}")
915 message("")
916
917 if (SIMGRID_HAVE_NS3)
918   message("        Compile NS-3 ................: yes (path: ${NS3_PATH})")
919 else()
920   message("        Compile NS-3 ................: NO  (hint: ${NS3_HINT})")
921 endif()
922
923 if (${Java_FOUND})
924   message("        Compile Java ................: yes")
925   message("          Native lib in jar .........: ${enable_lib_in_jar}")
926 else()
927   message("        Compile Java ................: NO")
928 endif()
929 message("        Compile Lua .................: ${SIMGRID_HAVE_LUA}")
930 message("        Compile Smpi ................: ${HAVE_SMPI}")
931 message("          Smpi fortran ..............: ${SMPI_FORTRAN}")
932 message("          MPICH3 testsuite ..........: ${enable_smpi_MPICH3_testsuite}")
933 message("          Privatization .............: ${HAVE_PRIVATIZATION}")
934 message("          PAPI support...............: ${HAVE_PAPI}")
935 message("        Compile Boost.Context support: ${HAVE_BOOST_CONTEXTS}")
936 message("")
937 message("        Maintainer mode .............: ${enable_maintainer_mode}")
938 message("        Documentation................: ${enable_documentation}")
939 message("        Model checking ..............: ${SIMGRID_HAVE_MC}")
940 message("        Jedule  mode ................: ${SIMGRID_HAVE_JEDULE}")
941 message("        Graphviz mode ...............: ${HAVE_GRAPHVIZ}")
942 message("        Mallocators .................: ${enable_mallocators}")
943 message("")
944 message("        Simgrid dependencies ........: ${SIMGRID_DEP}")
945 message("")
946
947 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/Testing/Notes/)
948 file(WRITE ${PROJECT_BINARY_DIR}/Testing/Notes/Build  "GIT version : ${GIT_VERSION}\n")
949 file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Release     : simgrid-${release_version}\n")
950
951 INCLUDE(Dart)