Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a sthread example that works (no deadlock)
[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)
9
10   if("${CMAKE_SYSTEM}" MATCHES "Linux")
11     add_executable       (pthread-${x} EXCLUDE_FROM_ALL pthread-${x}.c)
12     set_target_properties(pthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
13     target_link_libraries(pthread-${x} PRIVATE Threads::Threads)
14     target_link_libraries(pthread-${x} PUBLIC "-Wl,-znorelro -Wl,-znoseparate-code") # TODO: convert to target_link_option once cmake is >3.13
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 sthread examples: test the internal interface for debugging purpose
32 #############################################################################
33
34 foreach(x
35         mutex-simple)
36   if("${CMAKE_SYSTEM}" MATCHES "Linux")
37     add_executable       (sthread-${x} EXCLUDE_FROM_ALL sthread-${x}.c)
38     set_target_properties(sthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
39     target_link_libraries(sthread-${x} sthread)
40     set_property(TARGET sthread-${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
41
42     add_dependencies(tests sthread-${x})
43     ADD_TESH_FACTORIES(sthread-${x} "^thread" --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
44   endif()
45
46   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
47   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.c)
48 endforeach()
49
50
51 # Add all extra files to the archive
52 ####################################
53
54 set(tesh_files    ${tesh_files}     PARENT_SCOPE)
55 set(bin_files     ${bin_files}      PARENT_SCOPE)
56 set(examples_src  ${examples_src}   PARENT_SCOPE)
57 set(xml_files     ${xml_files}      PARENT_SCOPE)
58
59