Skip to content

Commit eb1a8c6

Browse files
authored
Merge pull request #641 from sebproell/copy-support-files
CMake: only copy testing support files
2 parents 62ce3e9 + fda7eb1 commit eb1a8c6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cmake/functions/four_c_auto_define_tests.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ endfunction()
213213
##
214214
# Copy support files to the test directory. The support files are copied to a directory that is shared by all tests
215215
# that use the given test base name.
216+
#
217+
# Usage: four_c_add_support_files_to_test(TEST_NAME_BASE [SUPPORT_FILES <file1> <file2> ...])
218+
#
219+
# TEST_NAME_BASE: The base name of the test. Returned by four_c_auto_define_tests().
220+
# SUPPORT_FILES: A list of files to be copied. The files are copied to the test directory. If any of the files
221+
# have an .in suffix, they are configured (replacing all @VAR@ expressions) before copying.
216222
##
217223
function(four_c_add_support_files_to_test _test_name_base)
218224
if(NOT FOUR_C_WITH_GOOGLETEST)
@@ -245,7 +251,15 @@ function(four_c_add_support_files_to_test _test_name_base)
245251
"Copying support file ${_support_file} to ${FOUR_C_TEST_SUPPORT_FILE_DIR}/${_support_file}"
246252
)
247253

248-
configure_file(${_support_file} ${FOUR_C_TEST_SUPPORT_FILE_DIR}/${_support_file})
254+
# If the file is an .in file that requires configuration, do so.
255+
if(_support_file MATCHES ".in$")
256+
# Strip the .in suffix
257+
string(REGEX REPLACE ".in$" "" _support_file_wo_in ${_support_file})
258+
configure_file(${_support_file} ${FOUR_C_TEST_SUPPORT_FILE_DIR}/${_support_file_wo_in} @ONLY)
259+
# Otherwise, just copy the file
260+
else()
261+
configure_file(${_support_file} ${FOUR_C_TEST_SUPPORT_FILE_DIR}/${_support_file} COPYONLY)
262+
endif()
249263
endforeach()
250264

251265
endfunction()

src/core/io/tests/test_files/has_includes/folder2/include2.dat renamed to src/core/io/tests/test_files/has_includes/folder2/include2.dat.in

File renamed without changes.

0 commit comments

Comments
 (0)