-
Notifications
You must be signed in to change notification settings - Fork 12
Make the CMake examples be independent projects #40
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
base: main
Are you sure you want to change the base?
Conversation
424f7f9 to
acb7aca
Compare
The tests are failing in various parts and needs debugging
| # cmake export files (both for install and build tree) | ||
| write_basic_package_version_file( | ||
| ${CMAKE_CURRENT_BINARY_DIR}/FortunoConfigVersion.cmake | ||
| VERSION ${PROJECT_VERSION} | ||
| # TODO: Switch to SameMajorVersion as soon as project version reaches 1.0. | ||
| COMPATIBILITY SameMinorVersion | ||
| ) | ||
| configure_package_config_file( | ||
| cmake/FortunoConfig.cmake.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/FortunoConfig.cmake | ||
| INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno | ||
| ) | ||
|
|
||
| # export the current targets to the build tree | ||
| export( | ||
| EXPORT FortunoTargets | ||
| FILE FortunoTargets.cmake | ||
| NAMESPACE Fortuno:: | ||
| ) | ||
|
|
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.
Stupid question, but please help me to learn 😉 : What is the point of having the basic package version file and package config file outside of the install guard?
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.
Yes, in general I'd prefer to have separate ones (sorry!), as I find it easier to discuss about specific single topics as about too many at the same time.
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.
Based on experiences with former projects, I think it would be worth to keep examples and tests separately for didactical purposes:
- examples are best practice code demos (which we could/should probably test as well, I agree), to be used by users when they start to use the library.
- tests can be anything needed to test certain functionality of the project. They must not be neither meaningful nor useful for users.
If we mix the two by putting everything under tests, first time users would be either confused and not finding the place to start or grabbing something, which was for internal testing only and not meant to be used by consumers of the library.
By the way, Fortran projects created with fpm --full also have both, a test and an example directory, so it might become a common pattern in the Fortran world.
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, now, I see how you did that with symlinks. OK, that could be reasonable solution. When one turns the examples into individual projects (which probably indeed makes a lot of more sense), then the export test would be superfluous, which was testing whether the compiled library can be used.
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.
Stupid question, but please help me to learn 😉 : What is the point of having the basic package version file and package config file outside of the install guard?
Yeah, this is one thing that I didn't understood until recently.
- The
configure_package_config_fileand such are just fancy versions ofconfigure_filewhich generates the file (FortunoConfig.cmake) and puts it in the build_dir. And in the definition it tries to look for aFortunoTargets.cmakefile right next to it install(EXPORT)does not generate theFortunoTargets.cmakein build_dir, only in the install prefixexport(EXPORT)generates theFortunoTargets.cmakein the build_dir (with the context of the build targets, instead of the installed ones, e.g.target_include_directorieswill evaluate the$<BUILD_INTERFACE>instead of the$<INSTALL_INTERFACE>)
As for why we would need the FortunoConfig.cmake file in the build_dir, it's for running the tests without needing to run the install step
Yes, in general I'd prefer to have separate ones (sorry!), as I find it easier to discuss about specific single topics as about too many at the same time.
NP, this part is relatively self-contained to making the examples as independent projects, I'll split off the description and make it an issue.
When one turns the examples into individual projects (which probably indeed makes a lot of more sense), then the export test would be superfluous, which was testing whether the compiled library can be used.
Yes, I was suspecting that that was the case. We still need them for now, because the running of the current example tests is disabled because they seem to fail by design. We can probably mark the relevant tests with WILL_FAIL or PASS_REGEX, but we need to split the tests to run individual tests and select which ones are meant to fail.
Make the CMake examples be independent projects showing how the user project should look like. These projects are also added to the testsuite.
However, the tests cannot be run right now because the example projects have expected failing tests, for which we need a way to run each test case individually and specify how those tests are expected to fail.
This is part of #41