Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Using FetchContent: Issues with debug postfix

Open robamu opened this issue 3 years ago • 0 comments

Describe the bug When using FetchContent to install Catch2 like this:

        message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent")
        include(FetchContent)

        FetchContent_Declare(
            Catch2
            GIT_REPOSITORY https://github.com/catchorg/Catch2.git
            GIT_TAG        v3.0.0-preview5
        )

        FetchContent_MakeAvailable(Catch2)

there is an issue when building our unit tests:

gmake[3]: *** No rule to make target '_deps/catch2-build/src/libCatch2d.a', needed by 'fsfw-tests'.  Stop.
gmake[3]: *** Waiting for unfinished jobs....

Also happens on v3.0.0-preview4. Our unittest is built with DEBUG flags to allow stepping. These flags are of course passed to Catch2, and there appears to be an issue with the according target name.

A solution for this was to add the following lines in our CMakeLists.txt

        # set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "")

Reproduction steps Use FetchContent to fetch Catch2 and build your unit test binary in DEBUG mode

Platform information:

  • OS: Ubuntu 21.10
  • Compiler+version: GCC v11.2.0
  • Catch version: v3.0.0-preview4 and v3.0.0-preview5

I just wonder if this is

  1. A documentation thing by documenting the DEBUG_POSTFIX quickfix when building debug
  2. Can be fixed by changing something in the CMakeLists.txt of Catch2
  3. Can be fixed by changing the way FetchContent is used

robamu avatar Apr 27 '22 08:04 robamu