Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Suppress trailing whitespaces.
[simgrid.git] / teshsuite / smpi / MBI / CMakeLists.txt
index 808cd70..fd2aa91 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2021-2022. The SimGrid Team. All rights reserved. 
+# Copyright 2021-2022. The SimGrid Team. All rights reserved.
 
 # Integrates the MBI tests into the SimGrid build chain when asked to
 
@@ -35,10 +35,14 @@ if (enable_smpi_MBI_testsuite)
 
   file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
   foreach(cfile ${cfiles})
-    # Copy the generated files only if different
-    file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
+    # Copy the generated files only if different (needs cmake ≥ 3.21)
+    if (CMAKE_VERSION VERSION_LESS 3.21)
+      file(COPY ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
+    else()
+      file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
+    endif()
     string(REGEX REPLACE "[.]c" "" basefile ${cfile})
-    
+
     # Generate an executable for each of them
     add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
     target_link_libraries(mbi_${basefile} simgrid)
@@ -53,10 +57,11 @@ if (enable_smpi_MBI_testsuite)
     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS mbi-${basefile})
     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS simgrid-mc)
   endforeach()
+  file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp) # Clean temp files
 
   if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
   else()
-    file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI) 
+    file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI)
   endif()
 endif()
 
@@ -70,4 +75,4 @@ set(teshsuite_src ${teshsuite_src}
                   ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
                   ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
                   ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py
-                  PARENT_SCOPE)
\ No newline at end of file
+                  PARENT_SCOPE)