The popular stb libraries are a set of header-only libraries which are very easy to just copy and paste into existing codebases.
However, if you have already set up a cmake based project is sometimes convenient to have proper cmake targets for the individual libraries.
This wrapper creates cmake targets for each library that takes care of adding the actual implementation for the libraries, i.e., adding the proper STB_(...)_IMPLEMENTATION define.
This is a fork to update the version of stb, fix some minor documentation issues, and update the cmake min target in the era of CMake 4.0 deprecating older versions.
After adding this wrapper to your project you have access to the stb::LIBRARY_NAME targets.
For example, to use the image library you simply add this to your cmake script:
target_link_libraries(YOUR_TARGET PUBLIC stb::image)- Via CPM: simply add
CPMAddPackage("gh:vikhik/stb-cmake-wrapper@0.2")to your cmake script. - Via git submodules: add a submodule to your repository and add
add_subdirectory(path/to/stb-cmake-wrapper). - Alternatively you can also copy and paste the contents of this repository.
This list gives an overview of the currently supported libraries. The libraries currently not supported by the wrapper are the ones needing additional defines to work (textedit, voxel_render, tilemap_editor, connected_components).
- stb::vorbis
- stb::hexwave
- stb::image
- stb::truetype
- stb::image_write
- stb::image_resize
- stb::rect_pack
- stb::perlin
- stb::ds
- stb::sprintf
- stb::textedit
- stb::voxel_render
- stb::dxt
- stb::easy_font
- stb::tilemap_editor
- stb::herringbone_wang_tile
- stb::c_lexer
- stb::divide
- stb::connected_components
- stb::leakcheck
- stb::include