commit 147613fdcb38bf94dce9ff0a9d8d5a8dad8443b1 parent 854d6296f6bd978444389e1e98f68c009024f426 Author: Vincent Forest <vincent.forest@meso-star.com> Date: Fri, 27 Aug 2021 11:49:00 +0200 Look for the ncdump program in the CMakeLists.txt Verify that the ncdump program exists before the program used to test the loading procedure is generated. This test is based on the Bash script using ncdump to extract reference data from a netcdf file. Diffstat:
| M | cmake/CMakeLists.txt | | | 68 | ++++++++++++++++++++++++++++++++++++++------------------------------ |
1 file changed, 38 insertions(+), 30 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -115,42 +115,50 @@ if(NOT NO_TEST) endfunction() new_test(test_htmie) - build_test(test_htmie_load) - set(TEST_FILES Mie_LUT_Cloud) - - foreach(_file IN LISTS TEST_FILES) - set(_netcdf ${PROJECT_SOURCE_DIR}/../${_file}.nc) - set(_script ${HTMIE_SOURCE_DIR}/dump_netcdf_data.sh) - set(_output_base ${CMAKE_CURRENT_BINARY_DIR}/${_file}) - add_custom_command( - OUTPUT + find_program(_ncdump ncdump) + + if(NOT _ncdump) + message(WARNING + "The ncdump program is missing. Could not test the loading of a htmie " + "file.") + else() + build_test(test_htmie_load) + + set(TEST_FILES Mie_LUT_Cloud) + + foreach(_file IN LISTS TEST_FILES) + set(_netcdf ${PROJECT_SOURCE_DIR}/../${_file}.nc) + set(_script ${HTMIE_SOURCE_DIR}/dump_netcdf_data.sh) + set(_output_base ${CMAKE_CURRENT_BINARY_DIR}/${_file}) + add_custom_command( + OUTPUT + ${_output_base}_lambda + ${_output_base}_macs + ${_output_base}_mscs + ${_output_base}_rmod + ${_output_base}_smod + ${_output_base}_g + COMMAND sh ${_script} lambda ${_netcdf} + COMMAND sh ${_script} macs ${_netcdf} + COMMAND sh ${_script} mscs ${_netcdf} + COMMAND sh ${_script} rmod ${_netcdf} + COMMAND sh ${_script} smod ${_netcdf} + COMMAND sh ${_script} g ${_netcdf} + DEPENDS ${_script} + COMMENT "Dump data of the ${_file} NetCDF" + VERBATIM) + add_test(test_htmie_load_${_file} + test_htmie_load ${_netcdf} ${CMAKE_CURRENT_BINARY_DIR}) + add_custom_target(dump-${_file}.nc ALL DEPENDS ${_output_base}_lambda ${_output_base}_macs ${_output_base}_mscs ${_output_base}_rmod ${_output_base}_smod - ${_output_base}_g - COMMAND sh ${_script} lambda ${_netcdf} - COMMAND sh ${_script} macs ${_netcdf} - COMMAND sh ${_script} mscs ${_netcdf} - COMMAND sh ${_script} rmod ${_netcdf} - COMMAND sh ${_script} smod ${_netcdf} - COMMAND sh ${_script} g ${_netcdf} - DEPENDS ${_script} - COMMENT "Dump data of the ${_file} NetCDF" - VERBATIM) - add_test(test_htmie_load_${_file} - test_htmie_load ${_netcdf} ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_target(dump-${_file}.nc ALL DEPENDS - ${_output_base}_lambda - ${_output_base}_macs - ${_output_base}_mscs - ${_output_base}_rmod - ${_output_base}_smod - ${_output_base}_g) - endforeach() - + ${_output_base}_g) + endforeach() + endif() endif() ################################################################################