Skip to content

Commit 231ef35

Browse files
authored
Merge pull request #49 from orange-cpp/feature/legacy_option
Adds option to enable legacy classes
2 parents d65852d + 1aa62cb commit 231ef35

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" O
1414
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
1515
option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON)
1616
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" ON)
17+
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF)
18+
1719

1820
file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
1921
file(GLOB_RECURSE OMATH_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
@@ -56,6 +58,10 @@ if (OMATH_SUPRESS_SAFETY_CHECKS)
5658
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_SUPRESS_SAFETY_CHECKS)
5759
endif ()
5860

61+
if (OMATH_ENABLE_LEGACY)
62+
target_compile_options(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
63+
endif ()
64+
5965
set_target_properties(${PROJECT_NAME} PROPERTIES
6066
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
6167
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"

include/omath/matrix.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#pragma once
2+
3+
#ifdef OMATH_ENABLE_LEGACY
4+
25
#include "omath/vector3.hpp"
36
#include <initializer_list>
47
#include <memory>
@@ -106,3 +109,4 @@ namespace omath
106109
std::unique_ptr<float[]> m_data;
107110
};
108111
} // namespace omath
112+
#endif

source/matrix.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef OMATH_ENABLE_LEGACY
2+
13
#include "omath/matrix.hpp"
24
#include "omath/angles.hpp"
35
#include "omath/vector3.hpp"
@@ -359,3 +361,4 @@ namespace omath
359361
m_data = nullptr;
360362
}
361363
} // namespace omath
364+
#endif

tests/general/unit_test_matrix.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//
22
// Created by vlad on 5/18/2024.
33
//
4+
5+
#ifdef OMATH_ENABLE_LEGACY
6+
47
#include <gtest/gtest.h>
58
#include <omath/matrix.hpp>
69
#include "omath/vector3.hpp"
@@ -177,4 +180,5 @@ TEST_F(UnitTestMatrix, AssignmentOperator_Move)
177180
EXPECT_FLOAT_EQ(m3.at(0, 0), 1.0f);
178181
EXPECT_EQ(m2.row_count(), 0); // m2 should be empty after the move
179182
EXPECT_EQ(m2.columns_count(), 0);
180-
}
183+
}
184+
#endif

0 commit comments

Comments
 (0)