zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.93k stars 757 forks source link

`CPPZMQ_BUILD_TESTS=OFF` incompatible with `ctest` when using as subproject #567

Open jlucier opened 2 years ago

jlucier commented 2 years ago

I am using cppzmq as dependency in my project via FetchContent, and I tried setting the CPPZMQ_BUILD_TESTS option to OFF in the following ways:

set(CPPZMQ_BUILD_TESTS OFF)  # before and after FetchContent_MakeAvailable(cppzmq)
set_target_properties(cppzmq PROPERTIES CPPZMQ_BUILD_TESTS OFF)

All seems well, and the build succeeds. However when I try to run my project's tests using ctest, a seemingly bogus test suite is discovered by ctest and fails to run because it cannot be found.

The following tests FAILED:
        1 - unit_tests_NOT_BUILT-b12d07c (Not Run)

It seems that despite my configuration, some cmake files related to the cppzmq tests are being created even though the suite itself isn't being built.

My current workaround (which I'm sure is sub-optimal) is to specify the following in my CMakeLists.txt:

option(CPPZMQ_BUILD_TESTS OFF)
FetchContent_MakeAvailable(cppzmq)

Am I missing something in the cmake configuration that would avoid this problem? Or is it possible a small change to this project's CMakeLists.txt would remedy the issue?

gummif commented 1 year ago

I really don't know. Your workaround seems like a fine solution.