diff --git a/CMakeLists.txt b/CMakeLists.txt index 05263b2..4a465d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) option(SMATH_BUILD_EXAMPLES "Build example programs" ON) option(SMATH_BUILD_TESTS "Build unit tests" ON) option(SMATH_BUILD_MODULES "Enable C++20 modules support" OFF) +option(SMATH_ENABLE_LEGACY_HEADER "Install legacy include shim" OFF) if(SMATH_BUILD_MODULES) message(STATUS "Building smath C++ module") @@ -17,6 +18,7 @@ add_library(smath INTERFACE) target_include_directories(smath INTERFACE $ + $<$:$> $ ) add_library(smath::smath ALIAS smath) @@ -27,6 +29,16 @@ install(TARGETS smath ) install(DIRECTORY include/ DESTINATION include) +if(SMATH_ENABLE_LEGACY_HEADER) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/smath_legacy_header.hpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/include/smath.hpp" + @ONLY + ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/smath.hpp" DESTINATION include) +endif() + install(EXPORT smathTargets NAMESPACE smath:: FILE smathTargets.cmake @@ -96,4 +108,3 @@ if(SMATH_BUILD_TESTS) include(GoogleTest) gtest_discover_tests(smath_tests) endif() - diff --git a/cmake/smath_legacy_header.hpp.in b/cmake/smath_legacy_header.hpp.in new file mode 100644 index 0000000..46cf641 --- /dev/null +++ b/cmake/smath_legacy_header.hpp.in @@ -0,0 +1,3 @@ +#pragma once + +#include diff --git a/examples/projection.cpp b/examples/projection.cpp index 7621b60..afad5f8 100644 --- a/examples/projection.cpp +++ b/examples/projection.cpp @@ -10,7 +10,7 @@ #include #endif -#include +#include using smath::Vec2; enum Color : uint8_t diff --git a/examples/random_steps.cpp b/examples/random_steps.cpp index c0b4d1c..6c7a3b2 100644 --- a/examples/random_steps.cpp +++ b/examples/random_steps.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include auto main() -> int { diff --git a/examples/tour.cpp b/examples/tour.cpp index 2e577ee..f844aae 100644 --- a/examples/tour.cpp +++ b/examples/tour.cpp @@ -17,7 +17,7 @@ // #define SMATH_IMPLICIT_CONVERSIONS -#include +#include int main() { diff --git a/flake.nix b/flake.nix index 3126772..40d9f94 100644 --- a/flake.nix +++ b/flake.nix @@ -57,8 +57,8 @@ installPhase = '' runHook preInstall - mkdir -p $out/include - cp ../include/smath.hpp $out/include/ + mkdir -p $out/include/smath + cp ../include/smath/smath.hpp $out/include/smath/ runHook postInstall ''; diff --git a/include/smath.hpp b/include/smath/smath.hpp similarity index 100% rename from include/smath.hpp rename to include/smath/smath.hpp diff --git a/src/modules/smath.cppm b/src/modules/smath.cppm index 5a44a25..2973f2a 100644 --- a/src/modules/smath.cppm +++ b/src/modules/smath.cppm @@ -1,6 +1,6 @@ module; -#include "smath.hpp" +#include "smath/smath.hpp" export module smath; diff --git a/tests/angles.cpp b/tests/angles.cpp index 6453a4e..c47c3e1 100644 --- a/tests/angles.cpp +++ b/tests/angles.cpp @@ -1,6 +1,6 @@ #include -#include +#include TEST(AngleReturnRadians, DegInput) { diff --git a/tests/interop.cpp b/tests/interop.cpp index d7dc2e9..071b3d1 100644 --- a/tests/interop.cpp +++ b/tests/interop.cpp @@ -2,7 +2,7 @@ #include -#include +#include struct ExternalVec3f { diff --git a/tests/vec.cpp b/tests/vec.cpp index ce23ce5..ddffa16 100644 --- a/tests/vec.cpp +++ b/tests/vec.cpp @@ -4,7 +4,7 @@ #include -#include +#include using smath::Vec; using smath::Vec2;