From f67a066bddf5f63725912b94243e5367e9806b31 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Mon, 11 Feb 2013 11:17:21 +0100 Subject: [PATCH] Modularize copying of test input files --- CMakeLists.txt | 29 +++----------------- cmake/Modules/OpmSatellites.cmake | 45 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 cmake/Modules/OpmSatellites.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a337907d..01329daa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,32 +225,9 @@ endmacro (cond_disable_test name) cond_disable_test ("AGMG") cond_disable_test ("ERT") -# if ever huge test datafiles are necessary, then change this -# into "create_symlink" (on UNIX only, apparently) -set (make_avail "copy") - -# provide datafiles as inputs for the tests, by copying them -# to a tests/ directory in the output tree (if different) -set (test_INPUT_FILES) -file (GLOB test_DATA "tests/*.xml") -foreach (input_datafile IN LISTS test_DATA) - file (RELATIVE_PATH rel_datafile "${PROJECT_SOURCE_DIR}" ${input_datafile}) - set (output_datafile "${PROJECT_BINARY_DIR}/${rel_datafile}") - if (NOT output_datafile STREQUAL input_datafile) - add_custom_command ( - OUTPUT ${output_datafile} - COMMAND ${CMAKE_COMMAND} - ARGS -E ${make_avail} ${input_datafile} ${output_datafile} - DEPENDS ${input_datafile} - VERBATIM - ) - endif (NOT output_datafile STREQUAL input_datafile) - list (APPEND test_INPUT_FILES "${output_datafile}") -endforeach (input_datafile) -add_custom_target (datafiles - DEPENDS ${test_INPUT_FILES} - COMMENT "Making test data available in output tree" - ) +# make datafiles necessary for tests available in output directory +include (OpmSatellites) +opm_data (test datafiles "tests/*.xml") # compile each of these separately add_custom_target (tests DEPENDS datafiles) diff --git a/cmake/Modules/OpmSatellites.cmake b/cmake/Modules/OpmSatellites.cmake new file mode 100644 index 00000000..415ce5cc --- /dev/null +++ b/cmake/Modules/OpmSatellites.cmake @@ -0,0 +1,45 @@ +# - Build satellites that are dependent of main library + +# Synopsis: +# opm_data (satellite target files) +# +# provides these output variables: +# +# ${satellite_INPUT_FILES} List of all files that are copied +# ${satellite}_DATAFILES Name of target which copies these files +# +# Example: +# +# opm_data (test datafiles "tests/*.xml") +# +macro (opm_data satellite target files) + # if ever huge test datafiles are necessary, then change this + # into "create_symlink" (on UNIX only, apparently) + set (make_avail "copy") + + # provide datafiles as inputs for the tests, by copying them + # to a tests/ directory in the output tree (if different) + set (${satellite}_INPUT_FILES) + file (GLOB ${satellite}_DATA "tests/*.xml") + if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + foreach (input_datafile IN LISTS ${satellite}_DATA) + file (RELATIVE_PATH rel_datafile "${PROJECT_SOURCE_DIR}" ${input_datafile}) + set (output_datafile "${PROJECT_BINARY_DIR}/${rel_datafile}") + add_custom_command ( + OUTPUT ${output_datafile} + COMMAND ${CMAKE_COMMAND} + ARGS -E ${make_avail} ${input_datafile} ${output_datafile} + DEPENDS ${input_datafile} + VERBATIM + ) + list (APPEND ${satellite}_INPUT_FILES "${output_datafile}") + endforeach (input_datafile) + endif(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + + # setup a target which does all the copying + set (${satellite}_DATAFILES "${target}") + add_custom_target (${${satellite}_DATAFILES} + DEPENDS ${${satellite}_INPUT_FILES} + COMMENT "Making test data available in output tree" + ) +endmacro (opm_data satellite target files)