From 6a626a235dcf14378ff0a24539ebb2c6e147eb59 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 28 Aug 2015 14:00:17 +0100 Subject: [PATCH] GRIB-822 Export samples and definition paths for install and build trees With ECBUILD-105 is is possible to check for build vs. install tree export in -import.cmake scripts. Use this to export the correct GRIB_API_DEFINITION_PATH, GRIB_API_SAMPLES_PATH, GRIB_API_IFS_SAMPLES_PATH in grib_api-import.cmake for dependent projects to use. --- CMakeLists.txt | 28 ++++++++++++++++------------ eccodes-import.cmake.in | 9 +++++++++ grib_api-import.cmake.in | 3 --- 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 eccodes-import.cmake.in delete mode 100644 grib_api-import.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 943442cd0..a261fdba5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,8 +85,8 @@ endif() ecbuild_add_option( FEATURE MEMORY_MANAGEMENT DESCRIPTION "enable memory management" DEFAULT OFF ADVANCED ) ecbuild_add_option( FEATURE ALIGN_MEMORY DESCRIPTION "enable memory alignment" DEFAULT OFF ADVANCED ) -ecbuild_add_option( FEATURE GRIB_TIMER DESCRIPTION "enable timer" DEFAULT OFF ADVANCED ) -ecbuild_add_option( FEATURE ECCODES_THREADS DESCRIPTION "enable threads" DEFAULT OFF ADVANCED ) +ecbuild_add_option( FEATURE GRIB_TIMER DESCRIPTION "enable timer" DEFAULT OFF ADVANCED ) +ecbuild_add_option( FEATURE ECCODES_THREADS DESCRIPTION "enable threads" DEFAULT OFF ADVANCED ) ############################################################################### # macro processing @@ -186,19 +186,23 @@ endif() # contents if( NOT ${DEVELOPER_MODE} ) - set( grib_api_default_data_prefix ${CMAKE_INSTALL_PREFIX} ) + set( the_default_data_prefix ${CMAKE_INSTALL_PREFIX} ) else() - set( grib_api_default_data_prefix ${CMAKE_BINARY_DIR} ) + set( the_default_data_prefix ${CMAKE_BINARY_DIR} ) endif() +set( ECCODES_DEFINITION_SUFF share/eccodes/definitions ) +set( ECCODES_SAMPLES_SUFF share/eccodes/samples ) +set( ECCODES_IFS_SAMPLES_SUFF share/eccodes/ifs_samples ) + if( NOT DEFINED ECCODES_DEFINITION_PATH ) - set( ECCODES_DEFINITION_PATH ${grib_api_default_data_prefix}/share/eccodes/definitions ) + set( ECCODES_DEFINITION_PATH ${the_default_data_prefix}/${ECCODES_DEFINITION_SUFF} ) endif() if( NOT DEFINED ECCODES_SAMPLES_PATH ) - set( ECCODES_SAMPLES_PATH ${grib_api_default_data_prefix}/share/eccodes/samples ) + set( ECCODES_SAMPLES_PATH ${the_default_data_prefix}/${ECCODES_SAMPLES_SUFF} ) endif() if( NOT DEFINED ECCODES_IFS_SAMPLES_PATH ) - set( ECCODES_IFS_SAMPLES_PATH ${grib_api_default_data_prefix}/share/eccodes/ifs_samples ) + set( ECCODES_IFS_SAMPLES_PATH ${the_default_data_prefix}/${ECCODES_IFS_SAMPLES_SUFF} ) endif() ### config header @@ -276,13 +280,13 @@ if( EC_HAVE_FORTRAN ) endif() if( NOT PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME ) - set( ECCODES_DEFINITIONS ${ECCODES_DEFINITIONS} PARENT_SCOPE )# includes already TPL definitions + set( ECCODES_DEFINITIONS ${ECCODES_DEFINITIONS} PARENT_SCOPE )# includes already TPL definitions set( ECCODES_INCLUDE_DIRS ${ECCODES_INCLUDE_DIRS} ${ECCODES_EXTRA_INCLUDE_DIRS} PARENT_SCOPE ) set( ECCODES_LIBRARIES ${ECCODES_LIBRARIES} ${ECCODES_EXTRA_LIBRARIES} ${CMATH_LIBRARIES} PARENT_SCOPE ) - set( ECCODES_FOUND TRUE PARENT_SCOPE ) - set( ECCODES_SAMPLES_PATH ${ECCODES_SAMPLES_PATH} PARENT_SCOPE ) - set( ECCODES_IFS_SAMPLES_PATH ${ECCODES_IFS_SAMPLES_PATH} PARENT_SCOPE ) - set( ECCODES_DEFINITION_PATH ${ECCODES_DEFINITION_PATH} PARENT_SCOPE ) + set( ECCODES_FOUND TRUE PARENT_SCOPE ) + set( ECCODES_SAMPLES_PATH ${ECCODES_SAMPLES_PATH} PARENT_SCOPE ) + set( ECCODES_IFS_SAMPLES_PATH ${ECCODES_IFS_SAMPLES_PATH} PARENT_SCOPE ) + set( ECCODES_DEFINITION_PATH ${ECCODES_DEFINITION_PATH} PARENT_SCOPE ) set( ECCODES_INSTALL_ECMWF_TOOLS ${ECCODES_INSTALL_ECMWF_TOOLS} PARENT_SCOPE ) endif() diff --git a/eccodes-import.cmake.in b/eccodes-import.cmake.in new file mode 100644 index 000000000..9a6f7833e --- /dev/null +++ b/eccodes-import.cmake.in @@ -0,0 +1,9 @@ +if( @PNAME@_IS_BUILD_DIR_EXPORT ) + set( ECCODES_DEFINITION_PATH @CMAKE_BINARY_DIR@/@ECCODES_DEFINITION_SUFF@ ) + set( ECCODES_SAMPLES_PATH @CMAKE_BINARY_DIR@/@ECCODES_SAMPLES_SUFF@ ) + set( ECCODES_IFS_SAMPLES_PATH @CMAKE_BINARY_DIR@/@ECCODES_IFS_SAMPLES_SUFF@ ) +else() + set( ECCODES_DEFINITION_PATH @CMAKE_INSTALL_PREFIX@/@ECCODES_DEFINITION_SUFF@ ) + set( ECCODES_SAMPLES_PATH @CMAKE_INSTALL_PREFIX@/@ECCODES_SAMPLES_SUFF@ ) + set( ECCODES_IFS_SAMPLES_PATH @CMAKE_INSTALL_PREFIX@/@ECCODES_IFS_SAMPLES_SUFF@ ) +endif() diff --git a/grib_api-import.cmake.in b/grib_api-import.cmake.in deleted file mode 100644 index c750d33bb..000000000 --- a/grib_api-import.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ -set( ECCODES_SAMPLES_PATH "@ECCODES_SAMPLES_PATH@" ) -set( ECCODES_IFS_SAMPLES_PATH "@ECCODES_IFS_SAMPLES_PATH@" ) -set( ECCODES_DEFINITION_PATH "@ECCODES_DEFINITION_PATH@" )