diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 0a476d4df..3ec754a61 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -6,18 +6,17 @@ add_subdirectory(gts) # Download all the binary GRIB data from website -# -FILE(READ "grib_data_files.txt" files_to_download) -STRING(REGEX REPLACE "\n" ";" files_to_download "${files_to_download}") + +file(READ "grib_data_files.txt" files_to_download) +string(REGEX REPLACE "\n" ";" files_to_download "${files_to_download}") if( HAVE_AEC ) - LIST(APPEND files_to_download ccsds.grib2) + list(APPEND files_to_download ccsds.grib2) endif() # Download all data files doing md5 check on each ecbuild_get_test_multidata( TARGET get_gribs - NAMES ${files_to_download} -) + NAMES ${files_to_download} ) # Copy other files - e.g. reference data, text files etc from the source data dir LIST(APPEND other_files diff --git a/data/tigge/CMakeLists.txt b/data/tigge/CMakeLists.txt index c93b9dbd0..6c6df6b4b 100644 --- a/data/tigge/CMakeLists.txt +++ b/data/tigge/CMakeLists.txt @@ -1,10 +1,9 @@ # data/tigge/CMakeLists.txt # Download all the TIGGE grib data from website -# -FILE(READ "tigge_data_files.txt" tigge_files_to_download) -STRING(REGEX REPLACE "\n" ";" tigge_files_to_download "${tigge_files_to_download}") + +file(READ "tigge_data_files.txt" tigge_files_to_download) +string(REGEX REPLACE "\n" ";" tigge_files_to_download "${tigge_files_to_download}") # Download all data files doing md5 check on each ecbuild_get_test_multidata( TARGET get_tigge_gribs - NAMES ${tigge_files_to_download} -) + NAMES ${tigge_files_to_download} ) diff --git a/definitions/CMakeLists.txt b/definitions/CMakeLists.txt index d5e0c5440..1c8c3ea64 100644 --- a/definitions/CMakeLists.txt +++ b/definitions/CMakeLists.txt @@ -19,6 +19,12 @@ install( DIRECTORY budg bufr cdf common grib1 grib2 gts mars metar tide hdf5 wr PATTERN "4.2.192.*.table" EXCLUDE PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) +# link to the definitions. See GRIB-786 +file( MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME} ) +execute_process( COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/definitions" ) + # copy the definitions to the build directory #file( COPY ${definition_files} ${table_files} ${text_files} # DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/definitions ) diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 0ac60a3e7..9ea8351a7 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -3,6 +3,7 @@ # Configure the file which all CMake tests will include configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} ) # Build the executables used by test scripts ################################################ @@ -92,7 +93,6 @@ foreach( test ${tests} ) ecbuild_add_test( TARGET c_${test} TYPE SCRIPT COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh - RESOURCES include.sh TEST_DEPENDS get_gribs get_bufrs ) endforeach() diff --git a/examples/C/include.ctest.sh.in b/examples/C/include.ctest.sh.in index cd0e412ca..28b292331 100644 --- a/examples/C/include.ctest.sh.in +++ b/examples/C/include.ctest.sh.in @@ -10,7 +10,8 @@ fi proj_dir=@PROJECT_SOURCE_DIR@ data_dir=@PROJECT_BINARY_DIR@/data -def_dir="@PROJECT_SOURCE_DIR@/definitions" +# use definitions from binary dir to test if installation will be correct +def_dir="@CMAKE_BINARY_DIR@/share/@PROJECT_NAME@/definitions" ECCODES_DEFINITION_PATH="${def_dir}" export ECCODES_DEFINITION_PATH diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index f4a23ff1c..fdf5aec34 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -3,6 +3,7 @@ # Configure the file which all CMake tests will include configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} ) # Build the executables used by test scripts ################################################ @@ -43,33 +44,14 @@ list( APPEND tests get_product_kind ) -# Simplify tests: no need to build executable and then test. All in one -# TODO -# ecbuild_add_test( TARGET test_f90_samples -# LINKER_LANGUAGE Fortran -# SOURCES samples.f90 -# LIBS eccodes_f90 eccodes -# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/samples.sh -# CONDITION HAVE_FORTRAN -# ) - foreach( tool ${tests} ) - # Build the Fortran executable - ecbuild_add_executable( TARGET f_${tool} - NOINSTALL - SOURCES ${tool}.f90 - CONDITION HAVE_FORTRAN - LINKER_LANGUAGE Fortran - LIBS eccodes_f90 eccodes - ) - # Add the test which depends on the above executable - ecbuild_add_test( TARGET f_${tool}_test - TYPE SCRIPT - DEPENDS f_${tool} + ecbuild_add_test( TARGET f_${tool} + SOURCES ${tool}.f90 + LINKER_LANGUAGE Fortran + LIBS eccodes_f90 eccodes CONDITION HAVE_FORTRAN COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh - RESOURCES include.sh TEST_DEPENDS get_gribs get_bufrs ) endforeach() @@ -104,6 +86,4 @@ ecbuild_add_executable( TARGET f_set_gvc # TYPE SCRIPT # DEPENDS set_gvc set # COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set.sh -# RESOURCES include.sh # ) -# diff --git a/examples/F90/include.ctest.sh.in b/examples/F90/include.ctest.sh.in index 61053cc97..4e86c5147 100644 --- a/examples/F90/include.ctest.sh.in +++ b/examples/F90/include.ctest.sh.in @@ -10,7 +10,8 @@ fi proj_dir=@PROJECT_SOURCE_DIR@ data_dir=@PROJECT_BINARY_DIR@/data -def_dir="@PROJECT_SOURCE_DIR@/definitions" +# use definitions from binary dir to test if installation will be correct +def_dir="@CMAKE_BINARY_DIR@/share/@PROJECT_NAME@/definitions" ECCODES_DEFINITION_PATH="${def_dir}" export ECCODES_DEFINITION_PATH diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index d4b930267..9c8468f97 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -3,6 +3,7 @@ # Configure the file which all CMake tests will include configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} ) # Build the executables used by test scripts ################################################ @@ -12,6 +13,7 @@ list( APPEND test_bins grib_iterator count_messages ) + foreach( tool ${test_bins} ) ecbuild_add_executable( TARGET p_${tool} NOINSTALL @@ -22,6 +24,7 @@ foreach( tool ${test_bins} ) list( APPEND ptools p_${tool} ) endforeach() + # Now add each test ################################################# list( APPEND tests @@ -60,7 +63,7 @@ foreach( test ${tests} ) DEPENDS ${ptools} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh CONDITION HAVE_PYTHON - RESOURCES include.sh ${test}.py + RESOURCES ${test}.py ENVIRONMENT PYTHON=${PYTHON_EXECUTABLE} TEST_DEPENDS get_gribs get_tigge_gribs get_bufrs ) diff --git a/examples/python/include.ctest.sh.in b/examples/python/include.ctest.sh.in index f8b7af33c..e3af05857 100644 --- a/examples/python/include.ctest.sh.in +++ b/examples/python/include.ctest.sh.in @@ -10,7 +10,8 @@ fi proj_dir=@PROJECT_SOURCE_DIR@ data_dir=@PROJECT_BINARY_DIR@/data -def_dir="@PROJECT_SOURCE_DIR@/definitions" +# use definitions from binary dir to test if installation will be correct +def_dir="@CMAKE_BINARY_DIR@/share/@PROJECT_NAME@/definitions" ECCODES_DEFINITION_PATH="${def_dir}" export ECCODES_DEFINITION_PATH diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index b4dab7601..02409dde8 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -11,7 +11,9 @@ endforeach() set( ECCODES_SAMPLES_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE ) set( ECCODES_SAMPLES_FILES ${ECCODES_SAMPLES_FILES} PARENT_SCOPE ) -# copy the samples to the build directory +# link to the samples in the build directory. See GRIB-786 +file( MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME} ) +execute_process( COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/samples" ) -file( COPY ${samples_files} - DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/samples ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 74aca895d..038db9230 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,6 +3,10 @@ # Configure the file which all CMake tests will include configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/utils.sh ${CMAKE_CURRENT_BINARY_DIR} ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/number_compare.pl ${CMAKE_CURRENT_BINARY_DIR} ) + # Build the executables used by test scripts ################################################ list( APPEND test_bins @@ -87,7 +91,6 @@ foreach( test ${tests1} ) ecbuild_add_test( TARGET t_${test} TYPE SCRIPT COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh - RESOURCES include.sh utils.sh number_compare.pl ) endforeach() @@ -98,7 +101,6 @@ foreach( test ${tests2} ) ecbuild_add_test( TARGET t_${test} TYPE SCRIPT COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh - RESOURCES include.sh utils.sh number_compare.pl TEST_DEPENDS get_gribs get_tigge_gribs get_bufrs get_metars get_gts ) endforeach() @@ -108,7 +110,7 @@ endforeach() 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 + RESOURCES lamb_az_eq_area.ref TEST_DEPENDS get_gribs ) @@ -117,7 +119,6 @@ ecbuild_add_test( TARGET t_grib_to_netcdf TYPE SCRIPT CONDITION HAVE_NETCDF COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_to_netcdf.sh - RESOURCES include.sh TEST_DEPENDS get_gribs ) @@ -125,7 +126,6 @@ ecbuild_add_test( TARGET t_jpeg TYPE SCRIPT CONDITION HAVE_JPEG COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jpeg.sh - RESOURCES include.sh TEST_DEPENDS get_gribs ) @@ -133,7 +133,5 @@ ecbuild_add_test( TARGET t_ccsds TYPE SCRIPT CONDITION HAVE_AEC COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ccsds.sh - RESOURCES include.sh TEST_DEPENDS get_gribs ) - diff --git a/tests/include.ctest.sh.in b/tests/include.ctest.sh.in index 74a93a684..cb1dd5a68 100644 --- a/tests/include.ctest.sh.in +++ b/tests/include.ctest.sh.in @@ -10,7 +10,8 @@ fi proj_dir=@PROJECT_SOURCE_DIR@ data_dir=@PROJECT_BINARY_DIR@/data -def_dir="@PROJECT_SOURCE_DIR@/definitions" +# use definitions from binary dir to test if installation will be correct +def_dir="@CMAKE_BINARY_DIR@/share/@PROJECT_NAME@/definitions" ECCODES_DEFINITION_PATH="${def_dir}" export ECCODES_DEFINITION_PATH