Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s/_/-/
[simgrid.git] / examples / cpp / 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 "^thread") # 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 set(MC_regular_tests mc-bugged1 mc-bugged2 mc-failing-assert mc-electric-fence)
24 foreach (example ${MC_regular_tests})
25   if(NOT SIMGRID_HAVE_MC)
26     set(_${example}_disable 1)
27   endif()
28   set(_${example}_factories "^thread")
29 endforeach()
30
31 if(HAVE_GRAPHVIZ)
32   add_executable       (s4u-dag-from-dot  EXCLUDE_FROM_ALL dag-from-dot/s4u-dag-from-dot.cpp)
33   target_link_libraries(s4u-dag-from-dot  simgrid)
34   set_target_properties(s4u-dag-from-dot  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dag-from-dot)
35   add_dependencies(tests s4u-dag-from-dot)
36
37   ADD_TESH(s4u-dag-from-dot --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/cpp/dag-from-dot
38                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
39                              --cd ${CMAKE_BINARY_DIR}/examples/cpp/dag-from-dot
40                              ${CMAKE_HOME_DIRECTORY}/examples/cpp/dag-from-dot/s4u-dag-from-dot.tesh)
41  endif()
42  set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/s4u-dag-from-dot.cpp)
43  set(tesh_files   ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/s4u-dag-from-dot.tesh)
44
45
46 if(SIMGRID_HAVE_MC)
47    add_executable       (s4u-mc-bugged1-liveness  EXCLUDE_FROM_ALL mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
48    target_link_libraries(s4u-mc-bugged1-liveness  simgrid)
49    set_target_properties(s4u-mc-bugged1-liveness PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness)
50    add_dependencies(tests-mc s4u-mc-bugged1-liveness)
51
52   if(HAVE_C_STACK_CLEANER)
53     add_executable       (s4u-mc-bugged1-liveness-cleaner-on  EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
54     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-on  simgrid)
55     set_target_properties(s4u-mc-bugged1-liveness-cleaner-on  PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fstack-cleaner")
56     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-on)
57
58     add_executable       (s4u-mc-bugged1-liveness-cleaner-off EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
59     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-off simgrid)
60     set_target_properties(s4u-mc-bugged1-liveness-cleaner-off PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fno-stack-cleaner")
61     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-off)
62   endif()
63 endif()
64
65 if(SIMGRID_HAVE_NS3)
66   add_executable       (s4u-network-ns3 EXCLUDE_FROM_ALL network-ns3/s4u-network-ns3.cpp)
67   target_link_libraries(s4u-network-ns3 simgrid)
68   set_target_properties(s4u-network-ns3  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3)
69   add_dependencies(tests s4u-network-ns3)
70   add_executable       (s4u-network-ns3-wifi EXCLUDE_FROM_ALL network-ns3-wifi/s4u-network-ns3-wifi.cpp)
71   target_link_libraries(s4u-network-ns3-wifi simgrid)
72   set_target_properties(s4u-network-ns3-wifi  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3-wifi)
73   add_dependencies(tests s4u-network-ns3-wifi)
74 endif()
75
76 # Deal with each example
77
78 foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
79                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
80                  app-bittorrent app-chainsend app-token-ring
81                  comm-pingpong comm-ready comm-serialize comm-suspend comm-wait comm-waitany comm-waitall comm-waituntil
82                  comm-dependent comm-host2host comm-failure comm-throttling
83                  cloud-capping cloud-migration cloud-simple
84                  dag-comm dag-failure dag-io dag-simple
85                  dht-chord dht-kademlia
86                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
87                  engine-filtering engine-run-partial
88                  exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
89                  exec-ptask-multicore exec-cpu-nonlinear exec-cpu-factors exec-failure
90                  maestro-set
91                  mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert
92                  network-wifi
93                  io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
94                  platform-failures platform-profile platform-properties
95                  plugin-host-load plugin-link-load plugin-prodcons
96                  replay-comm replay-io
97                  routing-get-clusters
98                  synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
99                  clusters-multicpu network-factors network-nonlinear)
100
101   # Use default source file unless specified otherwise
102   if(NOT DEFINED _${example}_sources)
103     set(_${example}_sources ${example}/s4u-${example}.cpp)
104   endif()
105
106   if(NOT DEFINED _${example}_disable)
107     add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
108     add_dependencies     (tests s4u-${example})
109     add_dependencies     (s4u-${example} platf_cpp)
110     target_link_libraries(s4u-${example} simgrid)
111     set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
112
113     # Use default factories unless specified otherwise
114     if(NOT DEFINED _${example}_factories)
115       set(_${example}_factories "*")
116     endif()
117 #    message("Factories of ${example}: ${_${example}_factories}")
118
119     ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
120                                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
121                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
122                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
123                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
124                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
125   else()
126     message(STATUS "Example ${example} disabled, thus not compiled.")
127     unset(_${example}_disable)
128   endif()
129
130   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
131   foreach(file ${_${example}_sources})
132     set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
133   endforeach()
134
135   unset(_${example}_factories)
136   unset(_${example}_sources)
137 endforeach()
138
139
140 # Specific examples
141 ###################
142
143 # MASTERWORKERS EXAMPLE
144 foreach(variant fun class)
145   add_executable       (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
146   target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
147   set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
148   add_dependencies(tests s4u-app-masterworkers-${variant})
149
150   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
151 endforeach()
152 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
153
154 # Model-checking
155 if(SIMGRID_HAVE_MC)
156   foreach (example ${MC_regular_tests})
157     if(NOT DEFINED _${example}_disable)
158       add_dependencies(tests-mc s4u-${example})
159     endif()
160   endforeach()
161
162   # Model-checking liveness
163   IF(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) # liveness model-checking works only on 64bits (for now ...)
164     add_dependencies(tests-mc s4u-mc-bugged1-liveness)
165     ADD_TESH(s4u-mc-bugged1-liveness-ucontext     --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness
166                                                   --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
167                                                   --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
168                                                   ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh)
169
170 # This example hit the 5' timeout on CI, disable it for now
171 #    ADD_TESH(s4u-mc-bugged1-liveness-visited-ucontext --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness
172 #                                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
173 #                                                      --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
174 #                                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh)
175     IF(HAVE_C_STACK_CLEANER)
176       add_dependencies(tests-mc s4u-mc-bugged1-liveness-stack-cleaner)
177       # This test checks if the stack cleaner is making a difference:
178       ADD_TEST(s4u-mc-bugged1-liveness-stack-cleaner ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
179                                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/
180                                                      ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/)
181     ENDIF()
182   ENDIF()
183
184 #  if (enable_coverage)
185 #    SET_TESTS_PROPERTIES(mc-bugged1-liveness-visited-ucontext PROPERTIES RUN_SERIAL "TRUE")
186 #  endif()
187 ENDIF()
188
189 # The tests the parallel variant of of DHTs
190
191 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
192   # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
193   # play well with Ucontexts on 64bit SunOS (at least on x86_64).
194   set(parallel-factories "^ucontext")
195 else()
196   set(parallel-factories "*")
197 endif()
198
199 foreach(example app-bittorrent app-masterworkers
200                 dht-chord dht-kademlia
201                 )
202   ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
203                                              --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
204                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
205                                              --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
206                                              ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
207 endforeach()
208
209 # ns3-tests
210 if(SIMGRID_HAVE_NS3)
211   ADD_TESH_FACTORIES(s4u-network-ns3 "*"
212                                      --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/cpp
213                                      --setenv bindir=${CMAKE_BINARY_DIR}/examples/cpp
214                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
215                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3.tesh)
216   ADD_TESH_FACTORIES(s4u-network-ns3-wifi "*"
217                                      --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/cpp
218                                      --setenv bindir=${CMAKE_BINARY_DIR}/examples/cpp
219                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
220                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3-wifi/s4u-network-ns3-wifi.tesh)
221 endif()
222 # Examples not accepting factories
223 ##################################
224
225 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
226                  trace-host-user-variables trace-link-user-variables trace-route-user-variables)
227   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
228   target_link_libraries(s4u-${example} simgrid)
229   set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
230   add_dependencies(tests s4u-${example})
231
232   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
233   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
234
235   ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
236                           --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
237                           --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
238                           --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
239                           ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
240 endforeach()
241
242 if (NOT enable_memcheck AND NOT WIN32)
243   ADD_TESH(simix-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
244                             --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
245                             ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simix-breakpoint.tesh)
246 endif()
247
248 if(enable_coverage AND SIMGRID_HAVE_MC)
249   foreach (example mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert)
250     ADD_TEST(cover-${example} ${CMAKE_CURRENT_BINARY_DIR}/${example}/s4u-${example} ${CMAKE_HOME_DIRECTORY}/examples/platforms/model_checker_platform.xml)
251   endforeach()
252   ADD_TEST(cover-mc-bugged1-liveness ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness ${CMAKE_HOME_DIRECTORY}/examples/platforms/small_platform.xml 1 1001)
253 endif()
254
255 # Add all extra files to the archive
256 ####################################
257 set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp
258                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/s4u-network-ns3.cpp
259                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3-wifi/s4u-network-ns3-wifi.cpp              PARENT_SCOPE)
260 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simix-breakpoint.tesh
261                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh
262                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh
263                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/s4u-network-ns3.tesh
264                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3-wifi/s4u-network-ns3-wifi.tesh             PARENT_SCOPE)
265 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
266                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
267                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield_d.xml
268                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
269                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
270                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-suspend/s4u-comm-suspend_d.xml
271                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/s4u-comm-wait_d.xml
272                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitany/s4u-comm-waitany_d.xml
273                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitall/s4u-comm-waitall_d.xml
274                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-ready/s4u-comm-ready_d.xml
275                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waituntil/s4u-comm-waituntil_d.xml
276                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
277                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
278                                   ${CMAKE_CURRENT_SOURCE_DIR}/energy-boot/platform_boot.xml
279                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
280                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/s4u-platform-properties_d.xml
281                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
282                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
283                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
284                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
285                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
286                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
287                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
288                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
289                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
290                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
291                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
292 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
293                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
294                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness PARENT_SCOPE)
295 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
296                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
297                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
298                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
299                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)
300