-
Notifications
You must be signed in to change notification settings - Fork 78
CMake: guard unit-tests to allow use with fetchContent and addSubdirectory #79
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: master
Are you sure you want to change the base?
Conversation
Adds an option to control whether unittests should be registered with cmakes ctest runner. It is initialized based on whether pffft is the current top level cmake build directory. This helps with including pffft via FetchContent with EXCLUDE_FROM_ALL. Because cmake will only build the targets that are actually required by the consuming project, if all tests are unconditionally registered with ctest, the testsuite of the consuming project will fail. This assumes that most library consumers are not interested in running the testsuites of all their dependencies in their own build. Also move the definition of the compile definition into the PFFFT target, so it only has to be defined once and downstream consumers can just include the target.
marton78
left a comment
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.
Hi, thanks a lot for your PR! I'm happy to merge this, but before: please fix the typos I pointed out and test locally to ensure that tests etc. are running in the stand-alone case.
|
Thanks, for having a first look, as written above, it's clear that this is not yet in a finished state, this was more to first see if this is something that is generally welcomed. I fixed the typos and noticed that they were effectively masking a lot of the build and I noticed that a lot of the testing code also relies on the No need to approve the CI, I have to do some restructuring and testing first. |
Hey and thanks for maintaining this nice little library! I am having some issues with including pffft via cmake's fetchContent.
This PR adds options to control whether tests/benchmarks/examples should be built and whether unittests should be registered with cmakes ctest runner. The options initialized based on whether pffft is the current top level cmake build directory.
This helps with including pffft via FetchContent with EXCLUDE_FROM_ALL. Because cmake will only build the targets that are actually required by the consuming project, if all tests are unconditionally registered with ctest, the testsuite of the consuming project will fail. This assumes that most library consumers are not interested in running the testsuites of all their dependencies in their own build.
It also moves the compile definitions for float/double into the PFFFT target, so it only has to be defined once and downstream consumers can just include the target.
This allows to use pffft with the following cmake snippet:
I had hoped to be able to enable this with less changes to pffft's cmake and am open to improving on this, but wanted to first get some general feedback on whether you would accept such a change and if there are other usecases that such changes could break that I should be aware of. Also there's always the tradeoff between the minimal amount of changes and making the result most complete/consistent.
The minimal change would be to just add the option to skip the
add_testcalls.