forked from BlueBrain/HighFive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework dependencies to be dynamic, i.e. can be overridden when using …
…from install (BlueBrain#255) We now create an INTERFACE target to hold dependencies info This target is created on every configure, from HighFive itself or any using project, trigerred from HighFiveConfig.cmake * WINDOWS: Dont auto-link * Activate c++11 if not specified * Added depend deploy mode. Prefix USE_x w HIGHFIVE_ * HIGHFIVE_USE_INSTALL_DEPS as an option with default
- Loading branch information
1 parent
d7c8ed0
commit 2f07be8
Showing
11 changed files
with
210 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
|
||
# Get HighFive targets | ||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/HighFiveTargets.cmake") | ||
include("${CMAKE_CURRENT_LIST_DIR}/HighFiveTargets.cmake") | ||
endif() | ||
|
||
# If the user sets this flag, all dependencies are preserved. | ||
# Useful in central deployments where dependencies are not prepared later | ||
option(HIGHFIVE_USE_INSTALL_DEPS "Use original Highfive dependencies" @HIGHFIVE_USE_INSTALL_DEPS@) | ||
if(HIGHFIVE_USE_INSTALL_DEPS) | ||
return() | ||
endif() | ||
|
||
# Options when used from external projects. Keep defaults | ||
if(NOT DEFINED HIGHFIVE_PARALLEL_HDF5) | ||
option(HIGHFIVE_PARALLEL_HDF5 "Enable Parallel HDF5 support" @HIGHFIVE_PARALLEL_HDF5@) | ||
endif() | ||
if(NOT DEFINED HIGHFIVE_USE_BOOST) | ||
option(HIGHFIVE_USE_BOOST "Enable Boost Support" @HIGHFIVE_USE_BOOST@) | ||
endif() | ||
|
||
# Pass on dependencies in target project build | ||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/HighFiveTargetDeps.cmake") | ||
include("${CMAKE_CURRENT_LIST_DIR}/HighFiveTargetDeps.cmake") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Link against target system libs | ||
# ------------------------------- | ||
|
||
# therefore making it possible to have new dependencies each build | ||
if(NOT TARGET highfive_deps) | ||
add_library(highfive_deps INTERFACE) | ||
else() | ||
# Reset if imported | ||
set_target_properties(highfive_deps PROPERTIES | ||
INTERFACE_COMPILE_DEFINITIONS "" | ||
INTERFACE_COMPILE_OPTIONS "" | ||
INTERFACE_INCLUDE_DIRECTORIES "" | ||
INTERFACE_LINK_LIBRARIES "" | ||
INTERFACE_LINK_OPTIONS "" | ||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "" | ||
) | ||
endif() | ||
|
||
|
||
# HDF5 | ||
if(NOT DEFINED HDF5_C_LIBRARIES) | ||
set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE TRUE) # Consistency | ||
set(HDF5_PREFER_PARALLEL ${HIGHFIVE_PARALLEL_HDF5}) | ||
find_package(HDF5 REQUIRED) | ||
endif() | ||
|
||
if(HIGHFIVE_PARALLEL_HDF5 AND NOT HDF5_IS_PARALLEL) | ||
message(WARNING "Parallel HDF5 requested but libhdf5 doesnt support it") | ||
endif() | ||
|
||
target_include_directories(highfive_deps SYSTEM INTERFACE ${HDF5_INCLUDE_DIRS}) | ||
target_link_libraries(highfive_deps INTERFACE ${HDF5_C_LIBRARIES}) | ||
target_compile_definitions(highfive_deps INTERFACE ${HDF5_DEFINITIONS}) | ||
|
||
# Boost | ||
if(HIGHFIVE_USE_BOOST) | ||
set(Boost_NO_BOOST_CMAKE TRUE) # Consistency | ||
find_package(Boost REQUIRED COMPONENTS system serialization) | ||
# Dont use imported targets yet, not avail before cmake 3.5 | ||
target_include_directories(highfive_deps SYSTEM INTERFACE ${Boost_INCLUDE_DIR}) | ||
target_compile_definitions(highfive_deps INTERFACE BOOST_ALL_NO_LIB H5_USE_BOOST) | ||
endif() | ||
|
||
# MPI | ||
if(HIGHFIVE_PARALLEL_HDF5 OR HDF5_IS_PARALLEL) | ||
find_package(MPI REQUIRED) | ||
target_include_directories(highfive_deps SYSTEM INTERFACE ${MPI_CXX_INCLUDE_PATH}) | ||
target_link_libraries(highfive_deps INTERFACE ${MPI_CXX_LIBRARIES}) | ||
if(CMAKE_VERSION VERSION_LESS 3.13) | ||
target_link_libraries(highfive_deps INTERFACE ${MPI_CXX_LINK_FLAGS}) | ||
else() | ||
target_link_options(highfive_deps INTERFACE "SHELL:${MPI_CXX_LINK_FLAGS}") | ||
endif() | ||
endif() | ||
|
||
# Propagate to HighFive | ||
target_link_libraries(HighFive INTERFACE highfive_deps) | ||
target_compile_definitions(HighFive INTERFACE MPI_NO_CPPBIND) # No c++ bindings | ||
|
||
# Ensure we activate at least C++11 | ||
if(NOT DEFINED CMAKE_CXX_STANDARD) | ||
if(CMAKE_VERSION VERSION_LESS "3.1") | ||
message(WARNING "HighFive requires at least c++11. You may need to set CMAKE_CXX_STANDARD.") | ||
else() | ||
target_compile_features(HighFive INTERFACE cxx_std_11) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
add_library(HighFive INTERFACE) | ||
add_library(highfive_deps INTERFACE) | ||
|
||
# Public headers | ||
target_include_directories(HighFive INTERFACE | ||
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" | ||
"$<INSTALL_INTERFACE:include>") | ||
|
||
|
||
# Generate ${PROJECT_NAME}Config.cmake | ||
|
||
include(CMakePackageConfigHelpers) | ||
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/HighFiveConfig.cmake.in | ||
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
INSTALL_DESTINATION share/${PROJECT_NAME}/CMake) | ||
|
||
write_basic_package_version_file( | ||
${PROJECT_NAME}ConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY AnyNewerVersion) | ||
|
||
install(FILES | ||
CMake/HighFiveTargetDeps.cmake | ||
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
DESTINATION share/${PROJECT_NAME}/CMake) | ||
|
||
|
||
# Generate ${PROJECT_NAME}Targets.cmake; | ||
# Provides IMPORTED targets when using this project from build/install trees. | ||
|
||
# NOTE: the export file is ${PROJECT_NAME}Targets to support when HighFive | ||
# is built within a 3rd-party project (X). Other projects can find and import | ||
# X-Targets.cmake containing the HighFive target | ||
|
||
# Specify targets to include in the HighFive Export | ||
install(TARGETS HighFive highfive_deps | ||
EXPORT HighFiveTargets | ||
INCLUDES DESTINATION include) | ||
|
||
# Generate & install the Export for the INSTALL_INTERFACE | ||
install(EXPORT HighFiveTargets | ||
FILE ${PROJECT_NAME}Targets.cmake | ||
DESTINATION share/${PROJECT_NAME}/CMake) | ||
|
||
# Generate the Export for the BUILD_INTERACE (hardly used) | ||
export(EXPORT HighFiveTargets | ||
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.