diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..159771b --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,29 @@ +name: CI + +on: + workflow_dispatch: + pull_request: + branches: [ master ] + push: + branches: [ master ] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + uses: ./.github/workflows/step_test.yaml + + pass: + needs: [ tests ] + runs-on: ubuntu-latest + steps: + - name: Check all CI jobs + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + if: always() diff --git a/.github/workflows/step_test.yaml b/.github/workflows/step_test.yaml new file mode 100644 index 0000000..15ee578 --- /dev/null +++ b/.github/workflows/step_test.yaml @@ -0,0 +1,62 @@ +name: test +run-name: Run tests + +on: + workflow_call: + +permissions: + contents: read + +jobs: + tests: + name: Check ${{ matrix.toolchain }} + runs-on: ${{ matrix.os || 'ubuntu-latest' }} + container: ${{ !matrix.os && 'ghcr.io/lecrisut/dev-env:main' || '' }} + continue-on-error: ${{ matrix.experimental || false }} + strategy: + fail-fast: false + matrix: + toolchain: [ gcc, llvm, intel, windows, macos ] + openmp: [ ON, OFF ] + include: + - os: windows-latest + toolchain: windows + # regex library is not available? + experimental: true + - os: macos-latest + toolchain: macos + - os: macos-latest + toolchain: macos + openmp: ON + # Need to find how to install openmp on macos + experimental: true + env: + WITH_OPENMP: ${{ matrix.openmp }} + steps: + - name: Enable msvc toolchain on windows + uses: ilammy/msvc-dev-cmd@v1 + if: contains(matrix.os, 'windows') + - name: Activate Intel compilers + # Not elegant, it will propagate all environment variable. + # Intel does not provide a way to output the environment variables to a file + # Note: PATH needs to be exported to GITHUB_PATH otherwise it can be overwritten + run: | + source /opt/intel/oneapi/setvars.sh + printenv >> $GITHUB_ENV + echo $PATH >> $GITHUB_PATH + if: matrix.toolchain == 'intel' + - uses: actions/checkout@v4 + - uses: lukka/get-cmake@latest + - name: Run CMake configuration for ${{ matrix.toolchain }} toolchain + uses: lukka/run-cmake@v10.3 + with: + workflowPreset: "${{ matrix.toolchain }}-ci" + pass: + needs: [ tests ] + runs-on: ubuntu-latest + steps: + - name: Check test jobs + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + if: always() diff --git a/.gitignore b/.gitignore index bf123be..424c5df 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,8 @@ graphs/*.npart.* GKlib .svn/ +include/metis.h + +### Project specific +CMakeUserPresets.json +cmake-build-* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/BUILD-Windows.txt b/BUILD-Windows.txt deleted file mode 100644 index feb77de..0000000 --- a/BUILD-Windows.txt +++ /dev/null @@ -1,52 +0,0 @@ -Building METIS requires CMake 2.8, found at -http://www.cmake.org/. CMake generates Visual Studio project files, -which then can be built using Visual Studio. There are two ways to -generate visual studio files: using the command line and using the -CMake GUI. - -Using the command line ----------------------- - -Open the command prompt and cd to the METIS source directory. Run - - > cmake --help - -and look at the list of generators for the Visual Studio studio you -want to build for. For example, the generator for Visual Studio 2010 -is called "Visual Studio 10". - -After you have found the appropriate generator, run - - > .\vsgen -G "" - -to generate the project files. The project files will be placed -build\windows. - -Finally, you need to manually uncomment the following two lines: - - //#define IDXTYPEWIDTH 32 - //#define REALTYPEWIDTH 32 - -To compile METIS with 64 bit integers or 64 bit floats, you also need -to set IDXTYPEWIDTH or REALTYPEWIDTH to 64. - -Using the CMake GUI -------------------- - -It is also possible to use the CMake GUI, distributed with CMake. To -do this, open the CMake GUI, and browse to the location of METIS' -source with the "Browse Source" button. You can also change the binary -directory. This is where the Visual Studio project files will be -placed. Click "Generate" to select the correct visual studio version -and build the project files. - -Using the VS project files --------------------------- - -The Visual Studio project will be called METIS.sln. Open it in Visual -Studio. If the configuration is not already "Release", set it to -"Release". Type F7 to build. The METIS library will be in -\libmetis\Release and the executable programs will be in -\programs\Release. ( will be build\windows if -you used the command line or whatever you choose if using the CMake -GUI.) diff --git a/CMakeLists.txt b/CMakeLists.txt index a15d19a..6cc77b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,52 +1,195 @@ -cmake_minimum_required(VERSION 2.8) -project(METIS C) - -set(SHARED FALSE CACHE BOOL "build a shared library") - -if(MSVC) - set(METIS_INSTALL FALSE) -else() - set(METIS_INSTALL TRUE) -endif() - -# Configure libmetis library. -if(SHARED) - set(METIS_LIBRARY_TYPE SHARED) -else() - set(METIS_LIBRARY_TYPE STATIC) -endif(SHARED) - -include(./conf/gkbuild.cmake) - -# METIS' custom options -#option(IDX64 "enable 64 bit ints" OFF) -#option(REAL64 "enable 64 bit floats (i.e., double)" OFF) -#if(IDX64) -# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=64") -#else() -# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=32") -#endif(IDX64) -#if(REAL64) -# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=64") -#else() -# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=32") -#endif(REAL64) -# -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${METIS_COPTIONS}") - - -# Add include directories. -# i.e., the -I equivalent -include_directories(build/xinclude) -include_directories(${GKLIB_PATH}/include) -include_directories(${CMAKE_INSTALL_PREFIX}/include) - -# List of paths that the compiler will search for library files. -# i.e., the -L equivalent -link_directories(${GKLIB_PATH}/lib) -link_directories(${CMAKE_INSTALL_PREFIX}/lib) - -# Recursively look for CMakeLists.txt in subdirs. -add_subdirectory("build/xinclude") -add_subdirectory("libmetis") -add_subdirectory("programs") +cmake_minimum_required(VERSION 3.15) +# CMake version compatibility +# TODO: Remove when cmake 3.25 is commonly distributed +if (POLICY CMP0140) + cmake_policy(SET CMP0140 NEW) +endif () + +#[==============================================================================================[ +# Basic project definition # +]==============================================================================================] + +list(APPEND CMAKE_MESSAGE_CONTEXT METIS) +project(METIS + VERSION 5.3.0 + DESCRIPTION "Serial Graph Partitioning and Fill-reducing Matrix Ordering" + HOMEPAGE_URL https://github.com/KarypisLab/METIS + LANGUAGES C +) + +# Back-porting to PROJECT_IS_TOP_LEVEL to older cmake +# TODO: Remove when requiring cmake >= 3.21 +if (NOT DEFINED Spglib_IS_TOP_LEVEL) + if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set(PROJECT_IS_TOP_LEVEL ON) + else () + set(PROJECT_IS_TOP_LEVEL OFF) + endif () +endif () + +# Specify C standard +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS ON) + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif () + +#[==============================================================================================[ +# Options # +]==============================================================================================] + +include(CMakeDependentOption) +include(FeatureSummary) +option(METIS_TESTS "METIS: Build unit tests" ${PROJECT_IS_TOP_LEVEL}) +option(METIS_SHARED_LIBS "METIS: Build as a shared library" ${PROJECT_IS_TOP_LEVEL}) +option(METIS_INSTALL "METIS: Install project" ${PROJECT_IS_TOP_LEVEL}) +option(METIS_OpenMP "METIS: Enable OpenMP support" OFF) +add_feature_info(METIS_OpenMP METIS_OpenMP "OpenMP support") +option(METIS_PROGRAMS "METIS: Build executable programs" OFF) +add_feature_info(METIS_PROGRAMS METIS_PROGRAMS "Build executable programs") +option(METIS_IDX64 "METIS: Build with 64 bit ints" OFF) +add_feature_info(METIS_IDX64 METIS_IDX64 "Build with 64 bit ints") +option(METIS_REAL64 "METIS: Build with 64 bit floats" OFF) +add_feature_info(METIS_REAL64 METIS_REAL64 "Build with 64 bit floats") + +#[==============================================================================================[ +# Project configuration # +]==============================================================================================] + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +# Add some helper functions +include(METIS) + +# Include basic tools +include(FetchContent) +if (METIS_INSTALL) + include(CMakePackageConfigHelpers) + if (UNIX) + include(GNUInstallDirs) + endif () +endif () + +# Define basic parameters +set(BUILD_SHARED_LIBS ${METIS_SHARED_LIBS}) + + +#[==============================================================================================[ +# External packages # +]==============================================================================================] + +set(gklib_find_package_args CONFIG) +if (METIS_OpenMP) + if (NOT COMPONENTS IN_LIST gklib_find_package_args) + list(APPEND gklib_find_package_args COMPONENTS) + endif () + list(APPEND gklib_find_package_args OpenMP) +endif () +FetchContent_Declare(GKlib + GIT_REPOSITORY https://github.com/LecrisUT/GKlib + GIT_TAG cmake/modernization + FIND_PACKAGE_ARGS ${gklib_find_package_args} +) +METIS_FetchContent_MakeAvailable(GKlib) + +include(METIS_PackagesInfo) + +feature_summary( + FILENAME ${CMAKE_CURRENT_BINARY_DIR}/METIS.info + VAR METIS_Info + DESCRIPTION "METIS supported libraries" + FATAL_ON_MISSING_REQUIRED_PACKAGES + WHAT ALL +) +message(STATUS ${METIS_Info}) + +#[==============================================================================================[ +# Main definition # +]==============================================================================================] + +# Main project +add_library(METIS_METIS) +set_target_properties(METIS_METIS PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + EXPORT_NAME METIS + OUTPUT_NAME metis +) +add_library(METIS::METIS ALIAS METIS_METIS) + +# Main definitions inside src +add_subdirectory(include) +add_subdirectory(src) + +# Testing +if (METIS_TESTS) + enable_testing() + add_subdirectory(test) +endif () + +#[==============================================================================================[ +# Install or Export # +]==============================================================================================] + +# Installation +if (METIS_INSTALL) + # pkg-config files + configure_file(cmake/metis.pc.in metis.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/metis.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + COMPONENT METIS_Development + ) + + # cmake export files + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/METISConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion + ) + configure_package_config_file( + cmake/METISConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/METISConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/METIS + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/METISConfigVersion.cmake + ${CMAKE_CURRENT_BINARY_DIR}/METISConfig.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/METIS + COMPONENT METIS_Development + ) + export(EXPORT METISTargets + FILE METISTargets.cmake + NAMESPACE METIS:: + ) + install(EXPORT METISTargets + FILE METISTargets.cmake + NAMESPACE METIS:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/METIS + COMPONENT METIS_Development + ) +endif () + +# Make project available for FetchContent +if (NOT PROJECT_IS_TOP_LEVEL) + # Propagate variables + if (CMAKE_VERSION VERSION_LESS 3.25) + # TODO: Remove when cmake 3.25 is commonly distributed + set(METIS_VERSION ${METIS_VERSION} PARENT_SCOPE) + set(METIS_VERSION_MAJOR ${METIS_VERSION_MAJOR} PARENT_SCOPE) + set(METIS_VERSION_MINOR ${METIS_VERSION_MINOR} PARENT_SCOPE) + set(METIS_VERSION_PATCH ${METIS_VERSION_PATCH} PARENT_SCOPE) + set(METIS_VERSION_TWEAK ${METIS_VERSION_TWEAK} PARENT_SCOPE) + set(METIS_IDXTYPEWIDTH ${METIS_IDXTYPEWIDTH} PARENT_SCOPE) + set(METIS_REALTYPEWIDTH ${METIS_REALTYPEWIDTH} PARENT_SCOPE) + else () + return(PROPAGATE + METIS_VERSION + METIS_VERSION_MAJOR + METIS_VERSION_MINOR + METIS_VERSION_PATCH + METIS_VERSION_TWEAK + METIS_IDXTYPEWIDTH + METIS_REALTYPEWIDTH + ) + endif () +endif () diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..3db1fed --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,12 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "include": [ + "cmake/CMakePresets-defaults.json", + "cmake/CMakePresets-CI.json" + ] +} diff --git a/Makefile b/Makefile deleted file mode 100644 index 8fe67e7..0000000 --- a/Makefile +++ /dev/null @@ -1,101 +0,0 @@ -# Configuration options. -i64 = not-set -r64 = not-set -gdb = not-set -assert = not-set -assert2 = not-set -debug = not-set -gprof = not-set -valgrind = not-set -openmp = not-set -shared = not-set -cc = not-set -prefix = ~/local -gklib_path = ~/local - - -# Basically proxies everything to the builddir cmake. - -BUILDDIR = build - -IDXWIDTH = "\#define IDXTYPEWIDTH 32" -REALWIDTH = "\#define REALTYPEWIDTH 32" - -# Process configuration options. -CONFIG_FLAGS = -DCMAKE_VERBOSE_MAKEFILE=1 -ifneq ($(gklib_path), not-set) - CONFIG_FLAGS += -DGKLIB_PATH=$(abspath $(gklib_path)) -endif -ifneq ($(prefix), not-set) - CONFIG_FLAGS += -DCMAKE_INSTALL_PREFIX=$(prefix) -endif -ifneq ($(i64), not-set) - IDXWIDTH = "\#define IDXTYPEWIDTH 64" -endif -ifneq ($(r64), not-set) - REALWIDTH = "\#define REALTYPEWIDTH 64" -endif -ifneq ($(gdb), not-set) - CONFIG_FLAGS += -DGDB=$(gdb) -endif -ifneq ($(assert), not-set) - CONFIG_FLAGS += -DASSERT=$(assert) -endif -ifneq ($(assert2), not-set) - CONFIG_FLAGS += -DASSERT2=$(assert2) -endif -ifneq ($(debug), not-set) - CONFIG_FLAGS += -DDEBUG=$(debug) -endif -ifneq ($(gprof), not-set) - CONFIG_FLAGS += -DGPROF=$(gprof) -endif -ifneq ($(valgrind), not-set) - CONFIG_FLAGS += -DVALGRIND=$(valgrind) -endif -ifneq ($(openmp), not-set) - CONFIG_FLAGS += -DOPENMP=$(openmp) -endif -ifneq ($(shared), not-set) - CONFIG_FLAGS += -DSHARED=1 -endif -ifneq ($(cc), not-set) - CONFIG_FLAGS += -DCMAKE_C_COMPILER=$(cc) -endif - -VERNUM=5.1.0 -PKGNAME=metis-$(VERNUM) - -define run-config -mkdir -p $(BUILDDIR) -mkdir -p $(BUILDDIR)/xinclude -echo $(IDXWIDTH) > $(BUILDDIR)/xinclude/metis.h -echo $(REALWIDTH) >> $(BUILDDIR)/xinclude/metis.h -cat include/metis.h >> $(BUILDDIR)/xinclude/metis.h -cp include/CMakeLists.txt $(BUILDDIR)/xinclude -cd $(BUILDDIR) && cmake $(CURDIR) $(CONFIG_FLAGS) -endef - -all clean install: - @if [ ! -f $(BUILDDIR)/Makefile ]; then \ - more BUILD.txt; \ - else \ - make -C $(BUILDDIR) $@ $(MAKEFLAGS); \ - fi - -uninstall: - xargs rm < $(BUILDDIR)/install_manifest.txt - -config: distclean - $(run-config) - -distclean: - rm -rf $(BUILDDIR) - -remake: - find . -name CMakeLists.txt -exec touch {} ';' - -dist: - utils/mkdist.sh $(PKGNAME) - -.PHONY: config distclean all clean install uninstall remake dist diff --git a/README.md b/README.md index 43195db..5444ec7 100644 --- a/README.md +++ b/README.md @@ -15,70 +15,12 @@ git clone https://github.com/KarypisLab/METIS.git ## Building standalone METIS binaries and library To build METIS you can follow the instructions below: - -### Dependencies - -General dependencies for building METIS are: gcc, cmake, build-essential. -In Ubuntu systems these can be obtained from the apt package manager (e.g., apt-get install cmake, etc) - -``` -sudo apt-get install build-essential -sudo apt-get install cmake -``` - -In addition, you need to download and install -[GKlib](https://github.com/KarypisLab/GKlib) by following the instructions there. - - -### Building and installing METIS - -METIS is primarily configured by passing options to make config. For example: - -``` -make config shared=1 cc=gcc prefix=~/local -make install -``` - -will configure METIS to be built as a shared library using GCC and then install the binaries, header files, and libraries at - -``` -~/local/bin -~/local/include -~/local/lib +```console +$ cmake -B ./build +$ cmake --build ./build ``` -directories, respectively. - -### Common configuration options are: - - cc=[compiler] - The C compiler to use [default is determined by CMake] - shared=1 - Build a shared library instead of a static one [off by default] - prefix=[PATH] - Set the installation prefix [~/local by default] - gklib_path=[PATH] - Set the prefix path where GKlib has been installed. You can skip - this if GKlib's installation prefix is the same as that of METIS. - i64=1 - Sets to 64 bits the width of the datatype that will store information - about the vertices and their adjacency lists. - r64=1 - Sets to 64 bits the width of the datatype that will store information - about floating point numbers. - -### Advanced debugging related options: - - gdb=1 - Build with support for GDB [off by default] - debug=1 - Enable debugging support [off by default] - assert=1 - Enable asserts [off by default] - assert2=1 - Enable very expensive asserts [off by default] - -### Other make commands - - make uninstall - Removes all files installed by 'make install'. - - make clean - Removes all object files but retains the configuration options. - - make distclean - Performs clean and completely removes the build directory. - +See the top-level [`CMakeLists.txt`](CMakeLists.txt) for more details on the available options ## Copyright & License Notice Copyright 1998-2020, Regents of the University of Minnesota diff --git a/cmake/CMakePresets-CI.json b/cmake/CMakePresets-CI.json new file mode 100644 index 0000000..8d0ac90 --- /dev/null +++ b/cmake/CMakePresets-CI.json @@ -0,0 +1,309 @@ +{ + "version": 6, + "include": [ + "CMakePresets-defaults.json" + ], + "configurePresets": [ + { + "name": "ci-base", + "hidden": true, + "generator": "Ninja", + "inherits": [ + "default" + ], + "cacheVariables": { + "METIS_TESTS": { + "type": "BOOL", + "value": true + }, + "METIS_PROGRAMS": { + "type": "BOOL", + "value": true + }, + "METIS_OpenMP": { + "type": "BOOL", + "value": "$env{WITH_OPENMP}" + } + }, + "errors": { + "deprecated": true + } + }, + { + "name": "gcc-ci", + "displayName": "GCC toolchain", + "inherits": [ + "ci-base" + ], + "binaryDir": "cmake-build-ci-gcc", + "cacheVariables": { + "CMAKE_C_COMPILER": { + "type": "FILEPATH", + "value": "gcc" + }, + "CMAKE_LINKER_TYPE": { + "type": "STRING", + "value": "SYSTEM" + } + } + }, + { + "name": "intel-ci", + "displayName": "Intel toolchain", + "inherits": [ + "ci-base" + ], + "binaryDir": "cmake-build-ci-intel", + "cacheVariables": { + "CMAKE_C_COMPILER": { + "type": "FILEPATH", + "value": "icx" + }, + "CMAKE_LINKER_TYPE": { + "type": "STRING", + "value": "SYSTEM" + } + } + }, + { + "name": "llvm-ci", + "displayName": "LLVM (Clang) toolchain", + "inherits": [ + "ci-base" + ], + "binaryDir": "cmake-build-ci-llvm", + "cacheVariables": { + "CMAKE_C_COMPILER": { + "type": "FILEPATH", + "value": "clang" + }, + "CMAKE_LINKER_TYPE": { + "type": "STRING", + "value": "LLD" + } + } + }, + { + "name": "windows-ci", + "displayName": "Windows native toolchain", + "inherits": [ + "ci-base" + ], + "binaryDir": "cmake-build-ci-windows", + "cacheVariables": { + "CMAKE_C_COMPILER": { + "type": "FILEPATH", + "value": "cl" + } + } + }, + { + "name": "macos-ci", + "displayName": "MacOS native toolchain", + "inherits": [ + "ci-base" + ], + "binaryDir": "cmake-build-ci-macos", + "cacheVariables": { + "CMAKE_C_COMPILER": { + "type": "FILEPATH", + "value": "clang" + } + } + } + ], + "buildPresets": [ + { + "name": "ci-base", + "hidden": true, + "inherits": [ + "default" + ], + "cleanFirst": true + }, + { + "name": "gcc-ci", + "displayName": "GCC toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "gcc-ci" + }, + { + "name": "intel-ci", + "displayName": "Intel toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "intel-ci" + }, + { + "name": "llvm-ci", + "displayName": "LLVM (Clang) toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "llvm-ci" + }, + { + "name": "windows-ci", + "displayName": "Windows native toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "windows-ci" + }, + { + "name": "macos-ci", + "displayName": "MacOS native toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "macos-ci" + } + ], + "testPresets": [ + { + "name": "ci-base", + "hidden": true, + "inherits": [ + "default" + ], + "output": { + "outputOnFailure": true + } + }, + { + "name": "gcc-ci", + "displayName": "GCC toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "gcc-ci" + }, + { + "name": "intel-ci", + "displayName": "Intel toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "intel-ci" + }, + { + "name": "llvm-ci", + "displayName": "LLVM (Clang) toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "llvm-ci" + }, + { + "name": "windows-ci", + "displayName": "Windows native toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "windows-ci" + }, + { + "name": "macos-ci", + "displayName": "MacOS native toolchain", + "inherits": [ + "ci-base" + ], + "configurePreset": "macos-ci" + } + ], + "workflowPresets": [ + { + "name": "gcc-ci", + "displayName": "GCC toolchain", + "steps": [ + { + "type": "configure", + "name": "gcc-ci" + }, + { + "type": "build", + "name": "gcc-ci" + }, + { + "type": "test", + "name": "gcc-ci" + } + ] + }, + { + "name": "intel-ci", + "displayName": "Intel toolchain", + "steps": [ + { + "type": "configure", + "name": "intel-ci" + }, + { + "type": "build", + "name": "intel-ci" + }, + { + "type": "test", + "name": "intel-ci" + } + ] + }, + { + "name": "llvm-ci", + "displayName": "LLVM (Clang) toolchain", + "steps": [ + { + "type": "configure", + "name": "llvm-ci" + }, + { + "type": "build", + "name": "llvm-ci" + }, + { + "type": "test", + "name": "llvm-ci" + } + ] + }, + { + "name": "windows-ci", + "displayName": "Windows native toolchain", + "steps": [ + { + "type": "configure", + "name": "windows-ci" + }, + { + "type": "build", + "name": "windows-ci" + }, + { + "type": "test", + "name": "windows-ci" + } + ] + }, + { + "name": "macos-ci", + "displayName": "MacOS native toolchain", + "steps": [ + { + "type": "configure", + "name": "macos-ci" + }, + { + "type": "build", + "name": "macos-ci" + }, + { + "type": "test", + "name": "macos-ci" + } + ] + } + ] +} diff --git a/cmake/CMakePresets-defaults.json b/cmake/CMakePresets-defaults.json new file mode 100644 index 0000000..6327111 --- /dev/null +++ b/cmake/CMakePresets-defaults.json @@ -0,0 +1,54 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "displayName": "Default preset", + "binaryDir": "cmake-build-release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Release" + }, + "CMAKE_MESSAGE_CONTEXT_SHOW": { + "type": "BOOL", + "value": true + } + } + } + ], + "buildPresets": [ + { + "name": "default", + "displayName": "Default preset", + "configurePreset": "default" + } + ], + "testPresets": [ + { + "name": "default", + "displayName": "Default preset", + "configurePreset": "default" + } + ], + "workflowPresets": [ + { + "name": "default", + "displayName": "Default workflow", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + } + ] + } + ] +} diff --git a/cmake/METIS.cmake b/cmake/METIS.cmake new file mode 100644 index 0000000..66d0d03 --- /dev/null +++ b/cmake/METIS.cmake @@ -0,0 +1,35 @@ +include_guard() + +function(METIS_FetchContent_MakeAvailable) + #[===[.md + # METIS_FetchContent_MakeAvailable + + Calls FetchContent_Before.cmake and FetchContent_After.cmake for each project + + ]===] + + list(APPEND CMAKE_MESSAGE_CONTEXT "METIS_FetchContent_MakeAvailable") + set(ARGS_Options "") + set(ARGS_OneValue "MODULES_PATH;PREFIX;BEFORE_SUFFIX;AFTER_SUFFIX") + set(ARGS_MultiValue "") + cmake_parse_arguments(ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}" ${ARGN}) + + if(NOT DEFINED ARGS_MODULES_PATH) + set(ARGS_MODULES_PATH ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/compat) + endif () + if(NOT DEFINED ARGS_PREFIX) + set(ARGS_PREFIX FetchContent) + endif () + if(NOT DEFINED ARGS_BEFORE_SUFFIX) + set(ARGS_BEFORE_SUFFIX _Before) + endif () + if(NOT DEFINED ARGS_AFTER_SUFFIX) + set(ARGS_AFTER_SUFFIX _After) + endif () + + foreach (pkg IN LISTS ARGS_UNPARSED_ARGUMENTS) + include(${ARGS_MODULES_PATH}/${ARGS_PREFIX}${pkg}${ARGS_BEFORE_SUFFIX}.cmake OPTIONAL) + FetchContent_MakeAvailable(${pkg}) + include(${ARGS_MODULES_PATH}/${ARGS_PREFIX}${pkg}${ARGS_AFTER_SUFFIX}.cmake OPTIONAL) + endforeach () +endfunction() \ No newline at end of file diff --git a/cmake/METISConfig.cmake.in b/cmake/METISConfig.cmake.in new file mode 100644 index 0000000..51144a4 --- /dev/null +++ b/cmake/METISConfig.cmake.in @@ -0,0 +1,8 @@ +@PACKAGE_INIT@ + +## Define exported variables +set(METIS_IDXTYPEWIDTH @METIS_IDXTYPEWIDTH@) +set(METIS_REALTYPEWIDTH @METIS_REALTYPEWIDTH@) + +## Add all exported targets +include(${CMAKE_CURRENT_LIST_DIR}/METISTargets.cmake) diff --git a/cmake/METIS_PackagesInfo.cmake b/cmake/METIS_PackagesInfo.cmake new file mode 100644 index 0000000..5aa5713 --- /dev/null +++ b/cmake/METIS_PackagesInfo.cmake @@ -0,0 +1,6 @@ +set_package_properties(GKlib PROPERTIES + URL https://github.com/KarypisLab/GKlib + DESCRIPTION "A library of various helper routines and frameworks used by many of the KarypisLab's software" + TYPE REQUIRED + PURPOSE "Utilties library" +) diff --git a/cmake/compat/FetchContentGKlib_After.cmake b/cmake/compat/FetchContentGKlib_After.cmake new file mode 100644 index 0000000..5a3b091 --- /dev/null +++ b/cmake/compat/FetchContentGKlib_After.cmake @@ -0,0 +1,4 @@ +set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND GKlib) +get_property(_packages_not_found GLOBAL PROPERTY PACKAGES_NOT_FOUND) +list(REMOVE_ITEM _packages_not_found GKlib) +set_property(GLOBAL PROPERTY PACKAGES_NOT_FOUND ${_packages_not_found}) diff --git a/cmake/compat/FetchContentGKlib_Before.cmake b/cmake/compat/FetchContentGKlib_Before.cmake new file mode 100644 index 0000000..d8951c2 --- /dev/null +++ b/cmake/compat/FetchContentGKlib_Before.cmake @@ -0,0 +1,3 @@ +if (METIS_OpenMP) + set(GKLIB_OpenMP ON CACHE BOOL "METIS: overload" FORCE) +endif () diff --git a/cmake/metis.pc.in b/cmake/metis.pc.in new file mode 100644 index 0000000..4efbc7e --- /dev/null +++ b/cmake/metis.pc.in @@ -0,0 +1,6 @@ +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lmetis +Cflags: -I@CMAKE_INSTALL_FULL_INCLUDEDIR@ diff --git a/conf/check_thread_storage.c b/conf/check_thread_storage.c deleted file mode 100644 index e6e1e98..0000000 --- a/conf/check_thread_storage.c +++ /dev/null @@ -1,5 +0,0 @@ -extern __thread int x; - -int main(int argc, char **argv) { - return 0; -} diff --git a/conf/gkbuild.cmake b/conf/gkbuild.cmake deleted file mode 100644 index 591ece4..0000000 --- a/conf/gkbuild.cmake +++ /dev/null @@ -1,148 +0,0 @@ -# Helper modules. -include(CheckFunctionExists) -include(CheckIncludeFile) - -# Setup options. -option(GDB "enable use of GDB" OFF) -option(ASSERT "turn asserts on" OFF) -option(ASSERT2 "additional assertions" OFF) -option(DEBUG "add debugging support" OFF) -option(GPROF "add gprof support" OFF) -option(VALGRIND "add valgrind support" OFF) -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(GK_COPTS "/Ox") - set(GK_COPTIONS "-DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE -DUSE_GKREGEX") -elseif(MINGW) - set(GK_COPTS "-DUSE_GKREGEX") -else() - set(GK_COPTIONS "-DLINUX -D_FILE_OFFSET_BITS=64") -endif(MSVC) -if(CYGWIN) - set(GK_COPTIONS "${GK_COPTIONS} -DCYGWIN") -endif(CYGWIN) -if(CMAKE_COMPILER_IS_GNUCC) -# GCC opts. - set(GK_COPTIONS "${GK_COPTIONS} -std=c99 -fno-strict-aliasing") -if(VALGRIND) - set(GK_COPTIONS "${GK_COPTIONS} -march=x86-64 -mtune=generic") -else() -# -march=native is not a valid flag on PPC: -if(CMAKE_SYSTEM_PROCESSOR MATCHES "power|ppc|powerpc|ppc64|powerpc64" OR (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc|ppc64")) - set(GK_COPTIONS "${GK_COPTIONS} -mtune=native") -else() - set(GK_COPTIONS "${GK_COPTIONS} -march=native") -endif() -endif(VALGRIND) - if(NOT MINGW) - set(GK_COPTIONS "${GK_COPTIONS} -fPIC") - endif(NOT MINGW) -# GCC warnings. - set(GK_COPTIONS "${GK_COPTIONS} -Werror -Wall -pedantic -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label") -elseif(${CMAKE_C_COMPILER_ID} MATCHES "Sun") -# Sun insists on -xc99. - set(GK_COPTIONS "${GK_COPTIONS} -xc99") -endif(CMAKE_COMPILER_IS_GNUCC) - -if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel") - set(GK_COPTIONS "${GK_COPTIONS} -xHost") - # set(GK_COPTIONS "${GK_COPTIONS} -fast") -endif() - -# Add support for MacOS items -if(APPLE) - set(GK_COPTIONS "${GK_COPTIONS} -DMACOS") -endif(APPLE) - -# Find OpenMP if it is requested. -if(OPENMP) - include(FindOpenMP) - if(OPENMP_FOUND) - set(GK_COPTIONS "${GK_COPTIONS} -D__OPENMP__ ${OpenMP_C_FLAGS}") - else() - message(WARNING "OpenMP was requested but support was not found") - endif(OPENMP_FOUND) -endif(OPENMP) - - -# Add various definitions. -if(GDB) - set(GK_COPTS "${GK_COPTS} -g") - set(GK_COPTIONS "${GK_COPTIONS} -Werror") -else() - set(GK_COPTS "-O3") -endif(GDB) - - -if(DEBUG) - set(GK_COPTS "-Og") - set(GK_COPTIONS "${GK_COPTIONS} -DDEBUG") -endif(DEBUG) - -if(GPROF) - set(GK_COPTS "-pg") -endif(GPROF) - -if(NOT ASSERT) - set(GK_COPTIONS "${GK_COPTIONS} -DNDEBUG") -endif(NOT ASSERT) - -if(NOT ASSERT2) - set(GK_COPTIONS "${GK_COPTIONS} -DNDEBUG2") -endif(NOT ASSERT2) - - -# Add various options -if(PCRE) - set(GK_COPTIONS "${GK_COPTIONS} -D__WITHPCRE__") -endif(PCRE) - -if(GKREGEX) - set(GK_COPTIONS "${GK_COPTIONS} -DUSE_GKREGEX") -endif(GKREGEX) - -if(GKRAND) - set(GK_COPTIONS "${GK_COPTIONS} -DUSE_GKRAND") -endif(GKRAND) - - -# Check for features. -check_include_file(execinfo.h HAVE_EXECINFO_H) -if(HAVE_EXECINFO_H) - set(GK_COPTIONS "${GK_COPTIONS} -DHAVE_EXECINFO_H") -endif(HAVE_EXECINFO_H) - -check_function_exists(getline HAVE_GETLINE) -if(HAVE_GETLINE) - set(GK_COPTIONS "${GK_COPTIONS} -DHAVE_GETLINE") -endif(HAVE_GETLINE) - - -# Custom check for TLS. -if(MSVC) - set(GK_COPTIONS "${GK_COPTIONS} -D__thread=__declspec(thread)") - - # This if checks if that value is cached or not. - if("${HAVE_THREADLOCALSTORAGE}" MATCHES "^${HAVE_THREADLOCALSTORAGE}$") - try_compile(HAVE_THREADLOCALSTORAGE - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/conf/check_thread_storage.c) - if(HAVE_THREADLOCALSTORAGE) - message(STATUS "checking for thread-local storage - found") - else() - message(STATUS "checking for thread-local storage - not found") - endif() - endif() - if(NOT HAVE_THREADLOCALSTORAGE) - set(GK_COPTIONS "${GK_COPTIONS} -D__thread=") - endif() -endif() - -# Finally set the official C flags. -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GK_COPTIONS} ${GK_COPTS}") - diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 9515a51..2afe06d 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,3 +1,37 @@ -if(METIS_INSTALL) - install(FILES metis.h DESTINATION include) -endif() +# Generate metis.h file with appropriate exported macros +if (METIS_IDX64) + set(IDXTYPEWIDTH 64) +else () + set(IDXTYPEWIDTH 32) +endif () +if (METIS_REAL64) + set(REALTYPEWIDTH 64) +else () + set(REALTYPEWIDTH 32) +endif () +configure_file(metis.h.in metis.h @ONLY) + +# Configure main target to consume the metis.h +# TODO: Move to FILE_SET for cmake 3.23 +set_target_properties(METIS_METIS PROPERTIES + PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/metis.h +) +target_include_directories(METIS_METIS PUBLIC + # Add the path to the generated metis.h + "$" + "$" +) + +# Set namespaced variables to be exported +set(METIS_IDXTYPEWIDTH ${IDXTYPEWIDTH}) +set(METIS_REALTYPEWIDTH ${REALTYPEWIDTH}) +if (CMAKE_VERSION VERSION_LESS 3.25) + # TODO: Remove when cmake 3.25 is commonly distributed + set(METIS_IDXTYPEWIDTH ${METIS_IDXTYPEWIDTH} PARENT_SCOPE) + set(METIS_REALTYPEWIDTH ${METIS_IDXTYPEWIDTH} PARENT_SCOPE) +else () + return(PROPAGATE + METIS_IDXTYPEWIDTH + METIS_REALTYPEWIDTH + ) +endif () diff --git a/include/metis.h b/include/metis.h.in similarity index 99% rename from include/metis.h rename to include/metis.h.in index 5000d1b..3cd9bf9 100644 --- a/include/metis.h +++ b/include/metis.h.in @@ -30,7 +30,7 @@ GCC does provides these definitions in stdint.h, but it may require some modifications on other architectures. --------------------------------------------------------------------------*/ -//#define IDXTYPEWIDTH 32 +#define IDXTYPEWIDTH @IDXTYPEWIDTH@ /*-------------------------------------------------------------------------- @@ -40,7 +40,7 @@ 32 : single precision floating point (float) 64 : double precision floating point (double) --------------------------------------------------------------------------*/ -//#define REALTYPEWIDTH 32 +#define REALTYPEWIDTH @REALTYPEWIDTH@ diff --git a/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt deleted file mode 100644 index fc6cec6..0000000 --- a/libmetis/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Add this directory for internal users. -include_directories(.) - -# Find sources. -file(GLOB metis_sources *.c) - -# Build libmetis. -add_library(metis ${METIS_LIBRARY_TYPE} ${metis_sources}) - -if(METIS_INSTALL) - install(TARGETS metis - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib - ARCHIVE DESTINATION lib) -endif() diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt deleted file mode 100644 index baf40ad..0000000 --- a/programs/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# These programs use internal metis data structures. -include_directories(../libmetis) - -# Build program. -add_executable(gpmetis gpmetis.c cmdline_gpmetis.c io.c stat.c) -add_executable(ndmetis ndmetis.c cmdline_ndmetis.c io.c smbfactor.c) -add_executable(mpmetis mpmetis.c cmdline_mpmetis.c io.c stat.c) -add_executable(m2gmetis m2gmetis.c cmdline_m2gmetis.c io.c) -add_executable(graphchk graphchk.c io.c) -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) -endforeach(prog) - -if(METIS_INSTALL) - install(TARGETS gpmetis ndmetis mpmetis m2gmetis graphchk cmpfillin - RUNTIME DESTINATION bin) -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..94dfb35 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(libmetis) +if (METIS_PROGRAMS) + add_subdirectory(programs) +endif () diff --git a/src/libmetis/CMakeLists.txt b/src/libmetis/CMakeLists.txt new file mode 100644 index 0000000..6c55f40 --- /dev/null +++ b/src/libmetis/CMakeLists.txt @@ -0,0 +1,53 @@ +target_sources(METIS_METIS PRIVATE + auxapi.c + balance.c + bucketsort.c + checkgraph.c + coarsen.c + compress.c + contig.c + debug.c + fm.c + fortran.c + frename.c + gklib.c + graph.c + initpart.c + kmetis.c + kwayfm.c + kwayrefine.c + mcutil.c + mesh.c + meshpart.c + minconn.c + mincover.c + mmd.c + ometis.c + options.c + parmetis.c + pmetis.c + refine.c + separator.c + sfm.c + srefine.c + stat.c + timing.c + util.c + wspace.c +) +target_link_libraries(METIS_METIS PRIVATE GKlib::GKlib) + +if (TARGET GKlib_GKlib) + target_compile_options(GKlib_GKlib PRIVATE -fPIC) +endif () + +# Install +if (METIS_INSTALL) + install(TARGETS METIS_METIS + EXPORT METISTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT METIS_Runtime NAMELINK_COMPONENT METIS_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT METIS_Development + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT METIS_Development + RUNTIME DESTINATION ${CMAKE_INSTALL_RUNTIMEDIR} COMPONENT METIS_Runtime + ) +endif () diff --git a/libmetis/auxapi.c b/src/libmetis/auxapi.c similarity index 100% rename from libmetis/auxapi.c rename to src/libmetis/auxapi.c diff --git a/libmetis/balance.c b/src/libmetis/balance.c similarity index 100% rename from libmetis/balance.c rename to src/libmetis/balance.c diff --git a/libmetis/bucketsort.c b/src/libmetis/bucketsort.c similarity index 100% rename from libmetis/bucketsort.c rename to src/libmetis/bucketsort.c diff --git a/libmetis/checkgraph.c b/src/libmetis/checkgraph.c similarity index 100% rename from libmetis/checkgraph.c rename to src/libmetis/checkgraph.c diff --git a/libmetis/coarsen.c b/src/libmetis/coarsen.c similarity index 100% rename from libmetis/coarsen.c rename to src/libmetis/coarsen.c diff --git a/libmetis/compress.c b/src/libmetis/compress.c similarity index 100% rename from libmetis/compress.c rename to src/libmetis/compress.c diff --git a/libmetis/contig.c b/src/libmetis/contig.c similarity index 100% rename from libmetis/contig.c rename to src/libmetis/contig.c diff --git a/libmetis/debug.c b/src/libmetis/debug.c similarity index 100% rename from libmetis/debug.c rename to src/libmetis/debug.c diff --git a/libmetis/defs.h b/src/libmetis/defs.h similarity index 100% rename from libmetis/defs.h rename to src/libmetis/defs.h diff --git a/libmetis/fm.c b/src/libmetis/fm.c similarity index 100% rename from libmetis/fm.c rename to src/libmetis/fm.c diff --git a/libmetis/fortran.c b/src/libmetis/fortran.c similarity index 100% rename from libmetis/fortran.c rename to src/libmetis/fortran.c diff --git a/libmetis/frename.c b/src/libmetis/frename.c similarity index 100% rename from libmetis/frename.c rename to src/libmetis/frename.c diff --git a/libmetis/gklib.c b/src/libmetis/gklib.c similarity index 100% rename from libmetis/gklib.c rename to src/libmetis/gklib.c diff --git a/libmetis/gklib_defs.h b/src/libmetis/gklib_defs.h similarity index 100% rename from libmetis/gklib_defs.h rename to src/libmetis/gklib_defs.h diff --git a/libmetis/gklib_rename.h b/src/libmetis/gklib_rename.h similarity index 100% rename from libmetis/gklib_rename.h rename to src/libmetis/gklib_rename.h diff --git a/libmetis/graph.c b/src/libmetis/graph.c similarity index 100% rename from libmetis/graph.c rename to src/libmetis/graph.c diff --git a/libmetis/initpart.c b/src/libmetis/initpart.c similarity index 100% rename from libmetis/initpart.c rename to src/libmetis/initpart.c diff --git a/libmetis/kmetis.c b/src/libmetis/kmetis.c similarity index 100% rename from libmetis/kmetis.c rename to src/libmetis/kmetis.c diff --git a/libmetis/kwayfm.c b/src/libmetis/kwayfm.c similarity index 100% rename from libmetis/kwayfm.c rename to src/libmetis/kwayfm.c diff --git a/libmetis/kwayrefine.c b/src/libmetis/kwayrefine.c similarity index 100% rename from libmetis/kwayrefine.c rename to src/libmetis/kwayrefine.c diff --git a/libmetis/macros.h b/src/libmetis/macros.h similarity index 100% rename from libmetis/macros.h rename to src/libmetis/macros.h diff --git a/libmetis/mcutil.c b/src/libmetis/mcutil.c similarity index 100% rename from libmetis/mcutil.c rename to src/libmetis/mcutil.c diff --git a/libmetis/mesh.c b/src/libmetis/mesh.c similarity index 100% rename from libmetis/mesh.c rename to src/libmetis/mesh.c diff --git a/libmetis/meshpart.c b/src/libmetis/meshpart.c similarity index 100% rename from libmetis/meshpart.c rename to src/libmetis/meshpart.c diff --git a/libmetis/metislib.h b/src/libmetis/metislib.h similarity index 95% rename from libmetis/metislib.h rename to src/libmetis/metislib.h index dc224f4..50274f0 100644 --- a/libmetis/metislib.h +++ b/src/libmetis/metislib.h @@ -16,7 +16,7 @@ #include -#if defined(ENABLE_OPENMP) +#if defined(_OPENMP) #include #endif diff --git a/libmetis/minconn.c b/src/libmetis/minconn.c similarity index 100% rename from libmetis/minconn.c rename to src/libmetis/minconn.c diff --git a/libmetis/mincover.c b/src/libmetis/mincover.c similarity index 100% rename from libmetis/mincover.c rename to src/libmetis/mincover.c diff --git a/libmetis/mmd.c b/src/libmetis/mmd.c similarity index 100% rename from libmetis/mmd.c rename to src/libmetis/mmd.c diff --git a/libmetis/ometis.c b/src/libmetis/ometis.c similarity index 100% rename from libmetis/ometis.c rename to src/libmetis/ometis.c diff --git a/libmetis/options.c b/src/libmetis/options.c similarity index 100% rename from libmetis/options.c rename to src/libmetis/options.c diff --git a/libmetis/parmetis.c b/src/libmetis/parmetis.c similarity index 100% rename from libmetis/parmetis.c rename to src/libmetis/parmetis.c diff --git a/libmetis/pmetis.c b/src/libmetis/pmetis.c similarity index 100% rename from libmetis/pmetis.c rename to src/libmetis/pmetis.c diff --git a/libmetis/proto.h b/src/libmetis/proto.h similarity index 100% rename from libmetis/proto.h rename to src/libmetis/proto.h diff --git a/libmetis/refine.c b/src/libmetis/refine.c similarity index 100% rename from libmetis/refine.c rename to src/libmetis/refine.c diff --git a/libmetis/rename.h b/src/libmetis/rename.h similarity index 100% rename from libmetis/rename.h rename to src/libmetis/rename.h diff --git a/libmetis/separator.c b/src/libmetis/separator.c similarity index 100% rename from libmetis/separator.c rename to src/libmetis/separator.c diff --git a/libmetis/sfm.c b/src/libmetis/sfm.c similarity index 100% rename from libmetis/sfm.c rename to src/libmetis/sfm.c diff --git a/libmetis/srefine.c b/src/libmetis/srefine.c similarity index 100% rename from libmetis/srefine.c rename to src/libmetis/srefine.c diff --git a/libmetis/stat.c b/src/libmetis/stat.c similarity index 100% rename from libmetis/stat.c rename to src/libmetis/stat.c diff --git a/libmetis/stdheaders.h b/src/libmetis/stdheaders.h similarity index 100% rename from libmetis/stdheaders.h rename to src/libmetis/stdheaders.h diff --git a/libmetis/struct.h b/src/libmetis/struct.h similarity index 100% rename from libmetis/struct.h rename to src/libmetis/struct.h diff --git a/libmetis/timing.c b/src/libmetis/timing.c similarity index 100% rename from libmetis/timing.c rename to src/libmetis/timing.c diff --git a/libmetis/util.c b/src/libmetis/util.c similarity index 100% rename from libmetis/util.c rename to src/libmetis/util.c diff --git a/libmetis/wspace.c b/src/libmetis/wspace.c similarity index 100% rename from libmetis/wspace.c rename to src/libmetis/wspace.c diff --git a/src/programs/CMakeLists.txt b/src/programs/CMakeLists.txt new file mode 100644 index 0000000..9854ed8 --- /dev/null +++ b/src/programs/CMakeLists.txt @@ -0,0 +1,89 @@ +# Define a simple cli helper target +add_library(METIS_cli OBJECT) + +# Define program targets +add_executable(METIS_gpmetis) +add_executable(METIS::gpmetis ALIAS METIS_gpmetis) +set_target_properties(METIS_gpmetis PROPERTIES + EXPORT_NAME gpmetis + OUTPUT_NAME gpmetis +) +add_executable(METIS_ndmetis) +add_executable(METIS::ndmetis ALIAS METIS_ndmetis) +set_target_properties(METIS_ndmetis PROPERTIES + EXPORT_NAME ndmetis + OUTPUT_NAME ndmetis +) +add_executable(METIS_mpmetis) +add_executable(METIS::mpmetis ALIAS METIS_mpmetis) +set_target_properties(METIS_mpmetis PROPERTIES + EXPORT_NAME mpmetis + OUTPUT_NAME mpmetis +) +add_executable(METIS_m2gmetis) +add_executable(METIS::m2gmetis ALIAS METIS_m2gmetis) +set_target_properties(METIS_m2gmetis PROPERTIES + EXPORT_NAME m2gmetis + OUTPUT_NAME m2gmetis +) +add_executable(METIS_graphchk) +add_executable(METIS::graphchk ALIAS METIS_graphchk) +set_target_properties(METIS_graphchk PROPERTIES + EXPORT_NAME graphchk + OUTPUT_NAME graphchk +) +add_executable(METIS_cmpfillin) +add_executable(METIS::cmpfillin ALIAS METIS_cmpfillin) +set_target_properties(METIS_cmpfillin PROPERTIES + EXPORT_NAME cmpfillin + OUTPUT_NAME cmpfillin +) + +# Actual target definition +target_sources(METIS_cli PRIVATE + io.c + stat.c + smbfactor.c +) +target_link_libraries(METIS_cli PUBLIC GKlib::GKlib METIS_METIS) +# Add include_directories for mtest to use +target_include_directories(METIS_cli PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_sources(METIS_gpmetis PRIVATE + gpmetis.c + cmdline_gpmetis.c +) +target_link_libraries(METIS_gpmetis PRIVATE METIS_cli) +target_sources(METIS_ndmetis PRIVATE + ndmetis.c + cmdline_ndmetis.c +) +target_link_libraries(METIS_ndmetis PRIVATE METIS_cli) +target_sources(METIS_mpmetis PRIVATE + mpmetis.c + cmdline_mpmetis.c +) +target_link_libraries(METIS_mpmetis PRIVATE METIS_cli) +target_sources(METIS_m2gmetis PRIVATE + m2gmetis.c + cmdline_m2gmetis.c +) +target_link_libraries(METIS_m2gmetis PRIVATE METIS_cli) +target_sources(METIS_graphchk PRIVATE + graphchk.c +) +target_link_libraries(METIS_graphchk PRIVATE METIS_cli) +target_sources(METIS_cmpfillin PRIVATE + cmpfillin.c +) +target_link_libraries(METIS_cmpfillin PRIVATE METIS_cli) + +# install +if (METIS_INSTALL) + get_directory_property(PorgramTargets BUILDSYSTEM_TARGETS) + list(REMOVE_ITEM PorgramTargets METIS_cli) + install(TARGETS ${PorgramTargets} + # TODO: This should be moved to a different optional target + EXPORT METISTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT METIS_Runtime + ) +endif () diff --git a/programs/cmdline_gpmetis.c b/src/programs/cmdline_gpmetis.c similarity index 100% rename from programs/cmdline_gpmetis.c rename to src/programs/cmdline_gpmetis.c diff --git a/programs/cmdline_m2gmetis.c b/src/programs/cmdline_m2gmetis.c similarity index 100% rename from programs/cmdline_m2gmetis.c rename to src/programs/cmdline_m2gmetis.c diff --git a/programs/cmdline_mpmetis.c b/src/programs/cmdline_mpmetis.c similarity index 100% rename from programs/cmdline_mpmetis.c rename to src/programs/cmdline_mpmetis.c diff --git a/programs/cmdline_ndmetis.c b/src/programs/cmdline_ndmetis.c similarity index 100% rename from programs/cmdline_ndmetis.c rename to src/programs/cmdline_ndmetis.c diff --git a/programs/cmpfillin.c b/src/programs/cmpfillin.c similarity index 100% rename from programs/cmpfillin.c rename to src/programs/cmpfillin.c diff --git a/programs/defs.h b/src/programs/defs.h similarity index 100% rename from programs/defs.h rename to src/programs/defs.h diff --git a/programs/gpmetis.c b/src/programs/gpmetis.c similarity index 100% rename from programs/gpmetis.c rename to src/programs/gpmetis.c diff --git a/programs/graphchk.c b/src/programs/graphchk.c similarity index 100% rename from programs/graphchk.c rename to src/programs/graphchk.c diff --git a/programs/io.c b/src/programs/io.c similarity index 100% rename from programs/io.c rename to src/programs/io.c diff --git a/programs/m2gmetis.c b/src/programs/m2gmetis.c similarity index 100% rename from programs/m2gmetis.c rename to src/programs/m2gmetis.c diff --git a/programs/metisbin.h b/src/programs/metisbin.h similarity index 97% rename from programs/metisbin.h rename to src/programs/metisbin.h index ce9b54e..cbaf5a2 100644 --- a/programs/metisbin.h +++ b/src/programs/metisbin.h @@ -22,7 +22,7 @@ #include -#if defined(ENABLE_OPENMP) +#if defined(_OPENMP) #include #endif diff --git a/programs/mpmetis.c b/src/programs/mpmetis.c similarity index 100% rename from programs/mpmetis.c rename to src/programs/mpmetis.c diff --git a/programs/ndmetis.c b/src/programs/ndmetis.c similarity index 100% rename from programs/ndmetis.c rename to src/programs/ndmetis.c diff --git a/programs/proto.h b/src/programs/proto.h similarity index 100% rename from programs/proto.h rename to src/programs/proto.h diff --git a/programs/smbfactor.c b/src/programs/smbfactor.c similarity index 100% rename from programs/smbfactor.c rename to src/programs/smbfactor.c diff --git a/programs/stat.c b/src/programs/stat.c similarity index 100% rename from programs/stat.c rename to src/programs/stat.c diff --git a/programs/struct.h b/src/programs/struct.h similarity index 100% rename from programs/struct.h rename to src/programs/struct.h diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..8090f66 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,69 @@ +function(METIS_add_test test) + #[===[.md + # METIS_add_test + + Internal helper for adding GKlib tests + + ## Synopsis + ```cmake + METIS_add_test( + [TEST_NAME ] + [TARGET ] + [LABELS ]) + ``` + + ## Options + + `` + Path to the CMake project to be executed relative to `${CMAKE_CURRENT_SOURCE_DIR}` + + `TEST_NAME` [Default: ``] + Name for the test to be used as the ctest name + + `LABELS` + Additional labels to be added + + ]===] + + list(APPEND CMAKE_MESSAGE_CONTEXT METIS_add_test) + set(ARGS_Options) + set(ARGS_OneValue + TEST_NAME + ) + set(ARGS_MultiValue + LABELS + ) + cmake_parse_arguments(PARSE_ARGV 1 ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}") + # Check required/optional arguments + if (ARGC LESS 1) + message(FATAL_ERROR "Missing test name") + endif () + if (NOT DEFINED ARGS_TEST_NAME) + set(ARGS_TEST_NAME ${test}) + endif () + + add_test(NAME ${ARGS_TEST_NAME} + COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/${test} + ${CMAKE_CURRENT_BINARY_DIR}/${test} + --build-generator "${CMAKE_GENERATOR}" + --build-options -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + # Generated Config file point to binary targets until it is installed + -DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS + -DMETIS_ROOT=${PROJECT_BINARY_DIR} + # TODO: Implement recursive ctest and remove --notests flag + --test-command ${CMAKE_CTEST_COMMAND} --test-dir ${CMAKE_CURRENT_BINARY_DIR}/${test} --no-tests=ignore + ) + set_tests_properties(${ARGS_TEST_NAME} PROPERTIES + LABELS "${ARGS_LABELS}" + ) +endfunction() + +foreach (test IN ITEMS +) + # TODO: Implement some regression tests with METIS_add_test +endforeach () +# TODO: Decouple mtest to be independent from other dependencies +if (METIS_PROGRAMS) + # TODO: Currently reusing METIS_cli target +# add_subdirectory(mtest) +endif () diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 2e7512b..0000000 --- a/test/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -include ../Makefile.in - -CURBUILDDIR = $(TSTBUILDDIR) - - -MTESTSRC = mtest.c - -MTESTOBJS = $(patsubst %.c, $(CURBUILDDIR)/%$(OBJEXT), $(MTESTSRC)) -EXTRAOBJS = $(PRGBUILDDIR)/io$(OBJEXT) - -ALLOBJS = $(patsubst %.c, $(CURBUILDDIR)/%$(OBJEXT), $(wildcard *.c)) -HEADERS = $(wildcard *.h) $(TOPDIR)/include/metis.h - -LIBRARIES = $(BUILDDIR)/libmetis$(LIBEXT) - -INCLUDES += -I$(TOPDIR)/libmetis - -TARGETS = $(BUILDDIR)/mtest$(VERNUM)$(EXEEXT) - - -default: $(TARGETS) - - -$(BUILDDIR)/mtest$(VERNUM)$(EXEEXT): $(MTESTOBJS) $(LIBRARIES) - $(LD) $(LDOPTIONS) $(EXEOUTPUTFILE) $(MTESTOBJS) $(EXTRAOBJS) $(LIBSDIR) $(LIBS) - chmod 744 $@ - @if [ "$(BINDIR)" ]; then cp $@* $(BINDIR); fi - - -clean: - rm -f $(ALLOBJS) - -realclean: - rm -f $(ALLOBJS) $(TARGETS) - rm -fr $(BUILDDIR) - - - -$(ALLOBJS) : $(HEADERS) ../Makefile.in Makefile - -$(CURBUILDDIR)/%$(OBJEXT) : %.c - $(CC) $(CFLAGS) $(SOURCEFILE) $(OUTPUTFILE) - - diff --git a/test/mtest/CMakeLists.txt b/test/mtest/CMakeLists.txt new file mode 100644 index 0000000..5f848da --- /dev/null +++ b/test/mtest/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable(METIS_mtest mtest.c) +set_target_properties(METIS_mtest PROPERTIES + OUTPUT_NAME mtest +) +target_link_libraries(METIS_mtest PRIVATE METIS_METIS GKlib::GKlib) +# TODO: Decouple from the Programs targets +# TODO: cli interface is not actually implemented +target_link_libraries(METIS_mtest PRIVATE METIS_cli) + +target_include_directories(METIS_mtest PRIVATE + # TODO: Should not strongly couple the tests to the internal headers + ${PROJECT_SOURCE_DIR}/src/libmetis +) + +# TODO: Link mtest to actual add_test diff --git a/test/mtest.c b/test/mtest/mtest.c similarity index 100% rename from test/mtest.c rename to test/mtest/mtest.c diff --git a/test/proto.h b/test/mtest/proto.h similarity index 100% rename from test/proto.h rename to test/mtest/proto.h diff --git a/utils/int2idxtype.sh b/utils/int2idxtype.sh deleted file mode 100755 index 603b1d1..0000000 --- a/utils/int2idxtype.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -for file in *.[c,h] - do - cat $file | sed 's/ int / idxtype /g' > $file.tmp - mv $file.tmp $file - cat $file | sed 's/(int /(idxtype /g' > $file.tmp - mv $file.tmp $file - cat $file | sed 's/^int /idxtype /g' > $file.tmp - mv $file.tmp $file - done - diff --git a/utils/listunescapedsymbols.csh b/utils/listunescapedsymbols.csh deleted file mode 100755 index 56971df..0000000 --- a/utils/listunescapedsymbols.csh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -nm *.o | grep " T " | egrep -v '(libmetis|METIS|__)' | awk '{printf("#define %s libmetis__%s\n",$3, $3)}' - diff --git a/utils/mkdist.sh b/utils/mkdist.sh deleted file mode 100755 index e36f092..0000000 --- a/utils/mkdist.sh +++ /dev/null @@ -1,13 +0,0 @@ -rm -rf $1 -svn up -svn export http://dminers.dtc.umn.edu/svn/programs/karypis/metis/trunk $1 -mkdir $1/manual -svn export http://dminers.dtc.umn.edu/svn/programs/karypis/metis/manual/r5.0/manual.pdf $1/manual/manual.pdf -svn export http://dminers.dtc.umn.edu/svn/libs/GKlib/trunk $1/GKlib -rm -rf $1/TODO -rm -rf $1/test -rm -rf $1/utils -rm -rf $1/doxygen -rm -rf $1/CHANGES.v4 -tar -czf $1.tar.gz $1 -rm -rf $1 diff --git a/utils/s+r.sh b/utils/s+r.sh deleted file mode 100755 index db8566d..0000000 --- a/utils/s+r.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -echo "Replacing $1 with $2" - -for file in *.[c,h] - do - cat $file | sed 's/$1/$2/g' > $file.tmp - mv $file.tmp $file - done - diff --git a/vsgen.bat b/vsgen.bat deleted file mode 100644 index e383e01..0000000 --- a/vsgen.bat +++ /dev/null @@ -1,8 +0,0 @@ -MKDIR build\windows -MKDIR build\xinclude -COPY include\metis.h build\xinclude -COPY include\CMakeLists.txt build\xinclude -CD build\windows -cmake -DCMAKE_CONFIGURATION_TYPES="Release" ..\.. %* -ECHO VS files have been generated in build\windows -CD ..\..\