Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update doc
[simgrid.git] / examples / c / CMakeLists.txt
1 # Regular examples: with only one source and tested with all factories
2 ######################################################################
3
4 foreach(x
5         actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-stacksize
6         actor-suspend actor-yield
7         app-masterworker app-pingpong app-token-ring 
8         async-wait async-waitall async-waitany
9         cloud-capping cloud-masterworker cloud-migration cloud-simple
10         exec-async exec-basic exec-dvfs exec-remote exec-waitany
11         energy-exec energy-exec-ptask energy-vm
12         io-disk-raw io-file-remote
13         platform-failures platform-properties
14         plugin-hostload)
15   add_executable       (${x}-c EXCLUDE_FROM_ALL ${x}/${x}.c)
16   target_link_libraries(${x}-c simgrid)
17   set_target_properties(${x}-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
18   add_dependencies(tests ${x}-c)
19
20   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
21   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
22 endforeach()
23
24 # Multi-files examples
25 ######################
26 # bittorrent example
27 add_executable       (app-bittorrent-c EXCLUDE_FROM_ALL app-bittorrent/app-bittorrent.c app-bittorrent/bittorrent-peer.c app-bittorrent/tracker.c)
28 target_link_libraries(app-bittorrent-c simgrid)
29 set_target_properties(app-bittorrent-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-bittorrent)
30 add_dependencies(tests app-bittorrent-c)
31
32 foreach (file app-bittorrent bittorrent-peer tracker)
33   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/${file}.c  ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/${file}.h)
34 endforeach()
35
36 # Chainsend example
37
38 add_executable       (app-chainsend-c EXCLUDE_FROM_ALL app-chainsend/chainsend.c app-chainsend/broadcaster.c 
39                       app-chainsend/peer.c)
40 target_link_libraries(app-chainsend-c simgrid)
41 set_target_properties(app-chainsend-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-chainsend)
42 add_dependencies(tests app-chainsend-c)
43
44 foreach (file chainsend broadcaster peer)
45   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/${file}.c)
46 endforeach()
47 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/chainsend.h)
48
49 #DHT-Kademlia
50 add_executable       (dht-kademlia-c EXCLUDE_FROM_ALL dht-kademlia/dht-kademlia.c dht-kademlia/node.c dht-kademlia/routing_table.c dht-kademlia/message.c dht-kademlia/answer.c)
51 target_link_libraries(dht-kademlia-c simgrid)
52 set_target_properties(dht-kademlia-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dht-kademlia)
53 add_dependencies(tests dht-kademlia-c)
54
55 foreach (file answer node routing_table message)
56   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.c  ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.h)
57 endforeach()
58
59 # Add all extra files to the archive
60 ####################################
61
62 set(tesh_files    ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/app-bittorrent.tesh
63                                 ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/app-chainsend.tesh
64                                 ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore.tesh
65                                 ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi.tesh
66                                 ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/dht-kademlia.tesh
67                                 PARENT_SCOPE)
68 set(bin_files     ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/generate.py                  
69                                ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py                        PARENT_SCOPE)
70 set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/common.h
71                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/dht-kademlia.c                  PARENT_SCOPE)
72 set(xml_files     ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/actor-create_d.xml
73                                ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/actor-lifetime_d.xml
74                                ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/actor-yield_d.xml
75                                ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/app-bittorrent_d.xml
76                                ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/app-chainsend_d.xml
77                                ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker_d.xml
78                                ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore_d.xml
79                                ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi_d.xml
80                                ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml
81                                ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait_d.xml
82                                ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml
83                                ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml
84                                ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml
85                                ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/async-waitall_d.xml
86                                ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml
87                                ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/dht-kademlia_d.xml
88                                ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/io-file-remote_d.xml
89                                ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/platform-properties_d.xml
90                                PARENT_SCOPE)
91
92 foreach(x
93         actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-stacksize
94         actor-suspend actor-yield
95         app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
96         async-wait async-waitall async-waitany
97         cloud-capping  cloud-masterworker cloud-migration cloud-simple
98         exec-async exec-basic exec-dvfs exec-remote exec-waitany
99         energy-exec energy-exec-ptask energy-vm
100         io-disk-raw io-file-remote
101         platform-failures platform-properties
102         plugin-hostload)
103   ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
104                   --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x}
105                   --cd ${CMAKE_HOME_DIRECTORY}/examples/c/${x}
106                   ${CMAKE_HOME_DIRECTORY}/examples/c/${x}/${x}.tesh)
107 endforeach()
108
109 ADD_TESH_FACTORIES(app-masterworker-multicore   "thread;ucontext;raw;boost" 
110                                                 --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/c/app-masterworker 
111                                                 --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/app-masterworker
112                                                 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
113                                                ${CMAKE_HOME_DIRECTORY}/examples/c/app-masterworker/app-masterworker-multicore.tesh)
114 ADD_TESH_FACTORIES(app-masterworker-vivaldi     "thread;ucontext;raw;boost" 
115                                                 --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/c/app-masterworker 
116                                                 --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/app-masterworker
117                                                 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
118                                                 ${CMAKE_HOME_DIRECTORY}/examples/c/app-masterworker/app-masterworker-vivaldi.tesh)
119 ADD_TESH_FACTORIES(c-dht-kademlia "thread;ucontext;raw;boost" 
120                                   --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/dht-kademlia
121                                   --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/c/dht-kademlia 
122                                   --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
123                                   ${CMAKE_HOME_DIRECTORY}/examples/c/dht-kademlia/dht-kademlia.tesh)
124
125 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
126     # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
127     # play well with Ucontexts on 64bit SunOS (at least on x86_64).
128     set(parallel-factories "thread;raw;boost")
129 else()
130     set(parallel-factories "thread;ucontext;raw;boost")
131 endif()
132
133 ADD_TESH_FACTORIES(c-app-bittorrent-parallel "raw" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} 
134                                              --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/app-bittorrent 
135                                              --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
136                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
137                                              --cd ${CMAKE_HOME_DIRECTORY}/examples/c/app-bittorrent app-bittorrent.tesh)
138
139 ADD_TESH_FACTORIES(c-dht-kademlia-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
140                                            --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/dht-kademlia
141                                            --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/c/dht-kademlia
142                                            --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
143                                            ${CMAKE_HOME_DIRECTORY}/examples/c/dht-kademlia/dht-kademlia.tesh)