From 6214a918f1dff262e79b1dfe732741512de66f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20Pep=C3=A8=20Sciarria?= Date: Thu, 5 Jun 2025 16:24:43 +0200 Subject: [PATCH] add installation of test under samples --- CMakeLists.txt | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8aaca80..f330e3d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -369,10 +369,35 @@ export( -# Optionally, you can install the headers -#install(DIRECTORY include/ -# DESTINATION include -#) +# Set the installation directory for the test files +set(INSTALL_TEST_DIR "${CMAKE_INSTALL_PREFIX}/test" CACHE PATH "Installation directory for test files") + +function(install_directory_recursive source_dir install_base_dir) # Function to install a directory and its subdirectories recursively + file(GLOB_RECURSE ALL_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}" "${source_dir}/*") + + foreach(FILE_PATH IN LISTS ALL_FILES) + # Construct the full source and destination paths + set(FULL_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}/${FILE_PATH}") + set(FULL_INSTALL_PATH "${install_base_dir}/${FILE_PATH}") + + # Check if it's a directory + if(IS_DIRECTORY "${FULL_SOURCE_PATH}") + # Create the directory in the install destination + file(MAKE_DIRECTORY "${FULL_INSTALL_PATH}") + else() + # Install the file + install(FILES "${FULL_SOURCE_PATH}" DESTINATION "${install_base_dir}" RENAME "${FILE_PATH}") + endif() + endforeach() +endfunction() + + + +# Install test/fileread directory +install_directory_recursive(samples/simple "${INSTALL_TEST_DIR}/simple") + +# Install test/pdegen directory +install_directory_recursive(samples/advanced "${INSTALL_TEST_DIR}/advanced")