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 ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
+ # 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
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()