From d3c97039ea55de7ba4d46eeb40a1cb8b85d5dd6a Mon Sep 17 00:00:00 2001 From: HugoFara Date: Fri, 14 Aug 2026 15:33:40 +0200 Subject: [PATCH] build: move stb_image_write.h into third_party/ 1724 lines of public-domain code from nothings/stb sat in src/ among our own, with nothing recording its version, its upstream, or its licence. Patch it and the next update silently reverts the patch. It now sits beside doctest, with all three recorded in the README, and a note that Command.cpp is the only place that may define STB_IMAGE_WRITE_IMPLEMENTATION. third_party/ is now on forefireL's include path as well as the test target's, in both cases as a SYSTEM include, so -Wall -Wextra stops at code we maintain. PRIVATE on forefireL, since Command.cpp is the only consumer. Contributes to #161, which is where the file came to notice: 24 of its 428 warning lines were this one header. --- CMakeLists.txt | 5 +++++ tests/unit/CMakeLists.txt | 4 +++- third_party/README.md | 22 +++++++++++++++++++--- {src => third_party}/stb_image_write.h | 0 4 files changed, 27 insertions(+), 4 deletions(-) rename {src => third_party}/stb_image_write.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a11c7b19..798f6e38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,6 +300,11 @@ endif() target_include_directories(forefireL PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/src/include") +# SYSTEM and PRIVATE: vendored headers are ours to use but not ours to fix, so +# the warning flags below must not apply to them, and nothing outside this +# library includes them. +target_include_directories(forefireL SYSTEM PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/third_party") # Threads is explicit because a static core does not drag libpthread in for # its consumers the way the shared library does. find_package(Threads REQUIRED) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 18ecabd9..219e111d 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -16,7 +16,9 @@ add_executable(forefire_unit_tests target_link_libraries(forefire_unit_tests PRIVATE forefireL) target_include_directories(forefire_unit_tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}") +# SYSTEM, so the warning flags below stop at code this project maintains. +target_include_directories(forefire_unit_tests SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/third_party") if(_ff_warning_flags) diff --git a/third_party/README.md b/third_party/README.md index a9bcd837..dd2caeee 100644 --- a/third_party/README.md +++ b/third_party/README.md @@ -3,12 +3,16 @@ Dependencies that are checked in rather than fetched, so that a build and a CI run need no network access beyond cloning the repository. -Nothing here is compiled into `libforefireL`: `CMakeLists.txt` globs `src/*.cpp` -only, and this directory is on the include path of the test target alone. +Nothing here is compiled on its own: `CMakeLists.txt` globs `src/*.cpp` only. +These are headers, included by whichever target needs them. Both `libforefireL` +and the test target have this directory on their include path, in both cases as +a `SYSTEM` include, so the project's `-Wall -Wextra` does not report code we do +not maintain. -| Directory | Version | License | +| File or directory | Version | License | | --- | --- | --- | | `doctest/` | 2.5.3 (2026-07-06) | MIT | +| `stb_image_write.h` | 1.16 | public domain / MIT | ## doctest @@ -22,3 +26,15 @@ it still builds under the project's `CMAKE_CXX_STANDARD 11`. To update it, replace the file with a newer tagged release and run `ctest --test-dir build`. Nothing in `tests/unit/` uses anything beyond `TEST_SUITE`, `TEST_CASE`, `CHECK`, `REQUIRE`, `CAPTURE` and `doctest::Approx`. + +## stb_image_write + +Writes the PNG output of the `plot` command. Taken unmodified from +, v1.16. + +Header-only, and header-only in the awkward sense: the implementation is +compiled in wherever `STB_IMAGE_WRITE_IMPLEMENTATION` is defined before the +include, which `src/Command.cpp` does and nothing else may. + +To update it, replace the file with a newer release and rebuild. ForeFire uses +`stbi_write_png` only. diff --git a/src/stb_image_write.h b/third_party/stb_image_write.h similarity index 100% rename from src/stb_image_write.h rename to third_party/stb_image_write.h