From ac172007ce428ac857ef1d7fbe1633b76675fa55 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 25 Sep 2015 16:47:47 +0100 Subject: [PATCH] GRIB-838: Make ifs_samples in build-dir symlinks --- ifs_samples/CMakeLists.txt | 16 ++++++++++++++ ifs_samples/grib1/CMakeLists.txt | 22 +++++++------------ ifs_samples/grib1_mlgrib2/CMakeLists.txt | 22 +++++++------------ .../grib1_mlgrib2_ieee32/CMakeLists.txt | 22 +++++++------------ .../grib1_mlgrib2_ieee64/CMakeLists.txt | 22 +++++++------------ 5 files changed, 48 insertions(+), 56 deletions(-) diff --git a/ifs_samples/CMakeLists.txt b/ifs_samples/CMakeLists.txt index 7a4975007..eb2507ac3 100644 --- a/ifs_samples/CMakeLists.txt +++ b/ifs_samples/CMakeLists.txt @@ -1,3 +1,19 @@ +function( install_samples samples destination_install destination_build ) + set( _samples ${${samples}} ) + # To install the samples + install( FILES ${_samples} + DESTINATION ${destination_install} + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) + + # To symlink the samples to the build-dir for developers + execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${destination_build} ) + foreach( _file ${_samples} ) + get_filename_component(_filename ${_file} NAME) + execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink + ${_file} ${destination_build}/${_filename} ) + endforeach() +endfunction() + add_subdirectory( grib1 ) add_subdirectory( grib1_mlgrib2 ) diff --git a/ifs_samples/grib1/CMakeLists.txt b/ifs_samples/grib1/CMakeLists.txt index 22bebd739..9a8b4e9a2 100644 --- a/ifs_samples/grib1/CMakeLists.txt +++ b/ifs_samples/grib1/CMakeLists.txt @@ -1,19 +1,13 @@ set( _basedir grib1 ) +set( _destination_install ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) +set( _destination_build ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) list( APPEND ifs_samples_${_basedir} - gg_ml.tmpl - gg_sfc.tmpl - sh_ml.tmpl - sh_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_sfc.tmpl + ${ECCODES_SAMPLES_FILES} ) -install( FILES ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) - -file( COPY ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) - -# Also copy the ifs sample files to the build dir (for developer mode) -file( COPY ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) +install_samples( ifs_samples_${_basedir} ${_destination_install} ${_destination_build} ) diff --git a/ifs_samples/grib1_mlgrib2/CMakeLists.txt b/ifs_samples/grib1_mlgrib2/CMakeLists.txt index 318700543..c28663cf5 100644 --- a/ifs_samples/grib1_mlgrib2/CMakeLists.txt +++ b/ifs_samples/grib1_mlgrib2/CMakeLists.txt @@ -1,19 +1,13 @@ set( _basedir grib1_mlgrib2 ) +set( _destination_install ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) +set( _destination_build ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) list( APPEND ifs_samples_${_basedir} - gg_ml.tmpl - gg_sfc.tmpl - sh_ml.tmpl - sh_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_sfc.tmpl + ${ECCODES_SAMPLES_FILES} ) -install( FILES ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) - -file( COPY ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) - -# Also copy the ifs sample files to the build dir (for developer mode) -file( COPY ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) +install_samples( ifs_samples_${_basedir} ${_destination_install} ${_destination_build} ) diff --git a/ifs_samples/grib1_mlgrib2_ieee32/CMakeLists.txt b/ifs_samples/grib1_mlgrib2_ieee32/CMakeLists.txt index 500f3d497..3b3e3b567 100644 --- a/ifs_samples/grib1_mlgrib2_ieee32/CMakeLists.txt +++ b/ifs_samples/grib1_mlgrib2_ieee32/CMakeLists.txt @@ -1,19 +1,13 @@ set( _basedir grib1_mlgrib2_ieee32 ) +set( _destination_install ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) +set( _destination_build ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) list( APPEND ifs_samples_${_basedir} - gg_ml.tmpl - gg_sfc.tmpl - sh_ml.tmpl - sh_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_sfc.tmpl + ${ECCODES_SAMPLES_FILES} ) -install( FILES ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${ECCODES_IFS_SAMPLES_PATH}/${_basedir} - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) - -file( COPY ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_BINARY_DIR}/share/${PROJECT_NAME}/ifs_samples/${_basedir} ) - -# Also copy the ifs sample files to the build dir (for developer mode) -file( COPY ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) +install_samples( ifs_samples_${_basedir} ${_destination_install} ${_destination_build} ) diff --git a/ifs_samples/grib1_mlgrib2_ieee64/CMakeLists.txt b/ifs_samples/grib1_mlgrib2_ieee64/CMakeLists.txt index b3dee95ea..c041dc3b2 100644 --- a/ifs_samples/grib1_mlgrib2_ieee64/CMakeLists.txt +++ b/ifs_samples/grib1_mlgrib2_ieee64/CMakeLists.txt @@ -1,19 +1,13 @@ set( _basedir grib1_mlgrib2_ieee64 ) +set( _destination_install ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) +set( _destination_build ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) list( APPEND ifs_samples_${_basedir} - gg_ml.tmpl - gg_sfc.tmpl - sh_ml.tmpl - sh_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/gg_sfc.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_ml.tmpl + ${CMAKE_CURRENT_SOURCE_DIR}/sh_sfc.tmpl + ${ECCODES_SAMPLES_FILES} ) -install( FILES ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_INSTALL_PREFIX}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) - -file( COPY ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_BINARY_DIR}/${ECCODES_IFS_SAMPLES_SUFF}/${_basedir} ) - -# Also copy the ifs sample files to the build dir (for developer mode) -file( COPY ${ECCODES_SAMPLES_FILES} ${ifs_samples_${_basedir}} - DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) +install_samples( ifs_samples_${_basedir} ${_destination_install} ${_destination_build} )