Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 18 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
42 changes: 42 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.