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

Tests fail to compile: fatal error: 'catch2/catch.hpp' file not found #635

Open
yurivict opened this issue Apr 16, 2024 · 1 comment
Open

Comments

@yurivict
Copy link

In file included from /usr/ports/net/cppzmq/work/cppzmq-4.10.0/tests/active_poller.cpp:3:
/usr/ports/net/cppzmq/work/cppzmq-4.10.0/tests/testutil.hpp:3:10: fatal error: 'catch2/catch.hpp' file not found
    3 | #include <catch2/catch.hpp>
      |          ^~~~~~~~~~~~~~~~~~
1 error generated.

Version: 4.10.0
catch2-3.5.4
FreeBSD 14.0

@bakerb845
Copy link

Hey @yurivict - I had the same issue but with catch2-3.6.0. I think what's going on in the newer catch's is they're doing away with the convenience header (catch.hpp). Basically, changing

#include <catch2/catch.hpp>

to

#include <catch2/catch_test_macros.hpp>

in tests/message.cpp, tests/socket.cpp, tests/send_multipart.cpp, tests/multipart.cpp, tests/socket_ref.cpp, tests/testutil.cpp, tests/recv_multipart.cpp, tests/buffer.cpp, tests/code_multipart.cpp, tests/utilities.cpp, and tests/context.cpp will get you through the compilation phase.

However, I also ran into an issue with tests/CMakeFiles.txt after this was done. I think you can leave

find_package(Catch2 QUIET)

as is. Though, with the blessing of @gummif, maybe it is time to set it to:

find_package(Catch2 3 QUIET)

Then a little later add some logic that looks like this (I'm guessing on the exact version where you should be explicitly linking to Catch2WithMain):

if (${Catch2_VERSION} VERSION_GREATER_EQUAL "3.5.0")
   target_link_libraries(
       unit_tests
      PRIVATE Catch2::Catch2 Catch2::Catch2WithMain
      PRIVATE cppzmq
      PRIVATE ${CMAKE_THREAD_LIBS_INIT}
   )
else()
   target_link_libraries(
       unit_tests
       PRIVATE Catch2::Catch2
       PRIVATE cppzmq
       PRIVATE ${CMAKE_THREAD_LIBS_INIT}
   )

endif()

Unfortunately I'm super short on time these days so I can't really test this on a machine with an older version of catch2.

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

No branches or pull requests

2 participants