diff --git a/CMakeLists.txt b/CMakeLists.txt index f79bac9..23713a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.26) project(omath VERSION 1.0.0) - +include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD 26) @@ -19,10 +19,16 @@ else() add_library(omath STATIC source/Vector3.cpp) endif() +target_compile_definitions(omath PUBLIC OMATH_EXPORT) + +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(omath PRIVATE /Zc:static_assert-) +endif() + add_subdirectory(source) -add_subdirectory(extlibs) if(OMATH_BUILD_TESTS) + add_subdirectory(extlibs) add_subdirectory(tests) endif() @@ -79,4 +85,4 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" DESTINATION lib/cmake/omath -) \ No newline at end of file +) diff --git a/include/omath/Angle.hpp b/include/omath/Angle.hpp index 26c6ebf..3622a1c 100644 --- a/include/omath/Angle.hpp +++ b/include/omath/Angle.hpp @@ -6,7 +6,7 @@ #include "omath/Angles.hpp" #include - +#include "omath_export.h" namespace omath { @@ -18,7 +18,7 @@ namespace omath template requires std::is_arithmetic_v - class Angle + class OMATH_API Angle { Type m_angle; constexpr Angle(const Type& degrees) diff --git a/include/omath/Angles.hpp b/include/omath/Angles.hpp index 47a287a..c578afb 100644 --- a/include/omath/Angles.hpp +++ b/include/omath/Angles.hpp @@ -6,7 +6,6 @@ #include #include - namespace omath::angles { template diff --git a/include/omath/Color.hpp b/include/omath/Color.hpp index 4625545..cf4644b 100644 --- a/include/omath/Color.hpp +++ b/include/omath/Color.hpp @@ -7,11 +7,11 @@ #include "omath/Vector3.hpp" #include #include "omath/Vector4.hpp" - +#include "omath_export.h" namespace omath { - struct HSV + struct OMATH_API HSV { float m_hue{}; float m_saturation{}; @@ -19,7 +19,7 @@ namespace omath }; - class Color final : public Vector4 + class OMATH_API Color final : public Vector4 { public: constexpr Color(float r, float g, float b, float a) : Vector4(r,g,b,a) diff --git a/include/omath/Mat.hpp b/include/omath/Mat.hpp index 3cb6f91..3adb480 100644 --- a/include/omath/Mat.hpp +++ b/include/omath/Mat.hpp @@ -8,11 +8,11 @@ #include #include #include "Vector3.hpp" - +#include "omath_export.h" namespace omath { - struct MatSize + struct OMATH_API MatSize { size_t rows, columns; }; @@ -25,7 +25,7 @@ namespace omath template requires std::is_arithmetic_v - class Mat final + class OMATH_API Mat final { public: constexpr Mat() diff --git a/include/omath/Matrix.hpp b/include/omath/Matrix.hpp index 1fbdb4b..fc1e296 100644 --- a/include/omath/Matrix.hpp +++ b/include/omath/Matrix.hpp @@ -2,12 +2,13 @@ #include #include #include +#include "omath_export.h" namespace omath { class Vector3; - class Matrix final + class OMATH_API Matrix final { public: Matrix(); diff --git a/include/omath/Triangle3d.hpp b/include/omath/Triangle3d.hpp index 370aa95..826e4fc 100644 --- a/include/omath/Triangle3d.hpp +++ b/include/omath/Triangle3d.hpp @@ -3,10 +3,11 @@ // #pragma once #include "omath/Vector3.hpp" +#include "omath_export.h" namespace omath { - class Triangle3d final + class OMATH_API Triangle3d final { public: Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3); diff --git a/include/omath/Vector2.hpp b/include/omath/Vector2.hpp index 46bc467..a4cf0af 100644 --- a/include/omath/Vector2.hpp +++ b/include/omath/Vector2.hpp @@ -5,11 +5,11 @@ #pragma once #include #include - +#include "omath_export.h" namespace omath { - class Vector2 + class OMATH_API Vector2 { public: float x = 0.f; diff --git a/include/omath/Vector3.hpp b/include/omath/Vector3.hpp index e22d815..c0521b3 100644 --- a/include/omath/Vector3.hpp +++ b/include/omath/Vector3.hpp @@ -7,11 +7,11 @@ #include #include #include "omath/Vector2.hpp" - +#include "omath_export.h" namespace omath { - class Vector3 : public Vector2 + class OMATH_API Vector3 : public Vector2 { public: float z = 0.f; diff --git a/include/omath/Vector4.hpp b/include/omath/Vector4.hpp index 4b43501..8a3c84f 100644 --- a/include/omath/Vector4.hpp +++ b/include/omath/Vector4.hpp @@ -5,11 +5,11 @@ #include #include - +#include "omath_export.h" namespace omath { - class Vector4 : public Vector3 + class OMATH_API Vector4 : public Vector3 { public: float w; diff --git a/include/omath/ViewAngles.hpp b/include/omath/ViewAngles.hpp index d744f6b..e3ef7a8 100644 --- a/include/omath/ViewAngles.hpp +++ b/include/omath/ViewAngles.hpp @@ -3,10 +3,12 @@ // #pragma once +#include "omath_export.h" + namespace omath { template - struct ViewAngles + struct OMATH_API ViewAngles { PitchType pitch; YawType yaw; diff --git a/include/omath/collision/LineTracer.hpp b/include/omath/collision/LineTracer.hpp index fc1d7fa..2c42e60 100644 --- a/include/omath/collision/LineTracer.hpp +++ b/include/omath/collision/LineTracer.hpp @@ -5,11 +5,11 @@ #include "omath/Vector3.hpp" #include "omath/Triangle3d.hpp" - +#include "../omath_export.h" namespace omath::collision { - class Ray + class OMATH_API Ray { public: Vector3 start; @@ -21,7 +21,7 @@ namespace omath::collision [[nodiscard]] Vector3 DirectionVectorNormalized() const; }; - class LineTracer + class OMATH_API LineTracer { public: LineTracer() = delete; diff --git a/include/omath/engines/Source/Camera.hpp b/include/omath/engines/Source/Camera.hpp index aca13cf..4ebe113 100644 --- a/include/omath/engines/Source/Camera.hpp +++ b/include/omath/engines/Source/Camera.hpp @@ -4,10 +4,11 @@ #pragma once #include "Constants.h" #include "omath/projection/Camera.hpp" +#include "../../omath_export.h" namespace omath::source { - class Camera final : public projection::Camera + class OMATH_API Camera final : public projection::Camera { public: Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort, diff --git a/include/omath/omath_export.h b/include/omath/omath_export.h new file mode 100644 index 0000000..091fd56 --- /dev/null +++ b/include/omath/omath_export.h @@ -0,0 +1,24 @@ +#pragma once + +/* Export prefix for functions */ +#ifdef _MSC_VER + /* MSVC */ +# define OMATH_API_EXPORT __declspec(dllexport) +#else + /* GCC/Clang */ +# define OMATH_API_EXPORT __attribute__((visibility("default"))) +#endif + +/* Import prefix for functions */ +#ifdef _MSC_VER +# define OMATH_API_IMPORT __declspec(dllimport) +#else +# define OMATH_API_IMPORT extern +#endif + +/* Resolve import/export */ +#ifdef OMATH_EXPORT +# define OMATH_API OMATH_API_EXPORT +#else +# define OMATH_API OMATH_API_IMPORT +#endif \ No newline at end of file diff --git a/include/omath/pathfinding/Astar.hpp b/include/omath/pathfinding/Astar.hpp index 0609850..07d7323 100644 --- a/include/omath/pathfinding/Astar.hpp +++ b/include/omath/pathfinding/Astar.hpp @@ -6,11 +6,11 @@ #include #include "NavigationMesh.hpp" #include "omath/Vector3.hpp" - +#include "../omath_export.h" namespace omath::pathfinding { - class Astar final + class OMATH_API Astar final { public: [[nodiscard]] diff --git a/include/omath/pathfinding/NavigationMesh.hpp b/include/omath/pathfinding/NavigationMesh.hpp index 525cbc4..325fe9d 100644 --- a/include/omath/pathfinding/NavigationMesh.hpp +++ b/include/omath/pathfinding/NavigationMesh.hpp @@ -8,7 +8,7 @@ #include #include #include - +#include "../omath_export.h" namespace omath::pathfinding { @@ -18,7 +18,7 @@ namespace omath::pathfinding }; - class NavigationMesh final + class OMATH_API NavigationMesh final { public: diff --git a/include/omath/prediction/Engine.hpp b/include/omath/prediction/Engine.hpp index 6d8e617..d81eea0 100644 --- a/include/omath/prediction/Engine.hpp +++ b/include/omath/prediction/Engine.hpp @@ -8,11 +8,11 @@ #include "omath/Vector3.hpp" #include "omath/prediction/Projectile.hpp" #include "omath/prediction/Target.hpp" - +#include "../omath_export.h" namespace omath::prediction { - class Engine final + class OMATH_API Engine final { public: explicit Engine(float gravityConstant, float simulationTimeStep, diff --git a/include/omath/prediction/Projectile.hpp b/include/omath/prediction/Projectile.hpp index 93ded29..51da5ae 100644 --- a/include/omath/prediction/Projectile.hpp +++ b/include/omath/prediction/Projectile.hpp @@ -4,11 +4,11 @@ #pragma once #include "omath/Vector3.hpp" - +#include "../omath_export.h" namespace omath::prediction { - class Projectile final + class OMATH_API Projectile final { public: diff --git a/include/omath/prediction/Target.hpp b/include/omath/prediction/Target.hpp index a2b37ce..2f062d0 100644 --- a/include/omath/prediction/Target.hpp +++ b/include/omath/prediction/Target.hpp @@ -4,11 +4,11 @@ #pragma once #include "omath/Vector3.hpp" - +#include "../omath_export.h" namespace omath::prediction { - class Target final + class OMATH_API Target final { public: diff --git a/include/omath/projection/Camera.hpp b/include/omath/projection/Camera.hpp index 15db451..2254d4c 100644 --- a/include/omath/projection/Camera.hpp +++ b/include/omath/projection/Camera.hpp @@ -10,11 +10,11 @@ #include "ErrorCodes.hpp" #include #include - +#include "../omath_export.h" namespace omath::projection { - class ViewPort final + class OMATH_API ViewPort final { public: float m_width; @@ -28,7 +28,7 @@ namespace omath::projection using FieldOfView = const Angle; template - class Camera + class OMATH_API Camera { public: