zlib icon indicating copy to clipboard operation
zlib copied to clipboard

fix: Make test executables optional

Open joeyparrish opened this issue 3 years ago • 1 comments

When including zlib as a submodule, it is useful to be able to disable the tests.

joeyparrish avatar Aug 16 '22 23:08 joeyparrish

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.

EmosewaMC avatar Sep 04 '22 04:09 EmosewaMC

@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.

joeyparrish avatar Nov 03 '22 18:11 joeyparrish

Can you just do add_subdirectory(zlib EXCLUDE_FROM_ALL)?

nmoinvaz avatar Nov 03 '22 18:11 nmoinvaz

We are doing that: https://github.com/shaka-project/shaka-packager/blob/0ee4af438d4ff943cf747f083cd149223d2bd4c5/packager/third_party/CMakeLists.txt#L39

joeyparrish avatar Nov 03 '22 21:11 joeyparrish

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.

nmoinvaz avatar Nov 03 '22 21:11 nmoinvaz

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)

joeyparrish avatar Nov 03 '22 21:11 joeyparrish

I updated the PR description with more detail on why this is necessary. Thanks, @nmoinvaz, for the link to the cmake issue tracker!

joeyparrish avatar Nov 03 '22 22:11 joeyparrish

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!

joeyparrish avatar Nov 09 '22 15:11 joeyparrish