-
Notifications
You must be signed in to change notification settings - Fork 160
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
Use Catch2 as normal dependency (not as submodule) #527
Conversation
Should be good to go! |
CMakeLists.txt
Outdated
find_package(Catch2) | ||
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/deps/catch2/CMakeLists.txt) | ||
add_subdirectory(deps/catch2 EXCLUDE_FROM_ALL) | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps/catch2/contrib) |
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.
One issue I have here is that I'm concerned about CMake mixing things up.
For example, we find Catch2, setting a bunch of stuff. Then, if the submodule is present, we include it and append to the search path. Which means that include(Catch)
would probably first look at the system Catch2, no?
It would seem cleaner to me to look for Catch2 only if the subdirectory is empty, printing a status message about the missing submodule and then using REQUIRE
, maybe?
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.
FWIW, find_library
seems to be in the CMake 3.1 we require, what was wrong with it?
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 find add_subdirectory(deps/catch2 EXCLUDE_FROM_ALL)
very un-Cmake, and that is probably where the issues start. Personally I would find it much simpler (and much more in the spirit of Cmake ;)) to remove the submodule all-together. We did not submodule Boost either and that did not pose any difficulties. Nowadays I do not consider Catch2 much less standard than 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.
catch2 is packaged under debian / ubuntu / archlinux / fedora at least
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.
and on conda-forge, and I imagine other package managers
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 don't have strong opinions but to mention few aspects:
We did not submodule Boost either and that did not pose any difficulties.
I would say Boost is different beast altogether. As we depend on library components, (as we all know) one can't just submodule boost...
catch2 is packaged under debian / ubuntu / archlinux / fedora at least
and on conda-forge, and I imagine other package managers
Using system package managers is perfectly fine when we are doing development on our own system / desktop environments. When we move to clusters (where many of us work), the same doesn't apply. Boost
availability via module
has been quite universal for long time. I wouldn't say the same thing for Catch2
.
Personally I would find it much simpler (and much more in the spirit of Cmake ;)) to remove the submodule all-together.
People involved in this discussion knows how to make catch2 available if needed. But IMO, we don't loose much by adding submodule for lightweight package is like Catch2. As @matz-e mentioned, it's just convenient, commonly used approach and one doesn't need to bother about the details.
So I think it's ok to use external packages but shouldn't get rid of submodule altogether.
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.
There is not something profoundly bad about carrying a submodule. However, my considerations are:
-
Have a submodule makes as responsible for keeping it up-to-date. Not carrying the submodule reduces work-load in that sense.
-
I wonder how many people will actually run the unit-tests for highfive. We are responsible for that, and indeed we run quite a bit of CI. So I wonder how many people benefit.
My proposition is on of :
- Having the submodule, but not require its clone by default (so having a fallback that takes the system's)
- Having an option to specify the path to the user's download of Catch2 (instead of using the system's).
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.
There is already an official way to tell where is Catch2 with cmake, don't add such option
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.
Having the submodule, but not require its clone by default (so having a fallback that takes the system's)
This can be done.
Having an option to specify the path to the user's download of Catch2 (instead of using the system's).
Don't understand this. You can always install Catch2 independently and use -DCMAKE_PREFIX_PATH=…
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.
catch2 is packaged under debian / ubuntu / archlinux / fedora at least
Looking into it a bit more. This is not the case for Ubuntu LTS 20.04. Catch2 occurs first in 21.04. Not to speak of RedHat…
@@ -24,7 +24,6 @@ set(USE_OPENCV OFF CACHE BOOL "Enable OpenCV testing") | |||
mark_as_advanced(USE_BOOST USE_EIGEN USE_XTENSOR) | |||
|
|||
option(HIGHFIVE_USE_BOOST "Enable Boost Support" ${USE_BOOST}) | |||
option(HIGHFIVE_USE_EXTERNAL_CATCH2 "Enable external Catch2 for unit tests" OFF) |
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 think with the submodule gone, and a (compared to Boost and HDF5) less common dependency present, unit tests should be in a tristate:
AUTO
(default) to enable unit tests ifCatch2
is foundON
to requireCatch2
and enable unit testsOFF
to disable unit tests and theCatch2
dependency
(this would be a good way to get switch to disable the Boost dependency, too, IMO)
(see also https://cmake.org/pipermail/cmake/2016-October/064342.html)
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'm fine with this.
Just of clarify:
AUTO
: enable tests only of Catch2 is foundON
: force run tests -> fail if Catch2 is not foundOFF
: do not run tests
this seems fine to me. If the user choses to install HighFive this is of limited added value though, but certainly not bad.
It would be indeed ok to make this the default of the target too. Still it feels like dragging it along. I would still argue to issue a warning that it won't still the default for a while, and then remove Boost from the target, making it strictly optional, or much better fully modular.
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.
Codecov Report
@@ Coverage Diff @@
## master #527 +/- ##
=========================================
Coverage ? 78.72%
=========================================
Files ? 64
Lines ? 3361
Branches ? 0
=========================================
Hits ? 2646
Misses ? 715
Partials ? 0 Continue to review full report at Codecov.
|
Mamba does not install the right HDF5. Pretty much don't like this - from the looks of the CI file, we rely on Ubuntu system packages, why do we mix and match package managements?
|
@tdegeus, I think this should fix #527 sufficiently. Any CI setup therein should maybe be followed up separately. A bit of a butchered CMake in my opinion, but given the "language" constraints, it seems to work. Will set unit tests to AUTO, disabling them if neither the submodule nor a system package for Catch2 is found. The submodule will be preferred, otherwise. Errors out if unit tests are set to ON and no Catch2 is found.
@tdegeus, I think this should fix #527 sufficiently. Any CI setup therein should maybe be followed up separately. A bit of a butchered CMake in my opinion, but given the "language" constraints, it seems to work. Will set unit tests to AUTO, disabling them if neither the submodule nor a system package for Catch2 is found. The submodule will be preferred, otherwise. Errors out if unit tests are set to ON and no Catch2 is found.
This PR is subsided by #535 |
@matz-e @alkino