Skip to content

Commit

Permalink
Merge 79113c5 into 260a830
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenBent authored Nov 3, 2020
2 parents 260a830 + 79113c5 commit 228b046
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmake/src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ if(WIN32)
endif()

if(HDF5_FOUND)
target_link_libraries(${PROJECT_NAME} PUBLIC HDF5::HDF5)
target_link_libraries(${PROJECT_NAME} PUBLIC MATIO::HDF5)
endif()

if(ZLIB_FOUND)
target_link_libraries(${PROJECT_NAME} PUBLIC ZLIB::ZLIB)
target_link_libraries(${PROJECT_NAME} PUBLIC MATIO::ZLIB)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ${MATIO_PIC})
Expand Down
26 changes: 17 additions & 9 deletions cmake/thirdParties.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,31 @@ endif()

if(HDF5_FOUND)
set(HAVE_HDF5 1)
add_library(HDF5::HDF5 INTERFACE IMPORTED)
add_library(MATIO::HDF5 INTERFACE IMPORTED)
if(MATIO_USE_CONAN AND TARGET CONAN_PKG::hdf5)
# target from Conan
target_link_libraries(HDF5::HDF5 INTERFACE CONAN_PKG::hdf5)
target_link_libraries(MATIO::HDF5 INTERFACE CONAN_PKG::hdf5)
elseif(HDF5_USE_STATIC_LIBRARIES AND TARGET hdf5::hdf5-static)
# static target from hdf5 1.10 or 1.12 config
target_link_libraries(HDF5::HDF5 INTERFACE hdf5::hdf5-static)
target_link_libraries(MATIO::HDF5 INTERFACE hdf5::hdf5-static)
elseif(NOT HDF5_USE_STATIC_LIBRARIES AND TARGET hdf5::hdf5-shared)
# shared target from hdf5 1.10 or 1.12 config
target_link_libraries(HDF5::HDF5 INTERFACE hdf5::hdf5-shared)
target_link_libraries(MATIO::HDF5 INTERFACE hdf5::hdf5-shared)
elseif(TARGET hdf5)
# target from hdf5 1.8 config
target_link_libraries(HDF5::HDF5 INTERFACE hdf5)
target_link_libraries(MATIO::HDF5 INTERFACE hdf5)
elseif(TARGET HDF5::HDF5)
# target defined in CMake FindHDF5 (since 3.19)
target_link_libraries(MATIO::HDF5 INTERFACE HDF5::HDF5)
else()
# results from CMake FindHDF5
set_target_properties(HDF5::HDF5 PROPERTIES
set_target_properties(MATIO::HDF5 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}"
)
endif()
if(NOT HDF5_USE_STATIC_LIBRARIES)
set_target_properties(HDF5::HDF5 PROPERTIES
set_target_properties(MATIO::HDF5 PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB"
)
endif()
Expand All @@ -64,8 +67,8 @@ endif()


macro(matio_create_zlib target)
add_library(ZLIB::ZLIB INTERFACE IMPORTED)
target_link_libraries(ZLIB::ZLIB INTERFACE ${target})
add_library(MATIO::ZLIB INTERFACE IMPORTED)
target_link_libraries(MATIO::ZLIB INTERFACE ${target})
set(ZLIB_FOUND TRUE)
endmacro()

Expand All @@ -86,8 +89,13 @@ if(MATIO_WITH_ZLIB)
matio_create_zlib(hdf5::zlib-shared)
elseif(TARGET zlib)
matio_create_zlib(zlib)
elseif(TARGET ZLIB::ZLIB)
matio_create_zlib(ZLIB::ZLIB)
else()
find_package(ZLIB 1.2.3)
if(ZLIB_FOUND)
matio_create_zlib(ZLIB::ZLIB)
endif()
endif()

if(ZLIB_FOUND)
Expand Down

0 comments on commit 228b046

Please sign in to comment.