Skip to content

Commit fd1b555

Browse files
committed
Add version handling, still need to modify CMakeLsists of METIS repo + add GKlib macro in generated header
1 parent 6aa0f8c commit fd1b555

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

tests/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ set(SOURCE_FILES
77
)
88

99
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
10+
sofa_find_package(metis REQUIRED)
11+
12+
if(NOT TARGET metis)
13+
string(REPLACE "." "_" METIS_VERSION "${Metis_VERSION}")
14+
else ()
15+
get_target_property(METIS_VERSION metis VERSION )
16+
string(REPLACE "." "_" METIS_VERSION "${METIS_VERSION}")
17+
endif ()
18+
19+
#TODO NEED TO CHANGE
20+
#set_target_properties(${PROJECT_NAME} PROPERTIES
21+
# VERSION 5.2.1
22+
# FRAMEWORK TRUE
23+
# PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/include/metis.h)
24+
#In all METIS CMakeLists files of all branch
25+
26+
27+
target_compile_definitions( ${PROJECT_NAME} PUBLIC METIS_VERSION_${METIS_VERSION})
1028

1129
target_link_libraries(${PROJECT_NAME} Sofa.Testing Sofa.Metis)
1230
target_link_libraries(${PROJECT_NAME} metis)

tests/testMetis.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern "C" {
88
#include <metis.h>
99
}
1010

11+
1112
/**
1213
* This test is a substep of the SparseLDLSolver.MatrixFactorization test
1314
* It verifies a call of a METIS function.
@@ -17,13 +18,15 @@ extern "C" {
1718
TEST(Metis, permutation)
1819
{
1920
int n = 15;
20-
2121
//input
2222
sofa::type::vector<int> xadj
2323
{ 0, 0, 0, 0, 3, 6, 7, 10, 14, 16, 16, 18, 20, 20, 21, 22 };
2424
sofa::type::vector<int> adj
2525
{ 4,6,7,3,6,7,8,3,4,7,3,4,6,10,5,11,7,13,8,14,10,11 };
2626

27+
#ifdef METIS_VERSION_5_1_0
28+
29+
2730
//output
2831
sofa::type::vector<int> perm(n);
2932
sofa::type::vector<int> invperm(n);
@@ -38,6 +41,12 @@ TEST(Metis, permutation)
3841

3942
EXPECT_EQ(perm, expectedPerm);
4043
EXPECT_EQ(invperm, expectedInvPerm);
44+
#endif
45+
46+
#ifdef METIS_VERSION_5_2_1
47+
48+
#endif
49+
4150
}
4251

4352

@@ -102,6 +111,9 @@ TEST(SparseLDLSolver, MatrixFactorization)
102111
solver->init();
103112
solver->invert(matrix);
104113

114+
#ifdef METIS_VERSION_5_1_0
115+
116+
105117
auto* genericInvertData = solver->getMatrixInvertData(&matrix);
106118
EXPECT_NE(genericInvertData, nullptr);
107119

@@ -160,4 +172,10 @@ TEST(SparseLDLSolver, MatrixFactorization)
160172

161173
static const sofa::type::vector<int> expected_LT_colptr_Values { 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 4, 4, 5, 7, 11 };
162174
EXPECT_EQ(invertData->LT_colptr, expected_LT_colptr_Values);
175+
176+
#endif
177+
178+
#ifdef METIS_VERSION_5_2_1
179+
180+
#endif
163181
}

0 commit comments

Comments
 (0)