Skip to content

โš™๏ธ CMake Integration

CrashCatch supports modern CMake out of the box, with both header-only subdirectory usage and installable package support for larger or multi-project environments.


๐Ÿงฉ Using as a Subdirectory

If you cloned or copied CrashCatch into your project, add this to your CMakeLists.txt:

add_subdirectory(CrashCatch)

add_executable(MyApp main.cpp)
target_link_libraries(MyApp PRIVATE CrashCatch::CrashCatch)

This method is great for embedded or monorepo-style projects. It ensures that the CrashCatch target INTERFACE only is available immediatly without installation.


๐Ÿ“ฆ Installing to Your System (Optional)

To install CrashCatch to your machine or a custom prefix:

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=install
cmake --build . --target install

This will generate:

install/
โ”œโ”€โ”€ include/CrashCatch.hpp
โ””โ”€โ”€ lib/cmake/CrashCatch/
    โ”œโ”€โ”€ CrashCatchConfig.cmake
    โ””โ”€โ”€ CrashCatchTargets.cmake


๐Ÿ” Using find_package()

If you've installed CrashCatch via cmake --install, it can be imported in another project.

find_package(CrashCatch REQUIRED)
add_executable(MyApp main.cpp)
target_link_libraries(MyApp PRIVATE CrashCatch::CrashCatch)

CMake will locate the headers and preconfigured target with no additional setup.

Linux Note: You may optionally add -rdynamic or link -ldl for bettery symbol resolution during stack tracing:

target_link_options(MyApp PRIVATE -rdynamic)


๐Ÿงช Example

See examples/ folder for fully working sample projects that compile with CMake.