cppzmq icon indicating copy to clipboard operation
cppzmq copied to clipboard

Unknown CMake command "catch_discover_tests".

Open About9 opened this issue 5 years ago • 6 comments

-- Detected CPPZMQ Version - 4.3.1 -- cppzmq v4.3.1 CMake Error at tests/CMakeLists.txt:47 (catch_discover_tests): Unknown CMake command "catch_discover_tests".

where I ran 'cmake ..', this error shows. The following issue says libzmq3-dev should make it. But what is libzmq3-dev? How can I install it?

https://github.com/zeromq/cppzmq/issues/294

About9 avatar Jun 26 '19 02:06 About9

I am facing the same issue since couple days and with no real solution until now. Were you able to solve it ?

anantmurti avatar Jul 18 '19 13:07 anantmurti

Maybe something like

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5c91ac4..cae89b3 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -45,4 +45,8 @@ if (COVERAGE)
     target_link_libraries(unit_tests PRIVATE --coverage)
 endif()

-catch_discover_tests(unit_tests)
+find_package(Catch QUIET)
+
+if(Catch_FOUND)
+  catch_discover_tests(unit_tests)
+endif()

would help?

t-b avatar Oct 29 '19 14:10 t-b

The easy solution is to use -DCPPZMQ_BUILD_TESTS=OFF on cmake. Like that:

cmake -DCPPZMQ_BUILD_TESTS=OFF ..

Worked fine for me.

dionisioedu avatar Nov 12 '19 12:11 dionisioedu

Same issue here.

SylvainCorlay avatar Jan 01 '21 14:01 SylvainCorlay

I fixed it by applying these changes:

--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -9,11 +9,14 @@
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
 
+find_package(Threads)
+find_package(Catch2 REQUIRED)
+
 include(CTest)
+include(Catch)
 include(cmake/catch.cmake)
 include(${CATCH_MODULE_PATH}/Catch.cmake)
 
-find_package(Threads)
 
 add_executable(
     unit_tests
@@ -38,6 +41,7 @@
 target_link_libraries(
     unit_tests
     PRIVATE cppzmq
+    PRIVATE Catch2::Catch2
     PRIVATE ${CMAKE_THREAD_LIBS_INIT}
 )
 

based upon https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md#usage

TBK avatar Jan 13 '21 17:01 TBK

@TBK Can you provide a PR with these changes? If that works on both the Unix/Travis and Windows/Appveyor CI, we can integrate that into master.

sigiesec avatar Jan 15 '21 10:01 sigiesec