Skip to content

Commit

Permalink
Fix Kealib interface target (#45)
Browse files Browse the repository at this point in the history
* Fix Kealib interface target

It is just a stable interface name for the variable actual library target name. CMake takes care of forwarding transitive usage requirements from Kealib's interface link libraries.

* HDF5 is a private link lib

* Drop last direct property of Kealib

* Exported config needs find_dependency(HDF5)
  • Loading branch information
dg0yt authored Dec 5, 2023
1 parent c6b3e4f commit c0beb79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ source_group("include_kea" FILES ${LIBKEA_H})
###############################################################################
# Build, link and install library
add_library(${LIBKEA_LIB_NAME} ${LIBKEA_CPP} ${LIBKEA_H} )
target_link_libraries(${LIBKEA_LIB_NAME} ${HDF5_LIBRARIES})
target_link_libraries(${LIBKEA_LIB_NAME} PRIVATE ${HDF5_LIBRARIES})

include(GenerateExportHeader)
generate_export_header(${LIBKEA_LIB_NAME}
Expand All @@ -54,21 +54,7 @@ set_target_properties(${LIBKEA_LIB_NAME}
)

add_library(Kealib INTERFACE)
target_include_directories(Kealib INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# TODO: a better way??
if(MSVC)
target_link_libraries(Kealib INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libkea${CMAKE_IMPORT_LIBRARY_SUFFIX}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/libkea${CMAKE_IMPORT_LIBRARY_SUFFIX}>)
else()
target_link_libraries(Kealib INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libkea${CMAKE_SHARED_LIBRARY_SUFFIX}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/lib/libkea${CMAKE_SHARED_LIBRARY_SUFFIX}>)
endif(MSVC)
target_link_libraries(Kealib INTERFACE ${LIBKEA_LIB_NAME})
###############################################################################

###############################################################################
Expand Down
9 changes: 9 additions & 0 deletions src/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
@PACKAGE_INIT@

if(NOT "@BUILD_SHARED_LIBS@")
# FindHDF5.cmake may expose exported targets in HDF5_LIBRARIES.
include(CMakeFindDependencyMacro)
if(NOT DEFINED HDF5_USE_STATIC_LIBRARIES)
set(HDF5_USE_STATIC_LIBRARIES "@HDF5_USE_STATIC_LIBRARIES@")
endif()
find_dependency(HDF5)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/libkeaTargets.cmake")

check_required_components(libkea)

0 comments on commit c0beb79

Please sign in to comment.