From 8bff94922ccb29a5bbbfd778d4f7c44042fc4e5c Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 23 Oct 2023 12:19:21 +0200 Subject: [PATCH] [cmake] Patch metis. --- scripts/cmake/Dependencies.cmake | 6 ++- scripts/cmake/metis.patch | 63 ++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 scripts/cmake/metis.patch diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index 2d3be267fbe..e172a40e70d 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -356,13 +356,16 @@ if(OGS_BUILD_UTILS) GIT_REPOSITORY https://github.com/KarypisLab/GKlib GIT_TAG 8bd6bad750b2b0d90800c632cf18e8ee93ad72d7 VERSION 5.1.1 + OPTIONS "CMAKE_POLICY_DEFAULT_CMP0042 NEW" EXCLUDE_FROM_ALL YES ) CPMFindPackage( NAME metis GIT_REPOSITORY https://github.com/KarypisLab/METIS VERSION 5.2.1 - EXCLUDE_FROM_ALL YES + EXCLUDE_FROM_ALL + YES PATCH_COMMAND git apply + ${PROJECT_SOURCE_DIR}/scripts/cmake/metis.patch ) if(GKlib_ADDED AND metis_ADDED) target_include_directories( @@ -372,6 +375,7 @@ if(OGS_BUILD_UTILS) target_compile_definitions( metis PUBLIC IDXTYPEWIDTH=64 REALTYPEWIDTH=32 ) + list(APPEND DISABLE_WARNINGS_TARGETS metis) endif() else() find_package(metis REQUIRED) diff --git a/scripts/cmake/metis.patch b/scripts/cmake/metis.patch new file mode 100644 index 00000000000..bc5e40a8e61 --- /dev/null +++ b/scripts/cmake/metis.patch @@ -0,0 +1,63 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a15d19a..7a505dc 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -37,7 +37,7 @@ include(./conf/gkbuild.cmake) + + # Add include directories. + # i.e., the -I equivalent +-include_directories(build/xinclude) ++#include_directories(build/xinclude) + include_directories(${GKLIB_PATH}/include) + include_directories(${CMAKE_INSTALL_PREFIX}/include) + +@@ -47,6 +47,6 @@ link_directories(${GKLIB_PATH}/lib) + link_directories(${CMAKE_INSTALL_PREFIX}/lib) + + # Recursively look for CMakeLists.txt in subdirs. +-add_subdirectory("build/xinclude") ++#add_subdirectory("build/xinclude") + add_subdirectory("libmetis") + add_subdirectory("programs") +diff --git a/conf/gkbuild.cmake b/conf/gkbuild.cmake +index 0e70a8e..3ce5ae7 100644 +--- a/conf/gkbuild.cmake ++++ b/conf/gkbuild.cmake +@@ -126,7 +126,7 @@ if(MSVC) + if("${HAVE_THREADLOCALSTORAGE}" MATCHES "^${HAVE_THREADLOCALSTORAGE}$") + try_compile(HAVE_THREADLOCALSTORAGE + ${CMAKE_BINARY_DIR} +- ${CMAKE_SOURCE_DIR}/conf/check_thread_storage.c) ++ ${PROJECT_SOURCE_DIR}/conf/check_thread_storage.c) + if(HAVE_THREADLOCALSTORAGE) + message(STATUS "checking for thread-local storage - found") + else() +diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt +index baf40ad..67e93a2 100644 +--- a/programs/CMakeLists.txt ++++ b/programs/CMakeLists.txt +@@ -11,7 +11,10 @@ add_executable(cmpfillin cmpfillin.c io.c smbfactor.c) + + # Link with the required libraries + foreach(prog gpmetis ndmetis mpmetis m2gmetis graphchk cmpfillin) +- target_link_libraries(${prog} metis GKlib m) ++ target_link_libraries(${prog} metis GKlib) ++ if(NOT WIN32) ++ target_link_libraries(${prog} m) ++ endif() + endforeach(prog) + + if(METIS_INSTALL) +diff --git a/programs/mpmetis.c b/programs/mpmetis.c +index 04a6a1b..af74de9 100644 +--- a/programs/mpmetis.c ++++ b/programs/mpmetis.c +@@ -188,7 +188,7 @@ void MPReportResults(params_t *params, mesh_t *mesh, idx_t *epart, idx_t *npart, + printf("\nMemory Information ----------------------------------------------------------\n"); + printf(" Max memory used:\t\t %7.3"PRREAL" MB\n", (real_t)(params->maxmemory/(1024.0*1024.0))); + +-#ifndef MACOS ++#if !defined(MACOS) && !defined(WIN32) && !defined(__MINGW32__) + { + struct rusage usage; + getrusage(RUSAGE_SELF, &usage);