You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current CMake Catch documentation provides an example on how to fetch and download Catch. I was wondering if it could be expanded to include a simple example of how to integrate a bundled single-header version of Catch into a CMake project. This appears to be the recommended way to use Catch often.
Having reviewed a stackoverflow answer about this, I am still struggling with what the best way to expose this all to CMake and lay out my test/ directory, and I think it could be a nice addition to the documentation.
The text was updated successfully, but these errors were encountered:
If you are saving the single-include header inside your repository, you can just use it the way you would use any other header file, or you can do it like in the linked answer...
Just make the CATCH_INCLUDE_DIR point to wherever you have the catch.hpp
cmake_minimum_required(VERSION 3.0)
project(cmake_test)
# Prepare "Catch" library for other executablesset(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/catch)
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE${CATCH_INCLUDE_DIR})
# Make test executableset(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
add_executable(tests ${TEST_SOURCES})
target_link_libraries(tests Catch)
I guess it just wasn't immediately clear to me as someone new to Catch (and albeit not a seasoned CMake user) how to do this. I had a working CMake build, but wanted to drop in Catch into a separate build for the unit tests.
But I was able to finally get it working using the stack overflow example. Just thought it might be something that could be laid out explicitly in Catch's docs for others who found it was not trivially straight forward. But I admit, my lack of thorough understanding of CMake was probably most to blame.
Feel free to close to the issue, appreciate the help.
@johnthagen I will see about improving the documentation a bit. Obviously we don't want to substitute for CMake documentation, but maybe it would be valuable.
The current CMake Catch documentation provides an example on how to fetch and download Catch. I was wondering if it could be expanded to include a simple example of how to integrate a bundled single-header version of Catch into a CMake project. This appears to be the recommended way to use Catch often.
Having reviewed a stackoverflow answer about this, I am still struggling with what the best way to expose this all to CMake and lay out my
test/
directory, and I think it could be a nice addition to the documentation.The text was updated successfully, but these errors were encountered: