Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / examples / s4u / CMakeLists.txt
1
2 # Regular examples: with only one source and tested with all factories by default
3 #################################################################################
4 ### Define the examples' specificities
5
6 set(_app-bittorrent_sources app-bittorrent/s4u-bittorrent.cpp app-bittorrent/s4u-bittorrent.hpp
7                             app-bittorrent/s4u-peer.cpp app-bittorrent/s4u-peer.hpp
8                             app-bittorrent/s4u-tracker.cpp app-bittorrent/s4u-tracker.hpp)
9 set(_dht-chord_sources    dht-chord/s4u-dht-chord.cpp dht-chord/s4u-dht-chord.hpp dht-chord/s4u-dht-chord-node.cpp)
10 set(_dht-kademlia_sources dht-kademlia/s4u-dht-kademlia.cpp dht-kademlia/s4u-dht-kademlia.hpp
11                           dht-kademlia/node.cpp dht-kademlia/node.hpp
12                           dht-kademlia/routing_table.cpp dht-kademlia/routing_table.hpp
13                           dht-kademlia/answer.cpp dht-kademlia/answer.hpp dht-kademlia/message.hpp)
14
15 set(_actor-stacksize_factories "raw;boost;ucontext") # Threads ignore modifications of the stack size
16
17 # The maestro-set example only works for threads and when not using windows.
18 set(_maestro-set_factories "thread")
19 if(WIN32)
20   set(_maestro-set_disable 1)
21 endif()
22
23 foreach (example mc-bugged1 mc-bugged2 mc-failing-assert mc-electric-fence)
24   if(NOT SIMGRID_HAVE_MC)
25     set(_${example}_disable 1)
26   endif()
27   set(_${example}_factories "ucontext;raw;boost")
28 endforeach()
29
30 set(_mc-bugged1-liveness_disable 1) 
31 if(SIMGRID_HAVE_MC)
32    add_executable       (s4u-mc-bugged1-liveness  EXCLUDE_FROM_ALL mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
33    target_link_libraries(s4u-mc-bugged1-liveness  simgrid)
34    set_target_properties(s4u-mc-bugged1-liveness PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness)
35    add_dependencies(tests s4u-mc-bugged1-liveness)
36    set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
37    set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh)
38  
39   if(HAVE_C_STACK_CLEANER)
40     add_executable       (s4u-mc-bugged1-liveness-cleaner-on  EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
41     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-on  simgrid)
42     set_target_properties(s4u-mc-bugged1-liveness-cleaner-on  PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fstack-cleaner")
43     add_dependencies(tests s4u-mc-bugged1-liveness-cleaner-on)
44
45     add_executable       (s4u-mc-bugged1-liveness-cleaner-off EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
46     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-off simgrid)
47     set_target_properties(s4u-mc-bugged1-liveness-cleaner-off PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fno-stack-cleaner")
48     add_dependencies(tests s4u-mc-bugged1-liveness-cleaner-off)
49   endif()
50
51 endif()
52
53 if(SIMGRID_HAVE_NS3)
54   add_executable       (s4u-network-ns3 EXCLUDE_FROM_ALL network-ns3/s4u-network-ns3.cpp)
55   target_link_libraries(s4u-network-ns3 simgrid)
56   set_target_properties(s4u-network-ns3  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3)
57   add_dependencies(tests s4u-network-ns3)
58   add_executable       (s4u-network-ns3-wifi EXCLUDE_FROM_ALL network-ns3-wifi/s4u-network-ns3-wifi.cpp)
59   target_link_libraries(s4u-network-ns3-wifi simgrid)
60   set_target_properties(s4u-network-ns3-wifi  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3-wifi)
61   add_dependencies(tests s4u-network-ns3-wifi)
62 endif()
63
64 # Deal with each example
65
66 foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
67                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
68                  app-bittorrent app-chainsend app-pingpong app-token-ring
69                  comm-ready comm-suspend comm-wait comm-waitany comm-waitall comm-waituntil
70                  comm-dependent
71                  cloud-capping cloud-migration cloud-simple
72                  dht-chord dht-kademlia
73                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
74                  engine-filtering
75                  exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-waitfor exec-dependent
76                  maestro-set
77                  mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-electric-fence mc-failing-assert
78                  network-wifi
79                  io-async io-file-system io-file-remote io-disk-raw io-dependent
80                  platform-failures platform-profile platform-properties
81                  plugin-host-load plugin-link-load
82                  replay-comm replay-io
83                  routing-get-clusters
84                  synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore)
85
86   # Use default source file unless specified otherwise
87   if(NOT DEFINED _${example}_sources)
88     set(_${example}_sources ${example}/s4u-${example}.cpp)
89   endif()
90
91   if(NOT DEFINED _${example}_disable)
92     add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
93     add_dependencies     (tests s4u-${example})
94     target_link_libraries(s4u-${example} simgrid)
95     set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
96
97     # Use default factories unless specified otherwise
98     if(NOT DEFINED _${example}_factories)
99       set(_${example}_factories "thread;ucontext;raw;boost")
100     endif()
101 #    message("Factories of ${example}: ${_${example}_factories}")
102
103     ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
104                                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
105                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
106                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
107                                       ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
108   else()
109     message(STATUS "Example ${example} disabled, thus not compiled.")
110     unset(_${example}_disabled)
111   endif()
112
113   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
114   foreach(file ${_${example}_sources})
115     set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
116   endforeach()
117
118   unset(_${example}_factories)
119   unset(_${example}_sources)
120 endforeach()
121
122
123 # Specific examples
124 ###################
125
126 # MASTERWORKERS EXAMPLE
127 foreach(variant fun class) 
128   add_executable       (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
129   target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
130   set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
131   add_dependencies(tests s4u-app-masterworkers-${variant})
132
133   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
134 endforeach()
135 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
136
137 # Model-checking liveness
138 if(SIMGRID_HAVE_MC)
139   IF(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) # liveness model-checking works only on 64bits (for now ...)
140     ADD_TESH(s4u-mc-bugged1-liveness-ucontext     --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness 
141                                                   --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
142                                                   --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
143                                                   ${CMAKE_HOME_DIRECTORY}/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh)
144
145 # This example hit the 5' timeout on CI, disable it for now
146 #    ADD_TESH(s4u-mc-bugged1-liveness-visited-ucontext --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness 
147 #                                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
148 #                                                      --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
149 #                                                       ${CMAKE_HOME_DIRECTORY}/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh)
150     IF(HAVE_C_STACK_CLEANER)
151       # This test checks if the stack cleaner is making a difference:
152       ADD_TEST(s4u-mc-bugged1-liveness-stack-cleaner ${CMAKE_HOME_DIRECTORY}/examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
153                                                      ${CMAKE_HOME_DIRECTORY}/examples/s4u/mc-bugged1-liveness/ 
154                                                      ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/)
155     ENDIF()
156   ENDIF()
157
158 #  if (enable_coverage)
159 #    SET_TESTS_PROPERTIES(mc-bugged1-liveness-visited-ucontext PROPERTIES RUN_SERIAL "TRUE")
160 #  endif()
161 ENDIF()
162
163 # The tests the parallel variant of of DHTs
164
165 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
166   # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
167   # play well with Ucontexts on 64bit SunOS (at least on x86_64).
168   set(parallel-factories "thread;raw;boost")
169 else()
170   set(parallel-factories "thread;ucontext;raw;boost")
171 endif()
172
173 foreach(example app-bittorrent app-masterworkers 
174                 dht-chord dht-kademlia
175                 )
176   ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
177                                              --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
178                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
179                                              --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example} 
180                                              ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
181 endforeach()
182
183 # ns3-tests
184 if(SIMGRID_HAVE_NS3)
185   ADD_TESH_FACTORIES(s4u-network-ns3 "thread;ucontext;raw;boost"
186                                      --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/s4u
187                                      --setenv bindir=${CMAKE_BINARY_DIR}/examples/s4u
188                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
189                                      ${CMAKE_HOME_DIRECTORY}/examples/s4u/network-ns3/s4u-network-ns3.tesh)
190   ADD_TESH_FACTORIES(s4u-network-ns3-wifi "thread;ucontext;raw;boost"
191                                      --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/s4u
192                                      --setenv bindir=${CMAKE_BINARY_DIR}/examples/s4u
193                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
194                                      ${CMAKE_HOME_DIRECTORY}/examples/s4u/network-ns3-wifi/s4u-network-ns3-wifi.tesh)
195 endif()
196 # Examples not accepting factories
197 ##################################
198
199 foreach (example trace-platform)
200   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
201   target_link_libraries(s4u-${example} simgrid)
202   set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
203   add_dependencies(tests s4u-${example})
204
205   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
206   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
207   
208   ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
209                           --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
210                           ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
211 endforeach()
212
213 if (NOT enable_memcheck AND NOT WIN32)
214   ADD_TESH(simix-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/app-pingpong
215                             --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
216                             ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/simix-breakpoint.tesh)
217 endif()
218
219 # Add all extra files to the archive
220 ####################################
221
222 set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/s4u-network-ns3.cpp
223                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3-wifi/s4u-network-ns3-wifi.cpp              PARENT_SCOPE)
224 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/simix-breakpoint.tesh
225                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh
226                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/s4u-network-ns3.tesh
227                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3-wifi/s4u-network-ns3-wifi.tesh             PARENT_SCOPE)
228 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
229                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
230                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield_d.xml
231                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
232                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
233                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-suspend/s4u-comm-suspend_d.xml
234                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/s4u-comm-wait_d.xml
235                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitany/s4u-comm-waitany_d.xml
236                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitall/s4u-comm-waitall_d.xml
237                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-ready/s4u-comm-ready_d.xml
238                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waituntil/s4u-comm-waituntil_d.xml
239                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
240                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
241                                   ${CMAKE_CURRENT_SOURCE_DIR}/energy-boot/platform_boot.xml
242                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
243                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/s4u-platform-properties_d.xml
244                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
245                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
246                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
247                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
248                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
249                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
250                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
251                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
252                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
253                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
254                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
255 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
256                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
257                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness PARENT_SCOPE)
258 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
259                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
260                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
261                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)
262