mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
improved cmake, removed useless cmake files
This commit is contained in:
@@ -15,11 +15,15 @@ option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" O
|
||||
option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON)
|
||||
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" ON)
|
||||
|
||||
file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
|
||||
file(GLOB_RECURSE OMATH_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
|
||||
|
||||
|
||||
if (OMATH_BUILD_AS_SHARED_LIBRARY)
|
||||
add_library(omath SHARED source/matrix.cpp)
|
||||
else()
|
||||
add_library(omath STATIC source/matrix.cpp)
|
||||
endif()
|
||||
add_library(omath SHARED ${OMATH_SOURCES} ${OMATH_HEADERS})
|
||||
else ()
|
||||
add_library(omath STATIC ${OMATH_SOURCES} ${OMATH_HEADERS})
|
||||
endif ()
|
||||
|
||||
message(STATUS "Building on ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
add_library(omath::omath ALIAS omath)
|
||||
@@ -28,28 +32,28 @@ if (OMATH_IMGUI_INTEGRATION)
|
||||
target_compile_definitions(omath PUBLIC OMATH_IMGUI_INTEGRATION)
|
||||
|
||||
# IMGUI is being linked as submodule
|
||||
if(TARGET imgui)
|
||||
if (TARGET imgui)
|
||||
target_link_libraries(omath PUBLIC imgui)
|
||||
install(TARGETS imgui
|
||||
EXPORT omathTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin)
|
||||
else()
|
||||
else ()
|
||||
# Assume that IMGUI linked via VCPKG.
|
||||
find_package(imgui CONFIG REQUIRED)
|
||||
target_link_libraries(omath PUBLIC imgui::imgui)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (OMATH_USE_AVX2)
|
||||
target_compile_definitions(omath PUBLIC OMATH_USE_AVX2)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
target_compile_definitions(omath PUBLIC OMATH_SUPRESS_SAFETY_CHECKS)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
set_target_properties(omath PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||
@@ -61,37 +65,35 @@ if (OMATH_USE_UNITY_BUILD)
|
||||
set_target_properties(omath PROPERTIES
|
||||
UNITY_BUILD ON
|
||||
UNITY_BUILD_BATCH_SIZE 20)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
||||
set_target_properties(omath PROPERTIES
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(omath PRIVATE -mavx2 -mfma)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
target_compile_features(omath PUBLIC cxx_std_23)
|
||||
|
||||
|
||||
add_subdirectory(source)
|
||||
|
||||
if(OMATH_BUILD_TESTS)
|
||||
if (OMATH_BUILD_TESTS)
|
||||
add_subdirectory(extlibs)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (OMATH_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND OMATH_THREAT_WARNING_AS_ERROR)
|
||||
target_compile_options(omath PRIVATE /W4 /WX)
|
||||
elseif(OMATH_THREAT_WARNING_AS_ERROR)
|
||||
elseif (OMATH_THREAT_WARNING_AS_ERROR)
|
||||
target_compile_options(omath PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
target_include_directories(omath
|
||||
PUBLIC
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE box.cpp)
|
||||
@@ -1,11 +0,0 @@
|
||||
target_sources(omath PRIVATE
|
||||
matrix.cpp
|
||||
color.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(projectile_prediction)
|
||||
add_subdirectory(pathfinding)
|
||||
add_subdirectory(projection)
|
||||
add_subdirectory(collision)
|
||||
add_subdirectory(engines)
|
||||
add_subdirectory(3d_primitives)
|
||||
@@ -1,3 +0,0 @@
|
||||
target_sources(omath PRIVATE
|
||||
line_tracer.cpp
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
add_subdirectory(source_engine)
|
||||
add_subdirectory(opengl_engine)
|
||||
add_subdirectory(iw_engine)
|
||||
add_subdirectory(unity_engine)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE camera.cpp formulas.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE camera.cpp formulas.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE camera.cpp formulas.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE formulas.cpp camera.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE navigation_mesh.cpp a_star.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE proj_pred_engine_legacy.cpp projectile.cpp target.cpp proj_pred_engine_avx2.cpp proj_pred_engine.cpp)
|
||||
@@ -1 +0,0 @@
|
||||
target_sources(omath PRIVATE camera.cpp)
|
||||
@@ -1,33 +1,13 @@
|
||||
enable_testing()
|
||||
|
||||
project(unit-tests)
|
||||
project(unit_tests)
|
||||
|
||||
include(GoogleTest)
|
||||
add_executable(unit-tests
|
||||
general/unit_test_prediction.cpp
|
||||
general/unit_test_matrix.cpp
|
||||
general/unit_test_mat.cpp
|
||||
general/unit_test_a_star.cpp
|
||||
general/unit_test_projection.cpp
|
||||
general/unit_test_vector3.cpp
|
||||
general/unit_test_vector2.cpp
|
||||
general/unit_test_color.cpp
|
||||
general/unit_test_vector4.cpp
|
||||
general/unit_test_line_trace.cpp
|
||||
general/unit_test_angles.cpp
|
||||
general/unit_test_view_angles.cpp
|
||||
general/unit_test_angle.cpp
|
||||
general/unit_test_triangle.cpp
|
||||
general/unit_test_box_primitive.cpp
|
||||
|
||||
engines/unit_test_open_gl.cpp
|
||||
engines/unit_test_unity_engine.cpp
|
||||
engines/unit_test_source_engine.cpp
|
||||
engines/unit_test_iw_engine.cpp
|
||||
file(GLOB_RECURSE UNIT_TESTS_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
||||
add_executable(unit_tests ${UNIT_TESTS_SOURCES})
|
||||
|
||||
)
|
||||
|
||||
set_target_properties(unit-tests PROPERTIES
|
||||
set_target_properties(unit_tests PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||
UNITY_BUILD ON
|
||||
@@ -36,6 +16,6 @@ set_target_properties(unit-tests PROPERTIES
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath::omath)
|
||||
target_link_libraries(unit_tests PRIVATE gtest gtest_main omath::omath)
|
||||
|
||||
gtest_discover_tests(unit-tests)
|
||||
gtest_discover_tests(unit_tests)
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <omath/engines/unity_engine/camera.hpp>
|
||||
#include <omath/engines/unity_engine/constants.hpp>
|
||||
#include <omath/engines/unity_engine/formulas.hpp>
|
||||
|
||||
#include <print>
|
||||
|
||||
TEST(UnitTestUnityEngine, ForwardVector)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user