-
Notifications
You must be signed in to change notification settings - Fork 262
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
adding an integration test to show fetch_content can work #2894
base: main
Are you sure you want to change the base?
Conversation
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.
Note: the project is technically fetch-contentable, but it does not play well with other projects due to option name clash, missing defaults based on IS_PROJECT_TOP_LEVEL
.
👍 to have this in the CI, but I encourage to put it as a ctest instead
- name: Build | ||
run: | | ||
cd integration_tests/fetch_content | ||
cmake --build build --parallel |
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.
Preferably these tests are run as part of ctest using ctest --build-and-test
with a FETCHCONTENT_SOURCE_DIR_<uppercaseName>
option. That way you are checking the current version of the project is working with fetchcontent.
For an example: https://github.com/LecrisUT/CMake-Template/blob/a4f73dbd53d8cb98e6325296c2905b2ed40dcaa3/test/CMakeLists.txt#L114-L131
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.
Oh neat! I'll give that a try tomorrow!
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.
@LecrisUT I actually don't really understand what that test is doing and how it works. The stuff I added builds a small example project. From what I understand of what you sent, it seems like it would only build the netcdf project but not actually link to and use it. I feel like the integration test is a complete test. What am I missing 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.
The first link there is the general framework for an arbitrary (regression) test that runs a cmake project as if it's used by a user from tge ground up. In the template it's ueed for packaging, example and regular regression test.
For an example of a packaging test, see this CMakeLists.txt. There is a bit of fluff to allow testing in the build tree and outside, but if you look closely it's very minimal, FetchContent + link libraries + simple smoke test. See the parent folder for how the CMakeLists
project is registered as a test.
In the framework link I've sent before, notice the --test-command ${CMAKE_CTEST_COMMAND}
. That instructs that the test does ctest (after configure -> build) of the cmake project being pointed to. That way you xan be as thorough as you want, e.g. checking that project version matches library, checking features are enabled in the library, etc. This gives more navigable tests since it's just a ctest output run from a ctest test.
Compared to your approach, it's more or less identical, but this adds the ability to be called within the ctest itself, which will make it much easier to keep track of active cmake changes that break the test (it uses the current source as the "git commit" to FetchContent). Your current approach only tests main
at any given point.
Basically what I suggest here is to move the execution outside of the dedicated Github Workflow and inside the project's test itself.
Sorry for being too wordy in my explanations most of the times, hope it doesn't put you 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.
No worries! I like detailed explanations and yours makes sense to me. Thanks for the input!
### | ||
|
||
- run: echo "CMAKE_PREFIX_PATH=${HOME}/environments/${{ matrix.hdf5 }}/" >> $GITHUB_ENV | ||
- run: echo "LD_LIBRARY_PATH=${HOME}/environments/${{ matrix.hdf5 }}/lib" >> $GITHUB_ENV |
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.
Not a fan of these approaches, but I understand the need for them right now. If hdf5 is fetch-contentable, this could be simplified greatly.
Anyway, LD_LIBRARY_PATH
should be unnecessary if running from build directory and the dependencies are installed with RPATH. Also, for mac it's DYLD_LIBRARY_PATH
#2895, as you've seen, adds |
Yep just saw that. Do you prefer to have this finished first, since it has minimal changes and then fix the default options based on |
Yes, that's the goal. But I've got to figure out these pesky windows actions. Cygwin fails because HDF5 is installed with autotools on Cygwin so there aren't any pkg-config or cmake config files to use to find hdf5. I'd have to write some logic by hand to do all that and frankly I'm lazy. Mingw is failing because netcdf is having trouble linking with the curl libs for some reason |
I did not check the CI in detail, but the CI should mimic the user's experience, i.e. how would a user install Most preferably though, since it's a required dependency importing it as An intermediate solution, I would suggest for now is to convert the CI to run the default cmake configure/build/install on hdf5. If we have issues converting that, the user would have even more issues as well. Sorry I just read the CI for |
It is also not necessarily the case that we need this to work for cygwin out-of-the-box. If we have it working for *nix and Visual-Studio based builds, that may be a good enough start point. Cygwin fetch_content() is not important enough to hold up the release altogether. |
Adds an integration test to show that netcdf can use cmake's fetch_content
Not included in mingw and cygwin builds; could not figure out how to get all of the packages to be found properly and it was purely a thing related to mingw and cygwin, not netcdf