Skip to content

Commit d247d63

Browse files
committed
modern CMake autobuild METIS
1 parent 8ee6a37 commit d247d63

File tree

9 files changed

+258
-150
lines changed

9 files changed

+258
-150
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.c"
7+
- "**.cmake"
8+
- "**/CMakeLists.txt"
9+
- ".github/workflows/ci.yml"
10+
11+
jobs:
12+
13+
unix:
14+
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest]
18+
intsize: [32, 64]
19+
20+
runs-on: ${{ matrix.os }}
21+
timeout-minutes: 5
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- run: cmake -B build -DIDXTYPEWIDTH=${{ matrix.intsize }}
27+
- run: cmake --build build --parallel
28+
29+
- run: ctest --test-dir build -V
30+
31+
32+
windows_msvc:
33+
runs-on: windows-latest
34+
timeout-minutes: 5
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- run: cmake -B build
40+
41+
- run: cmake --build build --config Release --parallel
42+
43+
- run: ctest --test-dir build -C Release -V

.gitmodules

Whitespace-only changes.

CMakeLists.txt

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
cmake_minimum_required(VERSION 2.8)
2-
project(ParMETIS C)
1+
cmake_minimum_required(VERSION 3.14...3.28)
2+
project(ParMETIS LANGUAGES C)
33

4+
# --- need METIS first
5+
include(FetchContent)
46

5-
# Search for MPI.
6-
# GK commented this out as it seems to be creating problems
7-
# include(FindMPI)
8-
# if(NOT MPI_FOUND)
9-
# message(FATAL_ERROR "mpi is not found")
10-
# endif()
11-
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_COMPILE_FLAGS}")
7+
FetchContent_Declare(GKlib
8+
GIT_REPOSITORY https://github.com/scivision/GKlib.git
9+
GIT_TAG 44630ca
10+
GIT_SHALLOW true
11+
)
12+
FetchContent_MakeAvailable(GKlib)
1213

14+
FetchContent_Declare(metis_fc
15+
GIT_REPOSITORY https://github.com/scivision/metis.git
16+
GIT_TAG fd7799b
17+
GIT_SHALLOW true
18+
)
1319

14-
# Prepare libraries.
15-
if(SHARED)
16-
set(ParMETIS_LIBRARY_TYPE SHARED)
17-
else()
18-
set(ParMETIS_LIBRARY_TYPE STATIC)
20+
FetchContent_MakeAvailable(metis_fc)
21+
22+
if(NOT DEFINED REALTYPEWIDTH)
23+
set(REALTYPEWIDTH 32)
24+
endif()
25+
if(NOT DEFINED IDXTYPEWIDTH)
26+
set(IDXTYPEWIDTH 32)
1927
endif()
28+
add_compile_definitions(REALTYPEWIDTH=${REALTYPEWIDTH} IDXTYPEWIDTH=${IDXTYPEWIDTH})
29+
30+
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}
31+
REALTYPEWIDTH=${REALTYPEWIDTH} IDXTYPEWIDTH=${IDXTYPEWIDTH}")
32+
message(STATUS "METIS ${metis_fc_SOURCE_DIR}")
33+
message(STATUS "GKlib ${gklib_SOURCE_DIR}")
34+
35+
find_package(MPI REQUIRED)
2036

2137
include(./conf/gkbuild.cmake)
2238

23-
# List of paths that the compiler will search for header files.
24-
# i.e., the -I equivalent
25-
include_directories(include)
26-
include_directories(${MPI_INCLUDE_PATH})
27-
include_directories(${GKLIB_PATH}/include)
28-
include_directories(${METIS_PATH}/include)
29-
include_directories(${CMAKE_INSTALL_PREFIX}/include)
30-
31-
# List of paths that the compiler will search for library files.
32-
# i.e., the -L equivalent
33-
link_directories(${GKLIB_PATH}/lib)
34-
link_directories(${METIS_PATH}/lib)
35-
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
36-
37-
# List of directories that cmake will look for CMakeLists.txt
38-
add_subdirectory(include)
39+
install(FILES include/parmetis.h TYPE INCLUDE)
40+
3941
add_subdirectory(libparmetis)
4042
add_subdirectory(programs)
4143

CMakePresets.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"version": 6,
3+
4+
"configurePresets": [
5+
{
6+
"name": "default",
7+
"binaryDir": "${sourceDir}/build",
8+
"cacheVariables": {
9+
"CMAKE_COMPILE_WARNING_AS_ERROR": true
10+
}
11+
},
12+
{
13+
"name": "msvc", "inherits": "default",
14+
"generator": "Visual Studio 17 2022",
15+
"cacheVariables": {
16+
"CMAKE_COMPILE_WARNING_AS_ERROR": false
17+
}
18+
}
19+
],
20+
"buildPresets": [
21+
{
22+
"name": "default",
23+
"configurePreset": "default"
24+
},
25+
{
26+
"name": "release",
27+
"configurePreset": "default",
28+
"configuration": "Release"
29+
},
30+
{
31+
"name": "msvc-debug",
32+
"configurePreset": "msvc",
33+
"configuration": "Debug"
34+
}
35+
],
36+
"testPresets": [
37+
{
38+
"name": "default",
39+
"configurePreset": "default",
40+
"output": {
41+
"outputOnFailure": true,
42+
"verbosity": "verbose"
43+
},
44+
"execution": {
45+
"noTestsAction": "error",
46+
"scheduleRandom": true,
47+
"stopOnFailure": false,
48+
"timeout": 60
49+
}
50+
},
51+
{
52+
"name": "release", "inherits": "default",
53+
"configuration": "Release"
54+
},
55+
{
56+
"name": "msvc-debug", "inherits": "default",
57+
"configurePreset": "msvc",
58+
"configuration": "Debug"
59+
}
60+
],
61+
"workflowPresets": [
62+
{
63+
"name": "default",
64+
"steps": [
65+
{
66+
"type": "configure",
67+
"name": "default"
68+
},
69+
{
70+
"type": "build",
71+
"name": "default"
72+
}
73+
]
74+
},
75+
{
76+
"name": "msvc",
77+
"steps": [
78+
{
79+
"type": "configure",
80+
"name": "msvc"
81+
},
82+
{
83+
"type": "build",
84+
"name": "msvc-debug"
85+
}
86+
]
87+
},
88+
{
89+
"name": "release",
90+
"steps": [
91+
{
92+
"type": "configure",
93+
"name": "default"
94+
},
95+
{
96+
"type": "build",
97+
"name": "release"
98+
}
99+
]
100+
}
101+
]
102+
}

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# ParMETIS
1+
# ParMETIS
22

3-
ParMETIS is an MPI-based library for partitioning graphs, partitioning finite element meshes,
4-
and producing fill reducing orderings for sparse matrices. The algorithms implemented in
5-
ParMETIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint
3+
ParMETIS is an MPI-based library for partitioning graphs, partitioning finite element meshes,
4+
and producing fill reducing orderings for sparse matrices. The algorithms implemented in
5+
ParMETIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint
66
partitioning schemes developed in our lab.
77

8-
## Downloading ParMETIS
8+
## Downloading ParMETIS
99

1010
You can download ParMETIS by simply cloning it using the command:
1111
```
@@ -18,20 +18,20 @@ To build ParMETIS you can follow the instructions below:
1818

1919
### Dependencies
2020

21-
General dependencies for building ParMETIS are: gcc, cmake, build-essential, and an MPI library.
22-
In Ubuntu systems these can be obtained from the apt package manager (e.g., apt-get install cmake, mpich, etc)
21+
General dependencies for building ParMETIS are: gcc, cmake, build-essential, and an MPI library.
22+
In Ubuntu systems these can be obtained from the apt package manager (e.g., apt-get install cmake, mpich, etc)
2323

2424
```
2525
sudo apt-get install build-essential
2626
sudo apt-get install cmake
2727
```
2828

2929
In addition, you need to download and install
30-
[GKlib](https://github.com/KarypisLab/GKlib) and
31-
[METIS](https://github.com/KarypisLab/METIS) by following the instructions there.
30+
[GKlib](https://github.com/KarypisLab/GKlib) and
31+
[METIS](https://github.com/KarypisLab/METIS) by following the instructions there.
3232

3333

34-
### Building and installing ParMETIS
34+
### Building and installing ParMETIS
3535

3636
ParMETIS is primarily configured by passing options to make config. For example:
3737

@@ -40,7 +40,7 @@ make config cc=mpicc prefix=~/local
4040
make install
4141
```
4242

43-
will configure ParMETIS to be built using mpicc and then install the binaries, header files, and libraries at
43+
will configure ParMETIS to be built using mpicc and then install the binaries, header files, and libraries at
4444

4545
```
4646
~/local/bin
@@ -78,15 +78,12 @@ directories, respectively.
7878
make distclean
7979
Performs clean and completely removes the build directory.
8080

81-
8281
### Definitions of supported data types
8382

8483
ParMETIS uses the same data types for integers and floating point numbers (32/64 bit
8584
integers and single/double precision floating point numbers) as used when configuring
8685
and building METIS.
8786

88-
8987
## Copyright & License Notice
90-
Copyright 1998-2020, Regents of the University of Minnesota
91-
9288

89+
Copyright 1998-2020, Regents of the University of Minnesota

0 commit comments

Comments
 (0)