mirror of
https://github.com/slendidev/smath.git
synced 2026-03-17 02:26:50 +02:00
Move smath.hpp to smath/smath.hpp
This is done in preparation for optional interop headers for different libraries. Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
@@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
option(SMATH_BUILD_EXAMPLES "Build example programs" ON)
|
option(SMATH_BUILD_EXAMPLES "Build example programs" ON)
|
||||||
option(SMATH_BUILD_TESTS "Build unit tests" ON)
|
option(SMATH_BUILD_TESTS "Build unit tests" ON)
|
||||||
option(SMATH_BUILD_MODULES "Enable C++20 modules support" OFF)
|
option(SMATH_BUILD_MODULES "Enable C++20 modules support" OFF)
|
||||||
|
option(SMATH_ENABLE_LEGACY_HEADER "Install legacy include <smath.hpp> shim" OFF)
|
||||||
|
|
||||||
if(SMATH_BUILD_MODULES)
|
if(SMATH_BUILD_MODULES)
|
||||||
message(STATUS "Building smath C++ module")
|
message(STATUS "Building smath C++ module")
|
||||||
@@ -17,6 +18,7 @@ add_library(smath INTERFACE)
|
|||||||
target_include_directories(smath
|
target_include_directories(smath
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<$<BOOL:${SMATH_ENABLE_LEGACY_HEADER}>:$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
add_library(smath::smath ALIAS smath)
|
add_library(smath::smath ALIAS smath)
|
||||||
@@ -27,6 +29,16 @@ install(TARGETS smath
|
|||||||
)
|
)
|
||||||
install(DIRECTORY include/ DESTINATION include)
|
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
|
install(EXPORT smathTargets
|
||||||
NAMESPACE smath::
|
NAMESPACE smath::
|
||||||
FILE smathTargets.cmake
|
FILE smathTargets.cmake
|
||||||
@@ -96,4 +108,3 @@ if(SMATH_BUILD_TESTS)
|
|||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(smath_tests)
|
gtest_discover_tests(smath_tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
3
cmake/smath_legacy_header.hpp.in
Normal file
3
cmake/smath_legacy_header.hpp.in
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <smath/smath.hpp>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <smath.hpp>
|
#include <smath/smath.hpp>
|
||||||
using smath::Vec2;
|
using smath::Vec2;
|
||||||
|
|
||||||
enum Color : uint8_t
|
enum Color : uint8_t
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <print>
|
#include <print>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include <smath.hpp>
|
#include <smath/smath.hpp>
|
||||||
|
|
||||||
auto main() -> int
|
auto main() -> int
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
// #define SMATH_IMPLICIT_CONVERSIONS
|
// #define SMATH_IMPLICIT_CONVERSIONS
|
||||||
|
|
||||||
#include <smath.hpp>
|
#include <smath/smath.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,8 +57,8 @@
|
|||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/include
|
mkdir -p $out/include/smath
|
||||||
cp ../include/smath.hpp $out/include/
|
cp ../include/smath/smath.hpp $out/include/smath/
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module;
|
module;
|
||||||
|
|
||||||
#include "smath.hpp"
|
#include "smath/smath.hpp"
|
||||||
|
|
||||||
export module smath;
|
export module smath;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <smath.hpp>
|
#include <smath/smath.hpp>
|
||||||
|
|
||||||
TEST(AngleReturnRadians, DegInput)
|
TEST(AngleReturnRadians, DegInput)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <smath.hpp>
|
#include <smath/smath.hpp>
|
||||||
|
|
||||||
struct ExternalVec3f
|
struct ExternalVec3f
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <smath.hpp>
|
#include <smath/smath.hpp>
|
||||||
|
|
||||||
using smath::Vec;
|
using smath::Vec;
|
||||||
using smath::Vec2;
|
using smath::Vec2;
|
||||||
|
|||||||
Reference in New Issue
Block a user