Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / examples / cpp / CMakeLists.txt
1 # Regular examples: with only one source and tested with all factories by default
2 #################################################################################
3 ### Define the examples' specificities
4
5 set(_app-bittorrent_sources app-bittorrent/s4u-bittorrent.cpp app-bittorrent/s4u-bittorrent.hpp
6                             app-bittorrent/s4u-peer.cpp app-bittorrent/s4u-peer.hpp
7                             app-bittorrent/s4u-tracker.cpp app-bittorrent/s4u-tracker.hpp)
8 set(_dht-chord_sources    dht-chord/s4u-dht-chord.cpp dht-chord/s4u-dht-chord.hpp dht-chord/s4u-dht-chord-node.cpp)
9 set(_dht-kademlia_sources dht-kademlia/s4u-dht-kademlia.cpp dht-kademlia/s4u-dht-kademlia.hpp
10                           dht-kademlia/node.cpp dht-kademlia/node.hpp
11                           dht-kademlia/routing_table.cpp dht-kademlia/routing_table.hpp
12                           dht-kademlia/answer.cpp dht-kademlia/answer.hpp dht-kademlia/message.hpp)
13
14 set(_actor-stacksize_factories "^thread") # Threads ignore modifications of the stack size
15
16 # The maestro-set example only works for threads
17 set(_maestro-set_factories "thread")
18
19 if(SIMGRID_HAVE_MC)
20   # These tests timeout with threads, not sure why
21   foreach(example mc-bugged1 mc-bugged2 mc-failing-assert mc-electric-fence)
22     set(_${example}_factories "^thread") # Timeout
23     add_dependencies(tests-mc s4u-${example})
24   endforeach()
25
26   if(enable_coverage)
27     foreach (example mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert)
28       ADD_TEST(cover-${example} ${CMAKE_CURRENT_BINARY_DIR}/${example}/s4u-${example} ${CMAKE_HOME_DIRECTORY}/examples/platforms/model_checker_platform.xml)
29     endforeach()
30   endif()
31 else()
32   foreach (example mc-bugged1 mc-bugged2  mc-centralized-mutex mc-failing-assert mc-electric-fence)
33     set(_${example}_disable 1)
34   endforeach()
35 endif()
36
37 # Hijack some regular tests to run them on top of the MC
38 foreach (example synchro-barrier synchro-mutex synchro-semaphore)
39   set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-mc-${example}.tesh)
40
41   if (SIMGRID_HAVE_MC)
42     ADD_TESH(s4u-mc-${example}
43               --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
44               --setenv libdir=${CMAKE_BINARY_DIR}/lib
45               --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
46               --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
47               --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
48               ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-mc-${example}.tesh)
49
50     add_dependencies(tests-mc s4u-${example})
51   endif()
52 endforeach()
53
54 if (SIMGRID_HAVE_MC)
55   # Dependency on the regular tests
56   foreach(example mc-centralized-mutex)
57     add_dependencies(tests-mc s4u-${example})
58   endforeach()
59 endif()
60
61 if(NOT HAVE_GRAPHVIZ)
62   set(_dag-from-dot_disable 1)
63   set(_dag-from-dot-simple_disable 1)
64 endif()
65
66 if (NOT SIMGRID_HAVE_JSON)
67   set(_dag-from-json-simple_disable 1)
68 endif()
69
70 if(SIMGRID_HAVE_NS3)
71   if(NS3_VERSION VERSION_GREATER_EQUAL 3.37)
72     set(_network-ns3_teshfile         ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
73     set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
74   else()
75     set(_network-ns3_teshfile         ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
76     set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
77   endif()
78
79 foreach (example network-ns3 network-ns3-wifi)
80   add_dependencies(tests-ns3 s4u-${example})
81 endforeach()
82
83 else()
84   # Even if ns3 is not found, we need to override the teshfile name and make sure that everything gets included in the archive
85   set(_network-ns3_teshfile         ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
86   set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
87
88   foreach (example network-ns3 network-ns3-wifi)
89     set(_${example}_disable 1)
90   endforeach()
91 endif()
92
93 # Deal with each example
94
95 foreach (example activityset-testany activityset-waitany activityset-waitall activityset-waitallfor
96                  actor-create actor-daemon actor-exiting actor-join actor-kill
97                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
98                  app-bittorrent app-chainsend app-token-ring
99                  battery-chiller-solar battery-connector battery-degradation battery-simple battery-energy
100                  chiller-simple
101                  comm-pingpong comm-ready comm-suspend comm-wait comm-waituntil
102                  comm-dependent comm-host2host comm-failure comm-throttling
103                  cloud-capping cloud-migration cloud-simple
104                  dag-comm dag-from-json-simple dag-from-dax-simple dag-from-dax dag-from-dot-simple dag-from-dot dag-failure dag-io dag-scheduling dag-simple dag-tuto
105                  dht-chord dht-kademlia
106                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
107                  engine-filtering engine-run-partial
108                  exec-async exec-basic exec-dvfs exec-remote exec-waitfor exec-dependent exec-unassigned
109                  exec-ptask-multicore exec-ptask-multicore-latency exec-cpu-nonlinear exec-cpu-factors exec-failure exec-threads
110                  maestro-set
111                  mc-bugged1 mc-bugged2 mc-centralized-mutex mc-electric-fence mc-failing-assert
112                  mess-wait
113                  network-ns3 network-ns3-wifi network-wifi
114                  io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
115                  task-dispatch task-io task-microservice task-parallelism task-simple task-storm task-switch-host task-variable-load
116                  solar-panel-simple
117                  platform-comm-serialize platform-failures platform-profile platform-properties
118                  plugin-host-load plugin-jbod plugin-link-load plugin-prodcons
119                  replay-comm replay-io
120                  routing-get-clusters
121                  synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
122                  clusters-multicpu network-factors network-nonlinear)
123
124   # Use default source file unless specified otherwise
125   if(NOT DEFINED _${example}_sources)
126     set(_${example}_sources ${example}/s4u-${example}.cpp)
127   endif()
128
129   # Use default tesh file unless specified otherwise
130   if(NOT DEFINED _${example}_teshfile)
131     set(_${example}_teshfile ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
132   endif()
133
134   if(NOT DEFINED _${example}_disable)
135     add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
136     add_dependencies     (tests s4u-${example})
137     add_dependencies     (s4u-${example} platf_cpp)
138     target_link_libraries(s4u-${example} simgrid)
139     set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
140
141     # Use default factories unless specified otherwise
142     if(NOT DEFINED _${example}_factories)
143       set(_${example}_factories "*")
144     endif()
145 #    message("Factories of ${example}: ${_${example}_factories}")
146
147     ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
148                                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
149                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
150                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
151                                       --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
152                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
153                                       ${_${example}_teshfile})
154   else()
155     message(STATUS "Example ${example} disabled, thus not compiled.")
156     unset(_${example}_disable)
157   endif()
158
159   set(tesh_files    ${tesh_files}    ${_${example}_teshfile})
160   foreach(file ${_${example}_sources})
161     set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
162   endforeach()
163
164   unset(_${example}_factories)
165   unset(_${example}_sources)
166   unset(_${example}_teshfile)
167 endforeach()
168
169
170 # Specific examples
171 ###################
172
173 # MASTERWORKERS EXAMPLE
174 foreach(variant fun class)
175   add_executable       (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
176   target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
177   set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
178   add_dependencies(tests s4u-app-masterworkers-${variant})
179
180   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
181 endforeach()
182 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
183
184 # The tests the parallel variant of of DHTs
185
186 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
187   # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
188   # play well with Ucontexts on 64bit SunOS (at least on x86_64).
189   set(parallel-factories "^ucontext")
190 else()
191   set(parallel-factories "*")
192 endif()
193
194 foreach(example app-bittorrent app-masterworkers
195                 dht-chord dht-kademlia
196                 )
197   ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
198                                              --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
199                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
200                                              --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
201                                              ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
202 endforeach()
203
204 # Test non-DPOR reductions on a given MC test
205 foreach(example mc-failing-assert)
206
207   if(SIMGRID_HAVE_MC)
208     ADD_TESH(s4u-${example}-nodpor    --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
209                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
210                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
211                                       --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
212                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
213                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
214   endif()
215   set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
216 endforeach()
217
218 # Examples not accepting factories
219 ##################################
220
221 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
222                  trace-host-user-variables trace-link-user-variables trace-route-user-variables)
223   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
224   target_link_libraries(s4u-${example} simgrid)
225   set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
226   add_dependencies(tests s4u-${example})
227
228   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
229   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
230
231   ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
232                           --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
233                           --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
234                           --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
235                           ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
236 endforeach()
237
238 if (NOT enable_memcheck)
239   ADD_TESH(debug-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
240                             --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
241                             ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh)
242 endif()
243
244 # Add all extra files to the archive
245 ####################################
246 set(examples_src  ${examples_src}    PARENT_SCOPE)
247 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh  PARENT_SCOPE)
248 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
249                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
250                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
251                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
252                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-scheduling/Montage_25.xml
253                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
254                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
255                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
256                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
257                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
258                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
259                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
260                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
261                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
262                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
263                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
264                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
265                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
266                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
267 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/battery-degradation/plot_battery_degradation.py
268                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py  PARENT_SCOPE)
269 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/simple_dax_with_cycle.xml
270                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/smalldax.xml
271                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax-simple/dag.xml
272                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
273                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot-simple/dag.dot
274                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag_with_cycle.dot
275                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-json-simple/dag.json
276                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
277                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
278                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
279                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)