From dadb13f546e149025e26edf8321a12e434482ffb Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 12 Jan 2021 16:20:26 -0500 Subject: FindHDF5: Simplify preprocessor setting de-duplication Use `list(REMOVE_DUPLICATES)` directly. For definitions the order doesn't matter. For include directories it is better to remove late duplicates than early duplicates. --- Modules/FindHDF5.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 05696ae..d363900 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -724,8 +724,8 @@ if(NOT HDF5_FOUND) endif() set(HDF5_${_lang}_FOUND TRUE) - _HDF5_remove_duplicates_from_beginning(HDF5_${_lang}_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_${_lang}_INCLUDE_DIRS) + list(REMOVE_DUPLICATES HDF5_${_lang}_DEFINITIONS) + list(REMOVE_DUPLICATES HDF5_${_lang}_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_${_lang}_LIBRARIES) _HDF5_remove_duplicates_from_beginning(HDF5_${_lang}_HL_LIBRARIES) else() @@ -780,8 +780,8 @@ elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH) endif() endif() endforeach() - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) + list(REMOVE_DUPLICATES HDF5_DEFINITIONS) + list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) set(HDF5_FOUND TRUE) @@ -923,8 +923,8 @@ if( NOT HDF5_FOUND ) set(HDF5_HL_FOUND TRUE) endif() - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) + list(REMOVE_DUPLICATES HDF5_DEFINITIONS) + list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) -- cgit v0.12 From a5fe1712b2fd4971c03e7d898c40caeba7feb4af Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Mon, 11 Jan 2021 23:12:06 +0000 Subject: FindHDF5: Remove unnecessary de-duplication of HDF5_LIBRARIES and friends * When both debug and optimized libraries are found, the corresponding keywords were getting de-duplicated and breaking. * CMake's link line generation de-duplicates in many cases anyway. * Other find modules do not explicitly de-duplicate in general. Fixes: #21670 --- Modules/FindHDF5.cmake | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index d363900..02d6b2f 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -206,22 +206,6 @@ else() set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc) endif() -# We may have picked up some duplicates in various lists during the above -# process for the language bindings (both the C and C++ bindings depend on -# libz for example). Remove the duplicates. It appears that the default -# CMake behavior is to remove duplicates from the end of a list. However, -# for link lines, this is incorrect since unresolved symbols are searched -# for down the link line. Therefore, we reverse the list, remove the -# duplicates, and then reverse it again to get the duplicates removed from -# the beginning. -macro(_HDF5_remove_duplicates_from_beginning _list_name) - if(${_list_name}) - list(REVERSE ${_list_name}) - list(REMOVE_DUPLICATES ${_list_name}) - list(REVERSE ${_list_name}) - endif() -endmacro() - # Test first if the current compilers automatically wrap HDF5 function(_HDF5_test_regular_compiler_C success version is_parallel) set(scratch_directory @@ -726,8 +710,6 @@ if(NOT HDF5_FOUND) set(HDF5_${_lang}_FOUND TRUE) list(REMOVE_DUPLICATES HDF5_${_lang}_DEFINITIONS) list(REMOVE_DUPLICATES HDF5_${_lang}_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_${_lang}_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_${_lang}_HL_LIBRARIES) else() set(_HDF5_NEED_TO_SEARCH TRUE) endif() @@ -782,8 +764,6 @@ elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH) endforeach() list(REMOVE_DUPLICATES HDF5_DEFINITIONS) list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) set(HDF5_FOUND TRUE) set(HDF5_REQUIRED_VARS HDF5_LIBRARIES) if(HDF5_FIND_HL) @@ -925,8 +905,6 @@ if( NOT HDF5_FOUND ) list(REMOVE_DUPLICATES HDF5_DEFINITIONS) list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) # If the HDF5 include directory was found, open H5pubconf.h to determine if # HDF5 was compiled with parallel IO support -- cgit v0.12