From 5bdde4c0a787e217e3b6730e3e7ff495ee9ebe73 Mon Sep 17 00:00:00 2001 From: Sebastian Reiter Date: Tue, 3 Feb 2026 11:37:21 +0100 Subject: [PATCH 1/6] Move `stl_reader.h` to `include/stl_reader` and provide CMakeLists.txt To better support CMake workflows using `FetchContent` and for a better integration into existing CMake based projects, `stl_reader.h` was moved to the sub-directory `include/stl_reader`. A `CMakeLists.txt` script is provided which defines an interface library `stl_reader`. --- .travis.yml | 4 ++-- CMakeLists.txt | 11 +++++++++++ docs/doxygen_config/stl_reader.dconf | 2 +- stl_reader.h => include/stl_reader/stl_reader.h | 0 tests/CMakeLists.txt | 3 ++- tests/read_stl.t.cpp | 2 +- tests/utils.h | 2 +- 7 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 CMakeLists.txt rename stl_reader.h => include/stl_reader/stl_reader.h (100%) diff --git a/.travis.yml b/.travis.yml index 16e01f6..de7f2c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,6 @@ dist: focal script: - mkdir -p build - cd build - - cmake ../tests + - cmake -DSTL_READER_BUILD_TESTS=ON .. - make -j - - ./stl_reader_tests + - ./tests/stl_reader_tests diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..17625ef --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 3.15) + +project (stl_reader) + +add_library (stl_reader INTERFACE) +target_include_directories (stl_reader INTERFACE include) + +option (STL_READER_BUILD_TESTS "Build the stl_reader tests." OFF) +if (STL_READER_BUILD_TESTS) + add_subdirectory (tests) +endif () diff --git a/docs/doxygen_config/stl_reader.dconf b/docs/doxygen_config/stl_reader.dconf index 647ce5c..d262fa9 100644 --- a/docs/doxygen_config/stl_reader.dconf +++ b/docs/doxygen_config/stl_reader.dconf @@ -907,7 +907,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = stl_reader.h \ +INPUT = include/stl_reader/stl_reader.h \ Readme.md # This tag can be used to specify the character encoding of the source files diff --git a/stl_reader.h b/include/stl_reader/stl_reader.h similarity index 100% rename from stl_reader.h rename to include/stl_reader/stl_reader.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a4e3d86..8d1f3c2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,6 +16,7 @@ FetchContent_Declare ( set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable (googletest) -target_link_libraries (stl_reader_tests gtest_main) +target_link_libraries (stl_reader_tests gtest_main stl_reader) + add_custom_target (copyResources ALL COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data data) diff --git a/tests/read_stl.t.cpp b/tests/read_stl.t.cpp index 2801478..1c8f243 100644 --- a/tests/read_stl.t.cpp +++ b/tests/read_stl.t.cpp @@ -1,4 +1,4 @@ -#include "../stl_reader.h" +#include #include TEST (readSTL, asciiSphere) diff --git a/tests/utils.h b/tests/utils.h index 3e2e935..1488b34 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -1,6 +1,6 @@ #pragma once -#include "../stl_reader.h" +#include #include #include From 858c52d3861db020fcc24fec8a40e6f9e5f01eaf Mon Sep 17 00:00:00 2001 From: Sebastian Reiter Date: Tue, 3 Feb 2026 11:37:52 +0100 Subject: [PATCH 2/6] Add .gitignore with very common temporary files and paths. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e10828 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.cache +compile_commands.json From f9bd99339ad586820e71a8994a7669b4b9e15d54 Mon Sep 17 00:00:00 2001 From: Sebastian Reiter Date: Tue, 3 Feb 2026 12:11:11 +0100 Subject: [PATCH 3/6] Update readme on how to integrate stl_reader using CMake's FetchContent. --- Readme.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Readme.md b/Readme.md index 3f4bcb0..3efd544 100644 --- a/Readme.md +++ b/Readme.md @@ -9,6 +9,25 @@ The function operates on template container types. Those containers should have A convenience class `StlMesh` is also provided, which makes accessing triangle corners and corresponding corner coordinates much more easy. It still provides raw access to the underlying data arrays. +## CMake integration +`CMake` is entirely optional and not required to use **stl_reader**. However, starting from **v2.0**, **stl_reader** provides an interface library of the same name, which adds the required include path when being linked against some target. This is especially useful when using `CMake's` `FetchContent` mechanism in your `CMakeLists.txt`, e.g., like this: +``` +include (FetchContent) +FetchContent_Declare ( + stl_reader + GIT_REPOSITORY https://github.com/sreiter/stl_reader.git + GIT_TAG v2.0 +) +FetchContent_MakeAvailable (stl_reader) +#... +target_link_libraries (YOUR_TARGET stl_reader) +``` + +You may then include **stl_reader.h** in your project like this: +``` +#include +``` + ## Documentation Please have a look at the [**stl_reader.h file documentation**](http://sreiter.github.io/stl_reader/stl__reader_8h.html) for a detailed documentation of the provided functions. From eebda399efd29d4184a1fa1910ad39d577fbf8c7 Mon Sep 17 00:00:00 2001 From: Sebastian Reiter Date: Sun, 19 Apr 2026 17:31:22 +0200 Subject: [PATCH 4/6] Use github workflows instead of travis for testing. --- .github/workflows/ubuntu-tests.yml | 34 ++++++++++++++++++++++++++++++ .travis.yml | 10 --------- 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ubuntu-tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ubuntu-tests.yml b/.github/workflows/ubuntu-tests.yml new file mode 100644 index 0000000..987daac --- /dev/null +++ b/.github/workflows/ubuntu-tests.yml @@ -0,0 +1,34 @@ +name: Ubuntu tests + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSTL_READER_BUILD_TESTS=ON + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build + + - name: Test + working-directory: ${{github.workspace}}/build/tests + run: stl_reader_tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index de7f2c7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: cpp -compiler: gcc -dist: focal - -script: - - mkdir -p build - - cd build - - cmake -DSTL_READER_BUILD_TESTS=ON .. - - make -j - - ./tests/stl_reader_tests From eaac71dbfb11c787fc92e193b53783ddee514eec Mon Sep 17 00:00:00 2001 From: Sebastian Reiter Date: Sun, 19 Apr 2026 20:08:13 +0200 Subject: [PATCH 5/6] Fix test dependencies. --- tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8d1f3c2..f93045c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,3 +20,4 @@ target_link_libraries (stl_reader_tests gtest_main stl_reader) add_custom_target (copyResources ALL COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data data) +add_dependencies (stl_reader_tests copyResources) \ No newline at end of file From 11b973a9b3d845f9f66d43284dd6e3af182a5f5c Mon Sep 17 00:00:00 2001 From: Sebastian Reiter Date: Sun, 19 Apr 2026 20:08:55 +0200 Subject: [PATCH 6/6] Run CI tests with debug output. --- .github/workflows/ubuntu-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu-tests.yml b/.github/workflows/ubuntu-tests.yml index 987daac..bb56d0c 100644 --- a/.github/workflows/ubuntu-tests.yml +++ b/.github/workflows/ubuntu-tests.yml @@ -31,4 +31,4 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build/tests - run: stl_reader_tests + run: pwd && ls && ./stl_reader_tests