diff --git a/.github/workflows/ubuntu-tests.yml b/.github/workflows/ubuntu-tests.yml new file mode 100644 index 0000000..bb56d0c --- /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: pwd && ls && ./stl_reader_tests 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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 16e01f6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: cpp -compiler: gcc -dist: focal - -script: - - mkdir -p build - - cd build - - cmake ../tests - - make -j - - ./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/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. 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..f93045c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,6 +16,8 @@ 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) +add_dependencies (stl_reader_tests copyResources) \ No newline at end of file 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