From c182c87963b64fae1235a0b09bea4937d41bb133 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Mon, 11 Jan 2021 16:17:48 -0500 Subject: [PATCH] Modify ctest so we can package the testfiles and install on the target. This lets us run the volk tests on the embedded target easily. Major changes are not including full paths to files, since these were based on the build system paths and not setting paths to find libraries in the build directory. Signed-off-by: Philip Balister --- cmake/Modules/VolkAddTest.cmake | 36 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/cmake/Modules/VolkAddTest.cmake b/cmake/Modules/VolkAddTest.cmake index 46f35f046..be39c23d4 100644 --- a/cmake/Modules/VolkAddTest.cmake +++ b/cmake/Modules/VolkAddTest.cmake @@ -139,17 +139,18 @@ function(VOLK_ADD_TEST test_name executable_name) #generate a shell script file that sets the environment and runs the test set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) file(WRITE ${sh_file} "#!${SHELL}\n") - if(SHELL_SUPPORTS_IFS) - file(APPEND ${sh_file} "export IFS=:\n") - else() - file(APPEND ${sh_file} "LL=\"$1\" && for tf in \"\$@\"; do LL=\"\${LL}:\${tf}\"; done\n") - endif() - - #each line sets an environment variable - foreach(environ ${environs}) - file(APPEND ${sh_file} "export ${environ}\n") - endforeach(environ) - + if (NOT CMAKE_CROSSCOMPILING) + if(SHELL_SUPPORTS_IFS) + file(APPEND ${sh_file} "export IFS=:\n") + else() + file(APPEND ${sh_file} "LL=\"$1\" && for tf in \"\$@\"; do LL=\"\${LL}:\${tf}\"; done\n") + endif() + + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${sh_file} "export ${environ}\n") + endforeach(environ) + endif(CMAKE_CROSSCOMPILING) set(VOLK_TEST_ARGS "${test_name}") #redo the test args to have a space between each @@ -164,10 +165,15 @@ function(VOLK_ADD_TEST test_name executable_name) #add the shell file as the test to execute; #use the form that allows for $ substitutions, #then combine the script arguments inside the script. - add_test(NAME qa_${test_name} - COMMAND ${SHELL} ${sh_file} ${TARGET_DIR_LIST} - ) - + if (NOT CMAKE_CROSSCOMPILING) + add_test(NAME qa_${test_name} + COMMAND ${SHELL} ${sh_file} ${TARGET_DIR_LIST} + ) + else() + add_test(NAME qa_${test_name} + COMMAND ${SHELL} ${test_name}_test.sh ${TARGET_DIR_LIST} + ) + endif(CMAKE_CROSSCOMPILING) endif(UNIX) if(WIN32)