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. It is also available via vcpkg and Conan.


๐Ÿงฉ 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. The CrashCatch INTERFACE target is available immediately 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
โ”‚   โ””โ”€โ”€ CrashCatchDLL.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: Add -rdynamic for better symbol resolution in stack traces:

target_link_options(MyApp PRIVATE -rdynamic)


๐Ÿ“ฆ vcpkg

CrashCatch is available as a vcpkg port. If you have vcpkg installed:

vcpkg install crashcatch

Then in your CMakeLists.txt:

find_package(CrashCatch CONFIG REQUIRED)
target_link_libraries(MyApp PRIVATE CrashCatch::CrashCatch)

Pass your vcpkg toolchain file when configuring:

cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake

Or use a vcpkg.json manifest in your project root:

{
  "dependencies": [ "crashcatch" ]
}

๐Ÿ Conan

CrashCatch is available as a Conan package. Add it to your conanfile.txt:

[requires]
crashcatch/1.4.0

[generators]
CMakeDeps
CMakeToolchain

Then install and configure:

conan install . --output-folder=build --build=missing
cmake .. -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake

Or in a conanfile.py:

def requirements(self):
    self.requires("crashcatch/1.4.0")

๐Ÿงช Example

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