Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / examples / sthread / CMakeLists.txt
1 set(THREADS_PREFER_PTHREAD_FLAG ON)
2 find_package(Threads REQUIRED)
3
4 # Regular pthread examples: test the interceptor of the pthread interface
5 #########################################################################
6
7 foreach(x
8         mutex-simple mutex-recursive
9         producer-consumer)
10
11   if("${CMAKE_SYSTEM}" MATCHES "Linux")
12     add_executable       (pthread-${x} EXCLUDE_FROM_ALL pthread-${x}.c)
13     set_target_properties(pthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
14     target_link_libraries(pthread-${x} PRIVATE Threads::Threads)
15
16     add_dependencies(tests pthread-${x})
17     ADD_TESH_FACTORIES(pthread-${x} "^thread" --setenv libdir=${CMAKE_BINARY_DIR}/lib --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/pthread-${x}.tesh)
18
19     if(SIMGRID_HAVE_MC)
20       add_dependencies(tests-mc pthread-${x})
21       ADD_TESH_FACTORIES(pthread-mc-${x} "^thread" --setenv libdir=${CMAKE_BINARY_DIR}/lib --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/pthread-mc-${x}.tesh)
22     endif()
23   endif()
24
25   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/pthread-${x}.tesh
26                                      ${CMAKE_CURRENT_SOURCE_DIR}/pthread-mc-${x}.tesh)
27   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/pthread-${x}.c)
28
29 endforeach()
30
31 # Regular pthread examples that may deadlock: test sthread + MC in that case
32 ############################################################################
33
34 foreach(x
35         mutex-simpledeadlock)
36
37   if("${CMAKE_SYSTEM}" MATCHES "Linux") # sthread is linux-only
38
39     add_executable       (pthread-${x} EXCLUDE_FROM_ALL pthread-${x}.c)
40     set_target_properties(pthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
41     target_link_libraries(pthread-${x} PRIVATE Threads::Threads)
42
43     if(SIMGRID_HAVE_MC)
44       add_dependencies(tests-mc pthread-${x})
45       ADD_TESH_FACTORIES(pthread-mc-${x} "^thread" --setenv libdir=${CMAKE_BINARY_DIR}/lib --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/pthread-mc-${x}.tesh)
46     endif()
47   endif()
48
49   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/pthread-mc-${x}.tesh)
50   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/pthread-${x}.c)
51
52 endforeach()
53
54 # C++ tests with sthread+MC that live in their own directory
55 ########################################################
56 foreach(example
57         stdobject)
58
59   if("${CMAKE_SYSTEM}" MATCHES "Linux") # sthread is linux-only
60
61     add_executable       (${example} EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.cpp)
62     set_target_properties(${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
63     target_link_libraries(${example} PRIVATE Threads::Threads)
64     set_target_properties(${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
65
66     if(SIMGRID_HAVE_MC)
67       add_dependencies(tests-mc ${example})
68       ADD_TESH_FACTORIES(sthread-mc-${example} "^thread" --setenv libdir=${CMAKE_BINARY_DIR}/lib --cd ${CMAKE_BINARY_DIR}/examples/sthread/${example} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
69     endif()
70   endif()
71
72   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
73   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.cpp)
74 endforeach()
75
76 # Regular sthread examples: test the internal interface for debugging purpose
77 #############################################################################
78
79 foreach(x
80         mutex-simple)
81   if("${CMAKE_SYSTEM}" MATCHES "Linux")
82     add_executable       (sthread-${x} EXCLUDE_FROM_ALL sthread-${x}.c)
83     set_target_properties(sthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
84     target_link_libraries(sthread-${x} sthread)
85     set_property(TARGET sthread-${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
86
87     add_dependencies(tests sthread-${x})
88     ADD_TESH_FACTORIES(sthread-${x} "^thread" --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
89   endif()
90
91   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
92   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.c)
93 endforeach()
94
95
96 # Add all extra files to the archive
97 ####################################
98
99 set(tesh_files    ${tesh_files}     PARENT_SCOPE)
100 set(bin_files     ${bin_files}      PARENT_SCOPE)
101 set(examples_src  ${examples_src}   PARENT_SCOPE)
102 set(xml_files     ${xml_files}      PARENT_SCOPE)
103
104