Logo AND Algorithmique Numérique Distribuée

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