diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index d9061a6..60bd937 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -37,7 +37,7 @@ jobs: - name: Run Tests shell: bash working-directory: ${{github.workspace}}/build - run: ./run_test + run: ./tests/run_test # release: # needs: build-and-test diff --git a/CMakeLists.txt b/CMakeLists.txt index 81dcc18..14264a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,28 @@ -set(CMAKE_BUILD_TYPE Debug) -set(CMAKE_CXX_FLAGS_DEBUG "-g") +cmake_minimum_required(VERSION 3.15) +project(CPhysic VERSION 0.0.1 LANGUAGES CXX) -cmake_minimum_required(VERSION 3.10) -project(CPhysic) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_CXX_EXTENSIONS OFF) include_directories( - sources - sources/math - sources/physic - includes - includes/math - includes/physic + ${CMAKE_SOURCE_DIR}/includes + ${CMAKE_SOURCE_DIR}/includes/math + ${CMAKE_SOURCE_DIR}/includes/physic ) -file(GLOB_RECURSE SRCS - "sources/*.cpp" - "sources/math/*.cpp" -) +# file(GLOB_RECURSE APP_SRC +# "sources/*.cpp" +# "sources/math/*.cpp" +# "sources/physic/*.cpp" +# ) +# add_executable(cphysic ${APP_SRC}) +# target_include_directories(cphysic PUBLIC +# ${CMAKE_SOURCE_DIR}/includes +# ${CMAKE_SOURCE_DIR}/includes/math +# ${CMAKE_SOURCE_DIR}/includes/physic +# ) -# add_executable(cphysic ${SRCS} "main.cpp") +add_subdirectory(tests) enable_testing() -find_package(GTest REQUIRED) -include(GoogleTest) - -include_directories(${GTEST_INCLUDE_DIRS}) - -file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS - "tests/*.cpp" -) - -add_executable( - run_test - ${TEST_SOURCES} - ${SRCS} -) - -target_link_libraries( - run_test - GTest::gtest_main - # GTest::Main - # pthread -) - -add_test(NAME run_test COMMAND run_test) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..c1ed3de --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,42 @@ +find_package(GTest REQUIRED) +# include(GoogleTest) + +# set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST) + +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}") +message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") +message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + +file(GLOB_RECURSE PROJECT_SRCS + "${CMAKE_SOURCE_DIR}/sources/*.cpp" + "${CMAKE_SOURCE_DIR}/sources/math/*.cpp" + "${CMAKE_SOURCE_DIR}/sources/physic/*.cpp" # Ensure this path is correct +) + +file(GLOB_RECURSE TEST_SRCS CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/math/*.cpp" # Look for .cpp files directly in the 'tests' directory + "${CMAKE_CURRENT_SOURCE_DIR}/geometry/*.cpp" # Look for .cpp files directly in the 'tests' directory + "${CMAKE_CURRENT_SOURCE_DIR}/physic/*.cpp" # Look for .cpp files directly in the 'tests' directory +) + +add_executable( + run_test + ${TEST_SRCS} + ${PROJECT_SRCS} +) + +target_link_libraries( + run_test + GTest::gtest_main +) + +target_include_directories(run_test PUBLIC + ${CMAKE_SOURCE_DIR}/includes + ${CMAKE_SOURCE_DIR}/includes/math + ${CMAKE_SOURCE_DIR}/includes/physic +) + +gtest_discover_tests( + run_test + PROPERTIES VERBOSE 1 +) diff --git a/tests/test_collision.cpp b/tests/geometry/box_collision.cpp similarity index 100% rename from tests/test_collision.cpp rename to tests/geometry/box_collision.cpp diff --git a/tests/test_collision_3.cpp b/tests/geometry/sphere_box_collision.cpp similarity index 100% rename from tests/test_collision_3.cpp rename to tests/geometry/sphere_box_collision.cpp diff --git a/tests/test_collision_2.cpp b/tests/geometry/sphere_collision.cpp similarity index 100% rename from tests/test_collision_2.cpp rename to tests/geometry/sphere_collision.cpp diff --git a/tests/test_matrix.cpp b/tests/math/matrix_op.cpp similarity index 100% rename from tests/test_matrix.cpp rename to tests/math/matrix_op.cpp diff --git a/tests/test_conversion.cpp b/tests/math/matrix_quaternion_conv.cpp similarity index 100% rename from tests/test_conversion.cpp rename to tests/math/matrix_quaternion_conv.cpp diff --git a/tests/test_quat4.cpp b/tests/math/quaternion_op.cpp similarity index 100% rename from tests/test_quat4.cpp rename to tests/math/quaternion_op.cpp diff --git a/tests/test_vec3.cpp b/tests/math/vec3_op.cpp similarity index 100% rename from tests/test_vec3.cpp rename to tests/math/vec3_op.cpp diff --git a/tests/test_vec4.cpp b/tests/math/vec4_op.cpp similarity index 100% rename from tests/test_vec4.cpp rename to tests/math/vec4_op.cpp diff --git a/tests/test_geometry_inertia.cpp b/tests/physic/parallel_axis_theorem.cpp similarity index 100% rename from tests/test_geometry_inertia.cpp rename to tests/physic/parallel_axis_theorem.cpp diff --git a/tests/test_movements.cpp b/tests/physic/singleton_linear_motion.cpp similarity index 100% rename from tests/test_movements.cpp rename to tests/physic/singleton_linear_motion.cpp