-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework dependencies to be dynamic, i.e. can be overridden when using from install (+ fix when they's targets) #255
Conversation
5234231
to
80af9d5
Compare
By searching hdf5 in package-config minimal changes have to be employed and we enable using alternate hdf5s Adding parallel option to highfive when imported Improvements. Added developer doc Exports
a141c32
to
51418c7
Compare
Could you tell me in which version HDF5 started to ship a package-config so that I can test the different scenario? |
@ferdonline Incidentally, I started playing with a solution for #253 yesterday. What I have so far (#257 ) is I think a nice draft to deal with #253, but also the issues being dealt with here. |
I installed hdf5-parallel from brew. It's still 1.10.5 |
bc12284
to
82de660
Compare
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
82de660
to
a4dff36
Compare
ATM Travis internet is having issues. To be retested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMake/HighFiveTargetDeps.cmake
Outdated
if(USE_BOOST) | ||
find_package(Boost REQUIRED COMPONENTS system serialization) | ||
target_link_libraries(highfive_deps INTERFACE Boost::boost Boost::serialization) | ||
target_include_directories(highfive_deps INTERFACE ${Boost_INCLUDE_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not incorrect Boost::boost
takes care of the include. I don't think there is need for the target_include_directories
(but it would be good to check)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted to not using boost targets for support for cmake < 3.5.
Next main release we bump cmake requirements and start using targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that is fine.
One could now have both implementations based on CMake version. Those of use using a new CMake version and that want to pick dependencies carefully now are left with no choice to use old-school behaviour.
CMake/HighFiveTargetDeps.cmake
Outdated
target_compile_definitions(highfive_deps INTERFACE ${HDF5_DEFINITIONS}) | ||
|
||
# Boost | ||
if(USE_BOOST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good the use HIGHFIVE_USE_BOOST
to avoid any name conflicts with other libraries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It's a breaking change though. Let's do that in the next main release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could ease the transition by externally allowing both and internally using HIGHFIVE_USE_BOOST
. One could even add a deprecation warning.
It is great that you are moving to a way to specify options at compile time (not only at install time). I was thinking though, wouldn't it be great to also allow the user access to the individual components? To select options one could then do either of two things: The current PR's approachset(USE_BOOST FALSE)
find_package(HighFive)
target_link_libraries(mylib HighFive) Even more customisation if desiredEDIT: I have changed the names in the hope to be more convincing. I really think that having this possibility would really be very nice. I think it is nice that boost, eigen, and xtensor remain fully optional in the library itself. I think the same spirit should hold for the CMake build system. find_package(HighFive)
target_link_libraries(mylib
HighFive::HighFive
HighFive::hdf5
HighFive::use_boost
HighFive::use_eigen
HighFive::use_xtensor) or maybe even find_package(HighFive COMPONENTS HighFive hdf5 boost eigen xtensor)
target_link_libraries(mylib
HighFive::HighFive
HighFive::hdf5
HighFive::use_boost
HighFive::use_eigen
HighFive::use_xtensor) |
In the current PR the target is that we do find_package(HighFive)
target_link_libraries(mylib HighFive) The user will probably want the options with what HighFive was installed, so I hope Now he still is free to do find_package(Boost COMPONENT XYZ)
find_package(HighFive)
target_link_libraries(mylib HighFive) And the mylib will use the user found Boost, without the need of adding target_link_libraries(mylib HighFive boost::xyz) |
|
@ferdonline Currently the C++ version is not set...
|
WINDOWS: Dont auto-link
@ferdonline Happy to test again when you're ready. Just ping me. |
target_include_directories(highfive_deps SYSTEM INTERFACE ${Boost_INCLUDE_DIR}) | ||
target_compile_definitions(highfive_deps INTERFACE BOOST_ALL_NO_LIB H5_USE_BOOST) | ||
endif() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that (in the future) one could consider to act on HIGHFIVE_USE_EIGEN
and HIGHFIVE_USE_XTENSOR
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, at least a separate PR...
@tdegeus please go ahead. I hope we dont have to change it much further |
@ferdonline To what should I set set_target_properties(highfive_deps PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "_FORTIFY_SOURCE=2;BOOST_ALL_NO_LIB;H5_USE_BOOST"
INTERFACE_COMPILE_OPTIONS ""
INTERFACE_INCLUDE_DIRECTORIES "/Users/tdegeus/miniconda3/envs/test/include;/Users/tdegeus/miniconda3/envs/test/include;${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "/Users/tdegeus/miniconda3/envs/test/lib/libhdf5.dylib;/usr/lib/libpthread.dylib;/Users/tdegeus/miniconda3/envs/test/lib/libz.dylib;/usr/lib/libdl.dylib;/usr/lib/libm.dylib"
INTERFACE_LINK_OPTIONS ""
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "/Users/tdegeus/miniconda3/envs/test/include;/Users/tdegeus/miniconda3/envs/test/include"
) In addition there is again the |
@ferdonline I found the solution to your problem. In the end it boils down to that you should take care not to export your What is a good way to propagate the changes? Can I open a PR to your branch? How? In the worst can I can paste my changes here. |
@tdegeus This was a time-consuming ticket where I explored those ideas. It doesnt work since cmake requires to export highfive_deps as well, otherwise it complains HighFive INTERFACE is not valid. Further, with central deployments we indeed want to use the original flags, so it came in handy to have highfive_deps populated and exported. |
@ferdonline I think your approach is the right one. I agree with using a |
I used INTERFACE IMPORTED libraries and indeed that didnt require us to export the it, but then at import time there were problems. I would need to test it. |
@ferdonline I see what you want (though maybe you can explain me the relevant use-case for this). What I would do is to conditionally export the dependency target (and now I also see why you chose the name |
|
@tdegeus Please open a PR to this branch, otherwise it's really difficult to see whatsoever diff. Also code here it clutters a lot the thread, we cant leave it here. |
|
See fix in #259 |
@tdegeus After checking with other maintainers we are not going via the two cmake exports as it was a more complex scenario and seemed less flexible. Improvements can be done later if needed. |
@ferdonline So the conda-forge package remains broken?? |
We will be merging this PR. It was working for conda, right? |
It was a while that we discussed this. In my memory: I don't think so in fact. The whole point is that the target generated here always contains absolute paths found at install time (i.e. on conda's CI). These paths typically do not exists for the end-user, resulting in linker errors. Solving this was the only point of my PR. I will double check tonight and point you to the details. |
Yep, this PR changed a lot, but in the end it aimed to solved exactly that problem. And you see in the import cmake file that we erase the target properties and recreate them dynamically if that's the user choice. It hopefully solves the conda problem! I let you test then before we merge. |
@ferdonline You seem to be right, I guess I understood incorrectly! Go ahead and match it, we can always re-discuss if things don't end up working. |
@ferdonline Can you also release a patch such that we can release a conda-forge package update? |
@ferdonline I can confirm the Conda is working as desired (conda-forge/highfive-feedstock#9)! Thanks a lot for the fix. |
In order to be used by other projects, HighFive exports targets.
However two problems arose recently:
HighFive will fail to build saying "
library doesnt exist hdf5::hdf5-shared
"This PR
Tests several attempts on how to deal with such situations.
UseHDF5_C_[SHARED]_LIBRARIES
instead - Doesn't work: suffers from the same problemIf the MPI_C_LIBRARIES is a target, simply finds the target location and uses the hard string for the interface libraries. This works but ends up locking the user to the detected hdf5 library. If the user later chooses to use a third party hdf5 directly in his application we end up linking to two different hdf5.Extra
By searching the dependencies in the PackageConfig.cmake, we effectively enable the use case that the end project is free to choose other versions of the libs, which is desirable since this is a header-only project.
Fixes #253