Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'add_wait_for_to_py_comm_binding' into 'master'
[simgrid.git] / teshsuite / smpi / MBI / CMakeLists.txt
1 # Copyright 2021-2022. The SimGrid Team. All rights reserved. 
2
3 # Integrates the MBI tests into the SimGrid build chain when asked to
4
5 # Only the python scripts are embeeded in the archive, and the C test files are generated at config time using these scripts.
6 # These python scripts are copied over from the MBI repository with as little changes as possible.
7
8 set(generator_scripts CollMatchingGenerator.py) # More generators to come
9
10 if (enable_smpi_MBI_testsuite)
11   if (NOT enable_smpi)
12     message(FATAL_ERROR "MBI test suite cannot be enabled without SMPI. Please change either setting.")
13   endif()
14   if (NOT enable_model-checking)
15     message(FATAL_ERROR "MBI test suite cannot be enabled without the Mc SimGrid model-checker. Please change either setting.")
16   endif()
17
18   message(STATUS "Generating the MBI scripts")
19   file(REMOVE_RECURSE  ${CMAKE_BINARY_DIR}/MBI/tmp)
20   file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
21   file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI/tmp)
22   foreach (script ${generator_scripts})
23     message(STATUS "  $ ${CMAKE_CURRENT_SOURCE_DIR}/${script}")
24     execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${script}
25                     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
26   endforeach()
27
28   set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
29   set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx")
30   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
31
32   # Connect the MBI tests to the other tests
33   add_custom_target(tests-mbi COMMENT "Recompiling the MBI tests and tools.")
34   add_dependencies(tests tests-mbi)
35
36   file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
37   foreach(cfile ${cfiles})
38     # Copy the generated files only if different
39     file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
40     string(REGEX REPLACE "[.]c" "" basefile ${cfile})
41     
42     # Generate an executable for each of them
43     add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
44     target_link_libraries(mbi_${basefile} simgrid)
45     target_compile_options(mbi_${basefile} PRIVATE "-Wno-error")
46     set_target_properties(mbi_${basefile} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
47     add_dependencies(tests-mbi mbi_${basefile})
48
49     # Generate a test case for each source file, using the MBI runner
50     ADD_TEST(NAME mbi-${basefile}
51              COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py ${CMAKE_BINARY_DIR} ./mbi_${basefile} ${cfile}
52              WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
53     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS mbi-${basefile})
54     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS simgrid-mc)
55   endforeach()
56
57   if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
58   else()
59     file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI) 
60   endif()
61 endif()
62
63 # Add the needed files to the distribution
64 foreach(script ${generator_scripts})
65   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${script})
66 endforeach()
67
68 set(teshsuite_src ${teshsuite_src}
69                   ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py
70                   ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
71                   ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
72                   ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py
73                   PARENT_SCOPE)