Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Export for DLL (shared MSVC build) #17

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.26)

project(omath VERSION 1.0.0)


include(CMakePackageConfigHelpers)

set(CMAKE_CXX_STANDARD 26)

Expand All @@ -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()

Expand Down Expand Up @@ -79,4 +85,4 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake"
DESTINATION lib/cmake/omath
)
)
4 changes: 2 additions & 2 deletions include/omath/Angle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "omath/Angles.hpp"

#include <algorithm>

#include "omath/omath_export.hpp"

namespace omath
{
Expand All @@ -18,7 +18,7 @@ namespace omath

template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized>
requires std::is_arithmetic_v<Type>
class Angle
class OMATH_API Angle
{
Type m_angle;
constexpr Angle(const Type& degrees)
Expand Down
1 change: 0 additions & 1 deletion include/omath/Angles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <numbers>
#include <cmath>


namespace omath::angles
{
template<class Type>
Expand Down
6 changes: 3 additions & 3 deletions include/omath/Color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
#include "omath/Vector3.hpp"
#include <cstdint>
#include "omath/Vector4.hpp"

#include "omath/omath_export.hpp"

namespace omath
{
struct HSV
struct OMATH_API HSV
{
float m_hue{};
float m_saturation{};
float m_value{};
};


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)
Expand Down
6 changes: 3 additions & 3 deletions include/omath/Mat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include <stdexcept>
#include <utility>
#include "Vector3.hpp"

#include "omath/omath_export.hpp"

namespace omath
{
struct MatSize
struct OMATH_API MatSize
{
size_t rows, columns;
};
Expand All @@ -25,7 +25,7 @@ namespace omath

template<size_t Rows = 0, size_t Columns = 0, class Type = float, MatStoreType StoreType = MatStoreType::ROW_MAJOR>
requires std::is_arithmetic_v<Type>
class Mat final
class OMATH_API Mat final
{
public:
constexpr Mat()
Expand Down
3 changes: 2 additions & 1 deletion include/omath/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#include <initializer_list>
#include <memory>
#include <string>
#include "omath/omath_export.hpp"

namespace omath
{
class Vector3;

class Matrix final
class OMATH_API Matrix final
{
public:
Matrix();
Expand Down
3 changes: 2 additions & 1 deletion include/omath/Triangle3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
//
#pragma once
#include "omath/Vector3.hpp"
#include "omath/omath_export.hpp"

namespace omath
{
class Triangle3d final
class OMATH_API Triangle3d final
{
public:
Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3);
Expand Down
4 changes: 2 additions & 2 deletions include/omath/Vector2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#pragma once
#include <tuple>
#include <cmath>

#include "omath/omath_export.hpp"

namespace omath
{
class Vector2
class OMATH_API Vector2
{
public:
float x = 0.f;
Expand Down
4 changes: 2 additions & 2 deletions include/omath/Vector3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include <cstdint>
#include <functional>
#include "omath/Vector2.hpp"

#include "omath/omath_export.hpp"

namespace omath
{
class Vector3 : public Vector2
class OMATH_API Vector3 : public Vector2
{
public:
float z = 0.f;
Expand Down
4 changes: 2 additions & 2 deletions include/omath/Vector4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <omath/Vector3.hpp>
#include <algorithm>

#include "omath/omath_export.hpp"

namespace omath
{
class Vector4 : public Vector3
class OMATH_API Vector4 : public Vector3
{
public:
float w;
Expand Down
4 changes: 3 additions & 1 deletion include/omath/ViewAngles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
//
#pragma once

#include "omath/omath_export.hpp"

namespace omath
{
template<class PitchType, class YawType, class RollType>
struct ViewAngles
struct OMATH_API ViewAngles
{
PitchType pitch;
YawType yaw;
Expand Down
6 changes: 3 additions & 3 deletions include/omath/collision/LineTracer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include "omath/Vector3.hpp"
#include "omath/Triangle3d.hpp"

#include "omath/omath_export.hpp"

namespace omath::collision
{
class Ray
class OMATH_API Ray
{
public:
Vector3 start;
Expand All @@ -21,7 +21,7 @@ namespace omath::collision
[[nodiscard]]
Vector3 DirectionVectorNormalized() const;
};
class LineTracer
class OMATH_API LineTracer
{
public:
LineTracer() = delete;
Expand Down
3 changes: 2 additions & 1 deletion include/omath/engines/Source/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#pragma once
#include "Constants.h"
#include "omath/projection/Camera.hpp"
#include "omath/omath_export.hpp"

namespace omath::source
{
class Camera final : public projection::Camera<Mat4x4, ViewAngles>
class OMATH_API Camera final : public projection::Camera<Mat4x4, ViewAngles>
{
public:
Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,
Expand Down
24 changes: 24 additions & 0 deletions include/omath/omath_export.hpp
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions include/omath/pathfinding/Astar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include <vector>
#include "NavigationMesh.hpp"
#include "omath/Vector3.hpp"

#include "omath/omath_export.hpp"

namespace omath::pathfinding
{
class Astar final
class OMATH_API Astar final
{
public:
[[nodiscard]]
Expand Down
4 changes: 2 additions & 2 deletions include/omath/pathfinding/NavigationMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <expected>
#include <vector>
#include <string>

#include "omath/omath_export.hpp"

namespace omath::pathfinding
{
Expand All @@ -18,7 +18,7 @@ namespace omath::pathfinding

};

class NavigationMesh final
class OMATH_API NavigationMesh final
{
public:

Expand Down
4 changes: 2 additions & 2 deletions include/omath/prediction/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include "omath/Vector3.hpp"
#include "omath/prediction/Projectile.hpp"
#include "omath/prediction/Target.hpp"

#include "omath/omath_export.hpp"

namespace omath::prediction
{
class Engine final
class OMATH_API Engine final
{
public:
explicit Engine(float gravityConstant, float simulationTimeStep,
Expand Down
4 changes: 2 additions & 2 deletions include/omath/prediction/Projectile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#pragma once
#include "omath/Vector3.hpp"

#include "omath/omath_export.hpp"

namespace omath::prediction
{
class Projectile final
class OMATH_API Projectile final
{
public:

Expand Down
4 changes: 2 additions & 2 deletions include/omath/prediction/Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#pragma once
#include "omath/Vector3.hpp"

#include "omath/omath_export.hpp"

namespace omath::prediction
{
class Target final
class OMATH_API Target final
{
public:

Expand Down
6 changes: 3 additions & 3 deletions include/omath/projection/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "ErrorCodes.hpp"
#include <omath/Angle.hpp>
#include <type_traits>

#include "omath/omath_export.hpp"

namespace omath::projection
{
class ViewPort final
class OMATH_API ViewPort final
{
public:
float m_width;
Expand All @@ -28,7 +28,7 @@ namespace omath::projection
using FieldOfView = const Angle<float, 0.f, 180.f, AngleFlags::Clamped>;

template<class Mat4x4Type, class ViewAnglesType>
class Camera
class OMATH_API Camera
{

public:
Expand Down