From 549fc7fa3ad9ba1117120d3f61eaf5a08d609565 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 10 Mar 2015 15:52:33 +0000 Subject: [PATCH] GRIB-711: CMake build: should not need to download data to compile --- data/CMakeLists.txt | 17 ++++------------- data/bufr/CMakeLists.txt | 19 +++++-------------- data/tigge/CMakeLists.txt | 18 ++++-------------- examples/C/CMakeLists.txt | 1 + examples/F90/CMakeLists.txt | 1 + examples/python/CMakeLists.txt | 1 + tests/CMakeLists.txt | 12 ++++++++---- 7 files changed, 24 insertions(+), 45 deletions(-) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 2df942ee4..2e3650216 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -95,15 +95,10 @@ if( HAVE_AEC ) LIST(APPEND files_to_download ccsds.grib2) endif() - -foreach( f ${files_to_download} ) - set(tgt data_${f}) - # Download the file and create a dummy target for it - ecbuild_get_test_data(TARGET "${tgt}" NAME "${f}" DIRNAME ${PROJECT_NAME}/data NOCHECK) - - # Add to list of targets - LIST(APPEND tgts "${tgt}") -endforeach() +ecbuild_get_test_multidata( TARGET get_gribs + NOCHECK + NAMES ${files_to_download} +) # Copy other files - e.g. reference data, text files etc from the source data dir LIST(APPEND other_files @@ -151,7 +146,3 @@ foreach( file ${other_files} ) execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${CMAKE_CURRENT_BINARY_DIR} ) endforeach() -# debug_var(tgts) -# Another dummy target which depends on all previous targets -#add_custom_target( get_gribs ALL DEPENDS ${tgts} ) -add_custom_target( get_gribs DEPENDS ${tgts} ) diff --git a/data/bufr/CMakeLists.txt b/data/bufr/CMakeLists.txt index 24adb1e59..0e991214d 100644 --- a/data/bufr/CMakeLists.txt +++ b/data/bufr/CMakeLists.txt @@ -412,17 +412,8 @@ set(bufr_refs_to_download syno_multi.bufr ) -foreach( f ${bufr_files_to_download} ${bufr_refs_to_download} ) - set(tgt bufr_data_${f}) - # Download the file and create a dummy target for it - ecbuild_get_test_data(TARGET "${tgt}" - NAME "${f}" - DIRNAME ${PROJECT_NAME}/data/bufr - NOCHECK) - - # Add to list of targets - LIST(APPEND tgts "${tgt}") -endforeach() - -add_custom_target( get_bufrs DEPENDS ${tgts} ) - +ecbuild_get_test_multidata( + TARGET get_bufrs + NOCHECK + NAMES ${bufr_files_to_download} ${bufr_refs_to_download} +) diff --git a/data/tigge/CMakeLists.txt b/data/tigge/CMakeLists.txt index 1a7c52c57..d96d556e2 100644 --- a/data/tigge/CMakeLists.txt +++ b/data/tigge/CMakeLists.txt @@ -244,17 +244,7 @@ set(tigge_files_to_download tiggelam_cnmc_sfc.grib ) -foreach( f ${tigge_files_to_download} ) - set(tgt tigge_data_${f}) - # Download the file and create a dummy target for it - ecbuild_get_test_data(TARGET "${tgt}" - NAME "${f}" - DIRNAME ${PROJECT_NAME}/data/tigge - NOCHECK) - - # Add to list of targets - LIST(APPEND tgts "${tgt}") -endforeach() - -add_custom_target( get_tigge_gribs DEPENDS ${tgts} ) - +ecbuild_get_test_multidata( TARGET get_tigge_gribs + NOCHECK + NAMES ${tigge_files_to_download} +) diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 9bfe7c5a5..7d08cafe1 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -88,6 +88,7 @@ foreach( test ${tests} ) TYPE SCRIPT COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh RESOURCES include.sh + TEST_DEPENDS get_gribs get_bufrs ) endforeach() diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index 4d284438b..957a5f8c4 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -67,6 +67,7 @@ foreach( tool ${tests} ) CONDITION EC_HAVE_FORTRAN COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh RESOURCES include.sh + TEST_DEPENDS get_gribs get_bufrs ) endforeach() diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index c5e5bc789..ce8a22ab9 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -57,5 +57,6 @@ foreach( test ${tests} ) CONDITION HAVE_PYTHON RESOURCES include.sh ${test}.py ENVIRONMENT PYTHON=${PYTHON_EXECUTABLE} + TEST_DEPENDS get_gribs get_tigge_gribs get_bufrs ) endforeach() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0844c37b9..fdd0c083c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -76,15 +76,15 @@ list( APPEND tests unit_tests ) +# Note: making the test dependent on the grib files (with DEPENDS) +# means they will be downloaded at "make" time +# rather than when you do "make test". Use TEST_DEPENDS instead foreach( test ${tests} ) - # Note: making the test dependent on the grib data files - # means they will be downloaded at "make" time - # rather than when you do "make test" ecbuild_add_test( TARGET t_${test} TYPE SCRIPT - DEPENDS get_gribs get_tigge_gribs get_bufrs COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh RESOURCES include.sh number_compare.pl + TEST_DEPENDS get_gribs get_tigge_gribs get_bufrs ) endforeach() @@ -94,6 +94,7 @@ ecbuild_add_test( TARGET t_lamb_az_eq_area TYPE SCRIPT COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lamb_az_eq_area.sh RESOURCES include.sh lamb_az_eq_area.ref + TEST_DEPENDS get_gribs ) # These ones are conditional @@ -102,6 +103,7 @@ ecbuild_add_test( TARGET t_grib_to_netcdf CONDITION HAVE_NETCDF COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_to_netcdf.sh RESOURCES include.sh + TEST_DEPENDS get_gribs ) ecbuild_add_test( TARGET t_jpeg @@ -109,6 +111,7 @@ ecbuild_add_test( TARGET t_jpeg CONDITION HAVE_JPEG COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jpeg.sh RESOURCES include.sh + TEST_DEPENDS get_gribs ) ecbuild_add_test( TARGET t_ccsds @@ -116,5 +119,6 @@ ecbuild_add_test( TARGET t_ccsds CONDITION HAVE_AEC COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ccsds.sh RESOURCES include.sh + TEST_DEPENDS get_gribs )