Skip to content
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

Unknown CMake command "catch_discover_tests". #334

Open
About9 opened this issue Jun 26, 2019 · 6 comments
Open

Unknown CMake command "catch_discover_tests". #334

About9 opened this issue Jun 26, 2019 · 6 comments

Comments

@About9
Copy link

About9 commented Jun 26, 2019

-- 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?

#294

@anantmurti
Copy link

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

@t-b
Copy link

t-b commented Oct 29, 2019

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?

@dionisioedu
Copy link

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

cmake -DCPPZMQ_BUILD_TESTS=OFF ..

Worked fine for me.

@SylvainCorlay
Copy link
Contributor

Same issue here.

@TBK
Copy link

TBK commented Jan 13, 2021

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

@sigiesec
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants