From 4b847f12f645b953feada796de66bc40b876f4f5 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Tue, 28 Feb 2017 01:00:27 +0000 Subject: FindHDF5: hide HDF5_DIR if HDF5 was found in another way --- Modules/FindHDF5.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 65a825d..c538a81 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -822,3 +822,9 @@ find_package_handle_standard_args(HDF5 ) unset(_HDF5_SEARCH_OPTS) + +if( HDF5_FOUND AND NOT HDF5_DIR) + # hide HDF5_DIR for the non-advanced user to avoid confusion with + # HDF5_DIR-NOT_FOUND while HDF5 was found. + mark_as_advanced(HDF5_DIR) +endif() -- cgit v0.12 From 8250a520aacdeab2c22a24bbd31c23fee787b86e Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Tue, 28 Feb 2017 01:37:11 +0000 Subject: FindHDF5: add HDF5_FIND_DEBUG variable to get debugging output --- Modules/FindHDF5.cmake | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index c538a81..f84b10e 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -90,6 +90,8 @@ # The following variable can be set to guide the search for HDF5 libraries and includes: # # HDF5_ROOT +# +# Set HDF5_FIND_DEBUG to true to get some extra debugging output. # This module is maintained by Will Dicharry . @@ -396,6 +398,9 @@ if(NOT HDF5_FOUND) ${_HDF5_SEARCH_OPTS} ) if( HDF5_FOUND) + if(HDF5_FIND_DEBUG) + message(STATUS "Found HDF5 at ${HDF5_DIR} via NO_MODULE. Now trying to extract locations etc.") + endif() set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) set(HDF5_LIBRARIES) @@ -424,7 +429,11 @@ if(NOT HDF5_FOUND) set(_suffix "") endif() + if(HDF5_FIND_DEBUG) + message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") + endif() get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) + if( _lang_location ) set(HDF5_${_lang}_LIBRARY ${_lang_location} CACHE PATH "HDF5 ${_lang} library" ) @@ -828,3 +837,17 @@ if( HDF5_FOUND AND NOT HDF5_DIR) # HDF5_DIR-NOT_FOUND while HDF5 was found. mark_as_advanced(HDF5_DIR) endif() + +if (HDF5_FIND_DEBUG) + message(STATUS "HDF5_DIR: ${HDF5_DIR}") + message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") + message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") + message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) + message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}") + message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}") + message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}") + message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}") + message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}") + endforeach() +endif() -- cgit v0.12 From 1c7a9119d29568a1e3da82e8e96c8db464d599ab Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Tue, 28 Feb 2017 00:57:29 +0000 Subject: FindHDF5: remove mark_as_advanced for non-cached variables --- Modules/FindHDF5.cmake | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index f84b10e..875098e 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -492,10 +492,6 @@ if(NOT HDF5_FOUND) set(HDF5_${__lang}_HL_LIBRARIES) mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE) - mark_as_advanced(HDF5_${__lang}_DEFINITIONS) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS) - mark_as_advanced(HDF5_${__lang}_LIBRARIES) - mark_as_advanced(HDF5_${__lang}_HL_LIBRARIES) set(HDF5_${__lang}_FOUND True) set(HDF5_HL_FOUND True) @@ -585,9 +581,6 @@ if(NOT HDF5_FOUND) endif() set(HDF5_${__lang}_FOUND True) - mark_as_advanced(HDF5_${__lang}_DEFINITIONS) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS) - mark_as_advanced(HDF5_${__lang}_LIBRARIES) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) -- cgit v0.12 From e629be4a7affe8615c2321b1a08bebb42bb81b15 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Mon, 6 Feb 2017 01:27:56 +0000 Subject: FindHDF5: fix typo in comment --- Modules/FindHDF5.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 875098e..1388aab 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -421,7 +421,7 @@ if(NOT HDF5_FOUND) #if we detect that occurrence clear the suffix if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix}) if(NOT TARGET ${HDF5_${_lang}_TARGET}) - #cant find this component with our without the suffix + #cant find this component with or without the suffix #so bail out, and let the following locate HDF5 set(HDF5_FOUND FALSE) break() -- cgit v0.12 From bf67fff0356f1d0d6996a52eb6fda2358b17b57c Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Mon, 6 Feb 2017 01:27:56 +0000 Subject: FindHDF5: recognize hdf5:: prefix when using hdf5-config.cmake Some versions of HDF5 use this prefix on their imported targets. --- Modules/FindHDF5.cmake | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 1388aab..8d2a034 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -404,12 +404,16 @@ if(NOT HDF5_FOUND) set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) set(HDF5_LIBRARIES) - set(HDF5_C_TARGET hdf5) - set(HDF5_C_HL_TARGET hdf5_hl) - set(HDF5_CXX_TARGET hdf5_cpp) - set(HDF5_CXX_HL_TARGET hdf5_hl_cpp) - set(HDF5_Fortran_TARGET hdf5_fortran) - set(HDF5_Fortran_HL_TARGET hdf5_hl_fortran) + if (NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) + # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc + set(_target_prefix "hdf5::") + endif() + set(HDF5_C_TARGET ${_target_prefix}hdf5) + set(HDF5_C_HL_TARGET ${_target_prefix}hdf5_hl) + set(HDF5_CXX_TARGET ${_target_prefix}hdf5_cpp) + set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) + set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) + set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) if(HDF5_USE_STATIC_LIBRARIES) set(_suffix "-static") else() -- cgit v0.12 From 003c91385a050fc3b469e9f4d1ccf22e70f0f709 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Mon, 6 Feb 2017 01:27:56 +0000 Subject: FindHDF5: do not cache library locations when using hdf5-config.cmake The imported targets provide a persistent reference of their location, so we do not need to cache the values. --- Modules/FindHDF5.cmake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 8d2a034..ae2c707 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -439,9 +439,7 @@ if(NOT HDF5_FOUND) get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) if( _lang_location ) - set(HDF5_${_lang}_LIBRARY ${_lang_location} CACHE PATH - "HDF5 ${_lang} library" ) - mark_as_advanced(HDF5_${_lang}_LIBRARY) + set(HDF5_${_lang}_LIBRARY ${_lang_location}) list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_${_lang}_FOUND True) @@ -449,9 +447,7 @@ if(NOT HDF5_FOUND) if(FIND_HL) get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) if( _lang_hl_location ) - set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location} CACHE PATH - "HDF5 ${_lang} HL library" ) - mark_as_advanced(HDF5_${_lang}_HL_LIBRARY) + set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location}) list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) set(HDF5_HL_FOUND True) -- cgit v0.12 From b2de6da2f161cde26178e568974fa5ef7f7480fc Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Mon, 6 Feb 2017 01:27:56 +0000 Subject: FindHDF5: use import libraries when using hdf5-config.cmake on Windows The `LOCATION` of imported shared libraries on Windows is that of the `.dll`. Use the import library instead to get the `.lib` to be linked. Fixes: #16534 --- Modules/FindHDF5.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index ae2c707..a85b9ac 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -436,8 +436,13 @@ if(NOT HDF5_FOUND) if(HDF5_FIND_DEBUG) message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") endif() - get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) - + # Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib. + get_target_property(_imported_conf ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_CONFIGURATIONS) + get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} ) + if (NOT _lang_location) + # no import lib, just try LOCATION + get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) + endif() if( _lang_location ) set(HDF5_${_lang}_LIBRARY ${_lang_location}) list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) @@ -445,7 +450,10 @@ if(NOT HDF5_FOUND) set(HDF5_${_lang}_FOUND True) endif() if(FIND_HL) - get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) + get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} ) + if (NOT _lang_hl_location) + get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) + endif() if( _lang_hl_location ) set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location}) list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) -- cgit v0.12 From 16f1dd0d16365448f9d483a5d00aba356eb2906b Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 16 Feb 2017 23:35:46 +0000 Subject: FindHDF5: document HDF5__DEFINITIONS --- Modules/FindHDF5.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index a85b9ac..96d4960 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -59,12 +59,16 @@ # bindings, if the HL component is enabled # # Available components are: C CXX Fortran and HL. For each enabled language -# binding, a corresponding HDF5_${LANG}_LIBRARIES variable will be defined. +# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially +# HDF5_${LANG}_DEFINITIONS, will be defined. # If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will # also be defined. With all components enabled, the following variables will be defined: # # :: # +# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings +# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings +# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings # HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings # HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -- cgit v0.12 From 2186b323c0bc43b7eecec0f906cff9fe2e57fc0f Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 16 Feb 2017 23:35:46 +0000 Subject: FindHDF5: initialize HDF5_DEFINITIONS when using hdf5-config.cmake --- Modules/FindHDF5.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 96d4960..927ec64 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -418,6 +418,7 @@ if(NOT HDF5_FOUND) set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) + set(HDF5_DEFINITIONS "") if(HDF5_USE_STATIC_LIBRARIES) set(_suffix "-static") else() -- cgit v0.12