From 998c8f3a4331eb875ca62441220f7631562d79c0 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 30 Apr 2025 21:26:25 +0300 Subject: [PATCH] improved cmake, removed useless cmake files --- CMakeLists.txt | 44 +++++++++++---------- source/3d_primitives/CMakeLists.txt | 1 - source/CMakeLists.txt | 11 ------ source/collision/CMakeLists.txt | 3 -- source/engines/CMakeLists.txt | 4 -- source/engines/iw_engine/CMakeLists.txt | 1 - source/engines/opengl_engine/CMakeLists.txt | 1 - source/engines/source_engine/CMakeLists.txt | 1 - source/engines/unity_engine/CMakeLists.txt | 1 - source/pathfinding/CMakeLists.txt | 1 - source/projectile_prediction/CMakeLists.txt | 1 - source/projection/CMakeLists.txt | 1 - tests/CMakeLists.txt | 32 +++------------ tests/engines/unit_test_unity_engine.cpp | 2 +- 14 files changed, 30 insertions(+), 74 deletions(-) delete mode 100644 source/3d_primitives/CMakeLists.txt delete mode 100644 source/CMakeLists.txt delete mode 100644 source/collision/CMakeLists.txt delete mode 100644 source/engines/CMakeLists.txt delete mode 100644 source/engines/iw_engine/CMakeLists.txt delete mode 100644 source/engines/opengl_engine/CMakeLists.txt delete mode 100644 source/engines/source_engine/CMakeLists.txt delete mode 100644 source/engines/unity_engine/CMakeLists.txt delete mode 100644 source/pathfinding/CMakeLists.txt delete mode 100644 source/projectile_prediction/CMakeLists.txt delete mode 100644 source/projection/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dfad3e..d4190b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,15 +11,19 @@ option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF) option(OMATH_USE_AVX2 "Omath will use AVX2 to boost performance" ON) option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types to imgui types" OFF) option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" OFF) -option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF) +option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF) 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$<$: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 diff --git a/source/3d_primitives/CMakeLists.txt b/source/3d_primitives/CMakeLists.txt deleted file mode 100644 index ef4e0a4..0000000 --- a/source/3d_primitives/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE box.cpp) \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt deleted file mode 100644 index 1053134..0000000 --- a/source/CMakeLists.txt +++ /dev/null @@ -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) \ No newline at end of file diff --git a/source/collision/CMakeLists.txt b/source/collision/CMakeLists.txt deleted file mode 100644 index 09b4793..0000000 --- a/source/collision/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -target_sources(omath PRIVATE - line_tracer.cpp -) diff --git a/source/engines/CMakeLists.txt b/source/engines/CMakeLists.txt deleted file mode 100644 index aea648a..0000000 --- a/source/engines/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_subdirectory(source_engine) -add_subdirectory(opengl_engine) -add_subdirectory(iw_engine) -add_subdirectory(unity_engine) \ No newline at end of file diff --git a/source/engines/iw_engine/CMakeLists.txt b/source/engines/iw_engine/CMakeLists.txt deleted file mode 100644 index e5e9741..0000000 --- a/source/engines/iw_engine/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE camera.cpp formulas.cpp) \ No newline at end of file diff --git a/source/engines/opengl_engine/CMakeLists.txt b/source/engines/opengl_engine/CMakeLists.txt deleted file mode 100644 index e5e9741..0000000 --- a/source/engines/opengl_engine/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE camera.cpp formulas.cpp) \ No newline at end of file diff --git a/source/engines/source_engine/CMakeLists.txt b/source/engines/source_engine/CMakeLists.txt deleted file mode 100644 index e5e9741..0000000 --- a/source/engines/source_engine/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE camera.cpp formulas.cpp) \ No newline at end of file diff --git a/source/engines/unity_engine/CMakeLists.txt b/source/engines/unity_engine/CMakeLists.txt deleted file mode 100644 index 5da7def..0000000 --- a/source/engines/unity_engine/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE formulas.cpp camera.cpp) \ No newline at end of file diff --git a/source/pathfinding/CMakeLists.txt b/source/pathfinding/CMakeLists.txt deleted file mode 100644 index e7cc7b9..0000000 --- a/source/pathfinding/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE navigation_mesh.cpp a_star.cpp) \ No newline at end of file diff --git a/source/projectile_prediction/CMakeLists.txt b/source/projectile_prediction/CMakeLists.txt deleted file mode 100644 index 1f189f7..0000000 --- a/source/projectile_prediction/CMakeLists.txt +++ /dev/null @@ -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) \ No newline at end of file diff --git a/source/projection/CMakeLists.txt b/source/projection/CMakeLists.txt deleted file mode 100644 index 1ca3a27..0000000 --- a/source/projection/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(omath PRIVATE camera.cpp) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5f1c8e0..b72c677 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) \ No newline at end of file +gtest_discover_tests(unit_tests) \ No newline at end of file diff --git a/tests/engines/unit_test_unity_engine.cpp b/tests/engines/unit_test_unity_engine.cpp index 7fb95a2..b5a5e8e 100644 --- a/tests/engines/unit_test_unity_engine.cpp +++ b/tests/engines/unit_test_unity_engine.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include TEST(UnitTestUnityEngine, ForwardVector) {