Skip to content

Commit

Permalink
METIS 5.2.1 upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 8, 2023
1 parent 9878ee7 commit 47927ed
Show file tree
Hide file tree
Showing 140 changed files with 3,308 additions and 365,417 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: cmake -B build -Dintsize=${{ matrix.intsize }}
- run: cmake -B build -DIDXTYPEWIDTH=${{ matrix.intsize }}
- run: cmake --build build --parallel

- run: ctest --test-dir build -V
Expand Down
48 changes: 22 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,41 @@ endif()

project(METIS
LANGUAGES C
VERSION 5.1.0.4
VERSION 5.2.1.1
)
# based on upstream e0f1b88b8efcb24ffa0ec55eabb78fbe61e58ae7

enable_testing()

option(BUILD_TESTING "Build METIS self-tests" ON)

if(NOT intsize)
set(intsize 32)
endif()
if(NOT realsize)
set(realsize 32)
endif()

include(FetchContent)

set(GKLIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/GKlib CACHE PATH "path to GKlib")
FetchContent_Declare(GKlib
GIT_REPOSITORY https://github.com/scivision/GKlib.git
GIT_TAG 44630ca
GIT_SHALLOW true
)
FetchContent_MakeAvailable(GKlib)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
option(BUILD_TESTING "Build METIS self-tests" ON)

set(CMAKE_C_STANDARD 99)

# Configure libmetis library.
if(BUILD_SHARED_LIBS)
set(METIS_LIBRARY_TYPE SHARED)
else()
set(METIS_LIBRARY_TYPE STATIC)
if(NOT DEFINED REALTYPEWIDTH)
set(REALTYPEWIDTH 32)
endif()
if(NOT DEFINED IDXTYPEWIDTH)
set(IDXTYPEWIDTH 32)
endif()
add_compile_definitions(REALTYPEWIDTH=${REALTYPEWIDTH} IDXTYPEWIDTH=${IDXTYPEWIDTH})

include(conf/gkbuild.cmake)

install(FILES include/metis.h TYPE INCLUDE)

include(${GKLIB_PATH}/GKlibSystem.cmake)
# Add include directories.
#include_directories(${GKLIB_PATH})
# Recursively look for CMakeLists.txt in subdirs.
add_subdirectory(include)
add_subdirectory(libmetis)
add_subdirectory(programs)

add_test(NAME GraphCheck
COMMAND $<TARGET_FILE:graphchk> ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/tiny_01.graph)
# add_test(NAME GraphCheck
# COMMAND $<TARGET_FILE:graphchk> ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/tiny_01.graph)

file(GENERATE OUTPUT .gitignore CONTENT "*")
114 changes: 114 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"version": 6,

"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
},
{
"name": "msvc", "inherits": "default",
"generator": "Visual Studio 17 2022",
"cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": false
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "release",
"configurePreset": "default",
"configuration": "Release"
},
{
"name": "msvc-debug",
"configurePreset": "msvc",
"configuration": "Debug"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"outputOnFailure": true,
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error",
"scheduleRandom": true,
"stopOnFailure": false,
"timeout": 60
}
},
{
"name": "release", "inherits": "default",
"configuration": "Release"
},
{
"name": "msvc-debug", "inherits": "default",
"configurePreset": "msvc",
"configuration": "Debug"
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
},
{
"type": "test",
"name": "default"
}
]
},
{
"name": "msvc",
"steps": [
{
"type": "configure",
"name": "msvc"
},
{
"type": "build",
"name": "msvc-debug"
},
{
"type": "test",
"name": "msvc-debug"
}
]
},
{
"name": "release",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "release"
},
{
"type": "test",
"name": "release"
}
]
}
]
}
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@

![ci](https://github.com/scivision/METIS/workflows/ci/badge.svg)

Modernizes
[METIS 5.1.0](http://glaros.dtc.umn.edu/gkhome/metis/metis/download)
build system to work on Linux and MacOS and Windows Subsystem for Linux.

## Prereqs

A C99 compiler, such as GCC, Clang, Visual Studio, Intel oneAPI

## Build
Modernizes CMakeLists.txt to work across operating systems and compilers.

```sh
cmake -B build

cmake --build build --parallel
cmake --workflow --preset default
```

which creates `build/libmetis.a`
Expand All @@ -25,6 +15,6 @@ which creates `build/libmetis.a`
By default, metis.h uses 32-bit integer and real. Each can be independently set to 32 or 64 bits like:

```sh
cmake -Bbuild -Dintsize=64 -Drealsize=64
cmake -Bbuild -DIDXTYPEWIDTH=64 -DREALTYPEWIDTH=64
cmake --build build
```
File renamed without changes.
99 changes: 99 additions & 0 deletions conf/gkbuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Helper modules.
include(CheckFunctionExists)
include(CheckIncludeFile)

# Setup options.
option(OPENMP "enable OpenMP support" OFF)
option(PCRE "enable PCRE support" OFF)
option(GKREGEX "enable GKREGEX support" OFF)
option(GKRAND "enable GKRAND support" OFF)


# Add compiler flags.
if(MSVC)
set(GKlib_COPTIONS WIN32 MSC _CRT_SECURE_NO_DEPRECATE USE_GKREGEX)
elseif(WIN32)
set(GKlib_COPTIONS USE_GKREGEX)
else()
set(GKlib_COPTIONS LINUX FILE_OFFSET_BITS=64)
endif(MSVC)

if(CYGWIN)
list(APPEND GKlib_COPTIONS CYGWIN)
endif()

if(APPLE)
list(APPEND GKlib_COPTIONS MACOS)
endif()

if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND GKlib_COPTS -fno-strict-aliasing -Werror -Wall -pedantic -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label)
endif()

if(UNIX)
include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE true)
endif()

# Find OpenMP if it is requested.
if(OPENMP)
find_package(OpenMP REQUIRED)
list(APPEND GKlib_COPTIONS __OPENMP__)
endif()

# Set the CPU type
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
list(APPEND GKlib_COPTIONS NO_X86=1)
endif()

# Add various options
if(PCRE)
list(APPEND GKlib_COPTIONS __WITHPCRE__)
endif()

if(GKREGEX)
list(APPEND GKlib_COPTIONS USE_GKREGEX)
endif()

if(GKRAND)
list(APPEND GKlib_COPTIONS USE_GKRAND)
endif()


# Check for features.
check_include_file(execinfo.h HAVE_EXECINFO_H)
if(HAVE_EXECINFO_H)
list(APPEND GKlib_COPTIONS HAVE_EXECINFO_H)
endif(HAVE_EXECINFO_H)

check_function_exists(getline HAVE_GETLINE)
if(HAVE_GETLINE)
list(APPEND GKlib_COPTIONS HAVE_GETLINE)
endif(HAVE_GETLINE)


# Custom check for TLS.
if(MSVC)
list(APPEND GKlib_COPTIONS __thread=__declspec(thread))

# This if checks if that value is cached or not.
if("${HAVE_THREADLOCALSTORAGE}" MATCHES "^${HAVE_THREADLOCALSTORAGE}$")
message(CHECK_START "checking for thread-local storage")
try_compile(HAVE_THREADLOCALSTORAGE
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_LIST_DIR}/check_thread_storage.c)
if(HAVE_THREADLOCALSTORAGE)
message(CHECK_PASS "found")
else()
message(CHECK_FAIL "not found")
endif()
endif()
if(NOT HAVE_THREADLOCALSTORAGE)
list(APPEND GKlib_COPTIONS __thread=)
endif()
endif()

# Finally set the official C flags.
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${GKlib_COPTS}>")
add_compile_definitions("$<$<COMPILE_LANGUAGE:C>:${GKlib_COPTIONS}>")
3 changes: 0 additions & 3 deletions include/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 47927ed

Please sign in to comment.