zlib
zlib copied to clipboard
fix: Make test executables optional
When including zlib as a submodule, it is useful to be able to disable the tests.
It'd be great to be able to disable the tests when using this project as a submodule. I'm spending more time than I would like attempting to get these tests found by ctest so I can get back to working on other stuff. Just being able to disable them since they do not pertain to our project would be great.
@madler, would you please look at this when you have time? We are currently forced to use a fork of zlib because of CMake issues like this.
Can you just do add_subdirectory(zlib EXCLUDE_FROM_ALL)?
We are doing that: https://github.com/shaka-project/shaka-packager/blob/0ee4af438d4ff943cf747f083cd149223d2bd4c5/packager/third_party/CMakeLists.txt#L39
Actually, I just ran across this in another repository. Here is the associated Kitware issue: https://gitlab.kitware.com/cmake/cmake/-/issues/20212.
Alternatively, you could use zlib-ng which has options to disable testing, but it doesn't fix the problem for this repo.
Yes, thank you for bringing this up. My PR description was poor, and should have had those details.
Here is what happens with EXCLUDE_FROM_ALL, but without this PR:
Start 5: example
Could not find executable example
Looked in the following places:
example
example
Release/example
Release/example
Debug/example
Debug/example
MinSizeRel/example
MinSizeRel/example
RelWithDebInfo/example
RelWithDebInfo/example
Deployment/example
Deployment/example
Development/example
Development/example
Unable to find executable: example
5/6 Test #5: example ..........................***Not Run 0.00 sec
Start 6: example64
Could not find executable example64
Looked in the following places:
example64
example64
Release/example64
Release/example64
Debug/example64
Debug/example64
MinSizeRel/example64
MinSizeRel/example64
RelWithDebInfo/example64
RelWithDebInfo/example64
Deployment/example64
Deployment/example64
Development/example64
Development/example64
Unable to find executable: example64
6/6 Test #6: example64 ........................***Not Run 0.00 sec
67% tests passed, 2 tests failed out of 6
Total Test time (real) = 23.97 sec
The following tests FAILED:
5 - example (Not Run)
6 - example64 (Not Run)
I updated the PR description with more detail on why this is necessary. Thanks, @nmoinvaz, for the link to the cmake issue tracker!
The change is now backward compatible for the sake of those who depend on the example and minigzip binaries. Only the add_test() calls have been made conditional on BUILD_TESTING. This has also been rebased and retargeted to the develop branch.
Thanks!