From 829147497cf3ea03446b90dc7c4f97637c0f27ef Mon Sep 17 00:00:00 2001 From: Edimar Valentin Date: Wed, 27 Aug 2025 20:29:55 -0700 Subject: [PATCH 1/3] cmake now better organized --- .github/workflows/cmake-single-platform.yml | 2 +- CMakeLists.txt | 49 +-------------------- test/CMakeLists.txt | 5 +++ test/dense_mread/CMakeLists.txt | 24 ++++++++++ test/sparse_mread/CMakeLists.txt | 24 ++++++++++ 5 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/dense_mread/CMakeLists.txt create mode 100644 test/sparse_mread/CMakeLists.txt diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml index 0ac33d9..c68a3ad 100644 --- a/.github/workflows/cmake-single-platform.yml +++ b/.github/workflows/cmake-single-platform.yml @@ -32,7 +32,7 @@ jobs: run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}}/build/test # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: ctest -C ${{env.BUILD_TYPE}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 9efd9db..eea4062 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,58 +7,11 @@ add_library(cmatrix STATIC src/sparse.c src/dense.c include/sparse.h include/dense.h - test/dense_mread/test_mread.c ) target_include_directories(cmatrix PUBLIC include) -# Enable testing -enable_testing() +add_subdirectory(test) -# Test executable for mread -add_executable(test_sparse_mread test/sparse_mread/test_mread.c) -target_link_libraries(test_sparse_mread PRIVATE cmatrix) -target_include_directories(test_sparse_mread PRIVATE include) -configure_file( - ${CMAKE_SOURCE_DIR}/test/sparse_mread/mread_input_0.txt - ${CMAKE_BINARY_DIR}/sparse_mread_input_0.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/sparse_mread/mread_input_1.txt - ${CMAKE_BINARY_DIR}/sparse_mread_input_1.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/sparse_mread/mread_input_2.txt - ${CMAKE_BINARY_DIR}/sparse_mread_input_2.txt - COPYONLY -) - -add_test(NAME test_sparse_mread COMMAND test_sparse_mread) -add_executable(test_dense_mread test/dense_mread/test_mread.c) -target_link_libraries(test_dense_mread PRIVATE cmatrix) -target_include_directories(test_dense_mread PRIVATE include) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/dense_mread/mread_input_0.txt; - ${CMAKE_BINARY_DIR}/dense_mread_input_0.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/dense_mread/mread_input_1.txt; - ${CMAKE_BINARY_DIR}/dense_mread_input_1.txt - COPYONLY -) - -configure_file( - ${CMAKE_SOURCE_DIR}/test/dense_mread/mread_input_2.txt; - ${CMAKE_BINARY_DIR}/dense_mread_input_2.txt - COPYONLY -) -add_test(NAME test_dense_mread COMMAND test_dense_mread) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..d346285 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,5 @@ +enable_testing() + +add_subdirectory(dense_mread) + +add_subdirectory(sparse_mread) \ No newline at end of file diff --git a/test/dense_mread/CMakeLists.txt b/test/dense_mread/CMakeLists.txt new file mode 100644 index 0000000..a5ee29f --- /dev/null +++ b/test/dense_mread/CMakeLists.txt @@ -0,0 +1,24 @@ +# Test executable for mread +add_executable(test_dense_mread test_mread.c) +target_link_libraries(test_dense_mread PRIVATE cmatrix) +target_include_directories(test_dense_mread PRIVATE include) + +configure_file( + mread_input_0.txt + dense_mread_input_0.txt + COPYONLY +) + +configure_file( + mread_input_1.txt + dense_mread_input_1.txt + COPYONLY +) + +configure_file( + mread_input_2.txt + dense_mread_input_2.txt + COPYONLY +) + +add_test(NAME test_dense_mread COMMAND test_dense_mread) diff --git a/test/sparse_mread/CMakeLists.txt b/test/sparse_mread/CMakeLists.txt new file mode 100644 index 0000000..b71c78d --- /dev/null +++ b/test/sparse_mread/CMakeLists.txt @@ -0,0 +1,24 @@ +# Test executable for mread +add_executable(test_sparse_mread test_mread.c) +target_link_libraries(test_sparse_mread PRIVATE cmatrix) +target_include_directories(test_sparse_mread PRIVATE include) + +configure_file( + mread_input_0.txt + sparse_mread_input_0.txt + COPYONLY +) + +configure_file( + mread_input_1.txt + sparse_mread_input_1.txt + COPYONLY +) + +configure_file( + mread_input_2.txt + sparse_mread_input_2.txt + COPYONLY +) + +add_test(NAME test_sparse_mread COMMAND test_sparse_mread) From f98685c3ddbdb8acb4bf69ea252773afe75c564b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edimar=20Valent=C3=ADn=20Kery?= Date: Sat, 30 Aug 2025 13:43:41 -0700 Subject: [PATCH 2/3] copilot: improved path Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- test/dense_mread/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dense_mread/CMakeLists.txt b/test/dense_mread/CMakeLists.txt index a5ee29f..321f908 100644 --- a/test/dense_mread/CMakeLists.txt +++ b/test/dense_mread/CMakeLists.txt @@ -1,7 +1,7 @@ # Test executable for mread add_executable(test_dense_mread test_mread.c) target_link_libraries(test_dense_mread PRIVATE cmatrix) -target_include_directories(test_dense_mread PRIVATE include) +target_include_directories(test_dense_mread PRIVATE ${CMAKE_SOURCE_DIR}/include) configure_file( mread_input_0.txt From f14fa49af1973af752607e38bf50deb1f7b6c04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edimar=20Valent=C3=ADn=20Kery?= Date: Sat, 30 Aug 2025 13:44:02 -0700 Subject: [PATCH 3/3] copilot: Update test/sparse_mread/CMakeLists.txt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- test/sparse_mread/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sparse_mread/CMakeLists.txt b/test/sparse_mread/CMakeLists.txt index b71c78d..3cc23f8 100644 --- a/test/sparse_mread/CMakeLists.txt +++ b/test/sparse_mread/CMakeLists.txt @@ -1,7 +1,7 @@ # Test executable for mread add_executable(test_sparse_mread test_mread.c) target_link_libraries(test_sparse_mread PRIVATE cmatrix) -target_include_directories(test_sparse_mread PRIVATE include) +target_include_directories(test_sparse_mread PRIVATE ${CMAKE_SOURCE_DIR}/include) configure_file( mread_input_0.txt