From db9e40d60fb1f6e58a471d24b802d02291510c34 Mon Sep 17 00:00:00 2001 From: jianda sheng Date: Thu, 10 Aug 2023 01:11:04 +0800 Subject: [PATCH 01/21] metis can be used as submodul, with gklib is also submodule. cmake create the metis.h when generate. --- .gitignore | 2 ++ CMakeLists.txt | 49 +++++++++++++++------------- conf/gkbuild.cmake | 58 ++++++++++++++++----------------- include/{metis.h => metis.h.in} | 4 +-- libmetis/CMakeLists.txt | 15 ++++++--- 5 files changed, 71 insertions(+), 57 deletions(-) rename include/{metis.h => metis.h.in} (99%) diff --git a/.gitignore b/.gitignore index bf123be..1349ce5 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ graphs/*.npart.* GKlib .svn/ +include/metis.h + diff --git a/CMakeLists.txt b/CMakeLists.txt index a15d19a..be043fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(METIS C) -set(SHARED FALSE CACHE BOOL "build a shared library") +set(METIS_SHARED FALSE CACHE BOOL "build a shared library") +set(METIS_BUILD_PROGRAMS TRUE CACHE BOOL "build metis programs") if(MSVC) set(METIS_INSTALL FALSE) @@ -10,34 +11,36 @@ else() endif() # Configure libmetis library. -if(SHARED) +if(METIS_SHARED) set(METIS_LIBRARY_TYPE SHARED) else() set(METIS_LIBRARY_TYPE STATIC) -endif(SHARED) +endif(METIS_SHARED) -include(./conf/gkbuild.cmake) +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}") - +option(METIS_IDX64 "enable 64 bit ints" OFF) +option(METIS_REAL64 "enable 64 bit floats (i.e., double)" OFF) +if(IDX64) + set(IDXTYPEWIDTH 64) +else() + set(IDXTYPEWIDTH 32) +endif(IDX64) +if(REAL64) + set(REALTYPEWIDTH 64) +else() + set(REALTYPEWIDTH 32) +endif(REAL64) +configure_file ( + "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h.in" + "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h" + @ONLY +) # 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 +50,8 @@ 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") +if(METIS_BUILD_PROGRAMS) + add_subdirectory("programs") +endif(METIS_BUILD_PROGRAMS) diff --git a/conf/gkbuild.cmake b/conf/gkbuild.cmake index 591ece4..174b292 100644 --- a/conf/gkbuild.cmake +++ b/conf/gkbuild.cmake @@ -3,16 +3,16 @@ 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) +option(GKLIB_GDB "enable use of GDB" OFF) +option(GKLIB_ASSERT "turn asserts on" OFF) +option(GKLIB_ASSERT2 "additional assertions" OFF) +option(GKLIB_DEBUG "add debugging support" OFF) +option(GKLIB_GPROF "add gprof support" OFF) +option(GKLIB_VALGRIND "add valgrind support" OFF) +option(GKLIB_OPENMP "enable OpenMP support" OFF) +option(GKLIB_PCRE "enable PCRE support" OFF) +option(GKLIB_GKREGEX "enable GKREGEX support" OFF) +option(GKLIB_GKRAND "enable GKRAND support" OFF) # Add compiler flags. if(MSVC) @@ -29,7 +29,7 @@ endif(CYGWIN) if(CMAKE_COMPILER_IS_GNUCC) # GCC opts. set(GK_COPTIONS "${GK_COPTIONS} -std=c99 -fno-strict-aliasing") -if(VALGRIND) +if(GKLIB_VALGRIND) set(GK_COPTIONS "${GK_COPTIONS} -march=x86-64 -mtune=generic") else() # -march=native is not a valid flag on PPC: @@ -38,7 +38,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "power|ppc|powerpc|ppc64|powerpc64" OR (APPLE else() set(GK_COPTIONS "${GK_COPTIONS} -march=native") endif() -endif(VALGRIND) +endif(GKLIB_VALGRIND) if(NOT MINGW) set(GK_COPTIONS "${GK_COPTIONS} -fPIC") endif(NOT MINGW) @@ -60,33 +60,33 @@ if(APPLE) endif(APPLE) # Find OpenMP if it is requested. -if(OPENMP) +if(GKLIB_OPENMP) include(FindOpenMP) - if(OPENMP_FOUND) + if(GKLIB_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) + endif(GKLIB_OPENMP_FOUND) +endif(GKLIB_OPENMP) # Add various definitions. -if(GDB) +if(GKLIB_GDB) set(GK_COPTS "${GK_COPTS} -g") set(GK_COPTIONS "${GK_COPTIONS} -Werror") else() set(GK_COPTS "-O3") -endif(GDB) +endif(GKLIB_GDB) -if(DEBUG) +if(GKLIB_DEBUG) set(GK_COPTS "-Og") set(GK_COPTIONS "${GK_COPTIONS} -DDEBUG") -endif(DEBUG) +endif(GKLIB_DEBUG) -if(GPROF) +if(GKLIB_GPROF) set(GK_COPTS "-pg") -endif(GPROF) +endif(GKLIB_GPROF) if(NOT ASSERT) set(GK_COPTIONS "${GK_COPTIONS} -DNDEBUG") @@ -98,17 +98,17 @@ endif(NOT ASSERT2) # Add various options -if(PCRE) +if(GKLIB_PCRE) set(GK_COPTIONS "${GK_COPTIONS} -D__WITHPCRE__") -endif(PCRE) +endif(GKLIB_PCRE) -if(GKREGEX) +if(GKLIB_GKREGEX) set(GK_COPTIONS "${GK_COPTIONS} -DUSE_GKREGEX") -endif(GKREGEX) +endif(GKLIB_GKREGEX) -if(GKRAND) +if(GKLIB_GKRAND) set(GK_COPTIONS "${GK_COPTIONS} -DUSE_GKRAND") -endif(GKRAND) +endif(GKLIB_GKRAND) # Check for features. @@ -131,7 +131,7 @@ if(MSVC) if("${HAVE_THREADLOCALSTORAGE}" MATCHES "^${HAVE_THREADLOCALSTORAGE}$") try_compile(HAVE_THREADLOCALSTORAGE ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/conf/check_thread_storage.c) + ${CMAKE_CURRENT_SOURCE_DIR}/conf/check_thread_storage.c) if(HAVE_THREADLOCALSTORAGE) message(STATUS "checking for thread-local storage - found") else() 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 index fc6cec6..8e59f45 100644 --- a/libmetis/CMakeLists.txt +++ b/libmetis/CMakeLists.txt @@ -1,14 +1,21 @@ # Add this directory for internal users. -include_directories(.) +set(METIS_NAME "metis" CACHE INTERNAL "") + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include) # Find sources. -file(GLOB metis_sources *.c) +file(GLOB metis_sources *.h *.c) # Build libmetis. -add_library(metis ${METIS_LIBRARY_TYPE} ${metis_sources}) +add_library(${METIS_NAME} ${METIS_LIBRARY_TYPE} ${metis_sources}) + +if(GKLIB_NAME) + target_link_libraries(${METIS_NAME} ${GKLIB_NAME}) + add_dependencies(${METIS_NAME} ${GKLIB_NAME}) +endif() if(METIS_INSTALL) - install(TARGETS metis + install(TARGETS ${METIS_NAME} LIBRARY DESTINATION lib RUNTIME DESTINATION lib ARCHIVE DESTINATION lib) From ee28bbeb6a9eed09fac10ea34063f83913439b9a Mon Sep 17 00:00:00 2001 From: jianda sheng Date: Thu, 10 Aug 2023 23:07:38 +0800 Subject: [PATCH 02/21] fix config bug --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be043fa..8768438 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,16 +22,16 @@ include(conf/gkbuild.cmake) # METIS' custom options option(METIS_IDX64 "enable 64 bit ints" OFF) option(METIS_REAL64 "enable 64 bit floats (i.e., double)" OFF) -if(IDX64) +if(METIS_IDX64) set(IDXTYPEWIDTH 64) else() set(IDXTYPEWIDTH 32) -endif(IDX64) -if(REAL64) +endif(METIS_IDX64) +if(METIS_REAL64) set(REALTYPEWIDTH 64) else() set(REALTYPEWIDTH 32) -endif(REAL64) +endif(METIS_REAL64) configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h" From 879c8c2b77d6c7fe9bfc514af9f8ed57e9fbcbfa Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 15:58:03 +0200 Subject: [PATCH 03/21] Add basic section structure --- CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8768438..ec6fb01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 2.8) + +#[==============================================================================================[ +# Basic project definition # +]==============================================================================================] project(METIS C) +#[==============================================================================================[ +# Options # +]==============================================================================================] + set(METIS_SHARED FALSE CACHE BOOL "build a shared library") set(METIS_BUILD_PROGRAMS TRUE CACHE BOOL "build metis programs") @@ -10,6 +18,10 @@ else() set(METIS_INSTALL TRUE) endif() +#[==============================================================================================[ +# Project configuration # +]==============================================================================================] + # Configure libmetis library. if(METIS_SHARED) set(METIS_LIBRARY_TYPE SHARED) @@ -38,6 +50,14 @@ configure_file ( @ONLY ) +#[==============================================================================================[ +# External packages # +]==============================================================================================] + +#[==============================================================================================[ +# Main definition # +]==============================================================================================] + # Add include directories. # i.e., the -I equivalent #include_directories(build/xinclude) @@ -55,3 +75,7 @@ add_subdirectory("libmetis") if(METIS_BUILD_PROGRAMS) add_subdirectory("programs") endif(METIS_BUILD_PROGRAMS) + +#[==============================================================================================[ +# Install or Export # +]==============================================================================================] From 7c69bfe9016134d853bf4ea1b22be36b49287b91 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 15:58:47 +0200 Subject: [PATCH 04/21] Bump cmake_minimum_required to something useful --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec6fb01..a1e0546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.15) #[==============================================================================================[ # Basic project definition # From f1b40baccd9e96a7f6e6efe3abc7dd8b91247211 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 16:02:47 +0200 Subject: [PATCH 05/21] Rearrange options and implement some defaults --- CMakeLists.txt | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1e0546..6916cc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,28 @@ cmake_minimum_required(VERSION 3.15) #[==============================================================================================[ # Basic project definition # ]==============================================================================================] -project(METIS C) + +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 () + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif () #[==============================================================================================[ # Options # From e7af6aa4020ea28c3204c11c795f731b1837ef73 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 16:03:03 +0200 Subject: [PATCH 06/21] Add C standard specification --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6916cc5..c348110 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ if (NOT DEFINED Spglib_IS_TOP_LEVEL) 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 () From 0855b1448e48943f5d91dc390900deb094c9f491 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 17:12:58 +0200 Subject: [PATCH 07/21] CMake project modernization Signed-off-by: Cristian Le --- CMakeLists.txt | 191 +++++++++++++++++++++++---------- cmake/METISConfig.cmake.in | 8 ++ cmake/METIS_PackagesInfo.cmake | 6 ++ cmake/metis.pc.in | 6 ++ include/CMakeLists.txt | 40 ++++++- libmetis/CMakeLists.txt | 69 ++++++++---- programs/CMakeLists.txt | 101 ++++++++++++++--- test/CMakeLists.txt | 12 +++ 8 files changed, 335 insertions(+), 98 deletions(-) create mode 100644 cmake/METISConfig.cmake.in create mode 100644 cmake/METIS_PackagesInfo.cmake create mode 100644 cmake/metis.pc.in create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c348110..b236433 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,9 @@ 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 # @@ -6,20 +11,20 @@ cmake_minimum_required(VERSION 3.15) 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 + 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 () + 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 @@ -28,80 +33,152 @@ set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS ON) if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE Release) endif () #[==============================================================================================[ # Options # ]==============================================================================================] -set(METIS_SHARED FALSE CACHE BOOL "build a shared library") -set(METIS_BUILD_PROGRAMS TRUE CACHE BOOL "build metis programs") - -if(MSVC) - set(METIS_INSTALL FALSE) -else() - set(METIS_INSTALL TRUE) -endif() +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_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 # ]==============================================================================================] -# Configure libmetis library. -if(METIS_SHARED) - set(METIS_LIBRARY_TYPE SHARED) -else() - set(METIS_LIBRARY_TYPE STATIC) -endif(METIS_SHARED) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + +# 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}) include(conf/gkbuild.cmake) -# METIS' custom options -option(METIS_IDX64 "enable 64 bit ints" OFF) -option(METIS_REAL64 "enable 64 bit floats (i.e., double)" OFF) -if(METIS_IDX64) - set(IDXTYPEWIDTH 64) -else() - set(IDXTYPEWIDTH 32) -endif(METIS_IDX64) -if(METIS_REAL64) - set(REALTYPEWIDTH 64) -else() - set(REALTYPEWIDTH 32) -endif(METIS_REAL64) -configure_file ( - "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h.in" - "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h" - @ONLY -) #[==============================================================================================[ # External packages # ]==============================================================================================] +find_package(GKlib CONFIG) +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 # ]==============================================================================================] -# Add include directories. -# i.e., the -I equivalent -#include_directories(build/xinclude) -include_directories(${GKLIB_PATH}/include) -include_directories(${CMAKE_INSTALL_PREFIX}/include) +# 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 libmetis +add_subdirectory(include) +add_subdirectory(libmetis) -# 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) +if (METIS_PROGRAMS) + add_subdirectory(programs) +endif () -# Recursively look for CMakeLists.txt in subdirs. -#add_subdirectory("build/xinclude") -add_subdirectory("libmetis") -if(METIS_BUILD_PROGRAMS) - add_subdirectory("programs") -endif(METIS_BUILD_PROGRAMS) +# 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/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/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/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/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt index 8e59f45..bac6d50 100644 --- a/libmetis/CMakeLists.txt +++ b/libmetis/CMakeLists.txt @@ -1,22 +1,49 @@ -# Add this directory for internal users. -set(METIS_NAME "metis" CACHE INTERNAL "") +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) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include) - -# Find sources. -file(GLOB metis_sources *.h *.c) - -# Build libmetis. -add_library(${METIS_NAME} ${METIS_LIBRARY_TYPE} ${metis_sources}) - -if(GKLIB_NAME) - target_link_libraries(${METIS_NAME} ${GKLIB_NAME}) - add_dependencies(${METIS_NAME} ${GKLIB_NAME}) -endif() - -if(METIS_INSTALL) - install(TARGETS ${METIS_NAME} - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib - ARCHIVE DESTINATION lib) -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/programs/CMakeLists.txt b/programs/CMakeLists.txt index baf40ad..d656408 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,20 +1,87 @@ -# These programs use internal metis data structures. -include_directories(../libmetis) +# Define a simple cli helper target +add_library(METIS_cli OBJECT) -# 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) +# 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 +) -# Link with the required libraries -foreach(prog gpmetis ndmetis mpmetis m2gmetis graphchk cmpfillin) - target_link_libraries(${prog} metis GKlib m) -endforeach(prog) +# Actual target definition +target_sources(METIS_cli PRIVATE + io.c + stat.c + smbfactor.c +) +target_link_libraries(METIS_cli PUBLIC GKlib::GKlib METIS_METIS) +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) -if(METIS_INSTALL) - install(TARGETS gpmetis ndmetis mpmetis m2gmetis graphchk cmpfillin - RUNTIME DESTINATION bin) -endif() +# 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/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..d232e9e --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(METIS_Test) + +set_target_properties(METIS_Test PROPERTIES + OUTPUT_NAME mtest +) + +target_sources(METIS_Test PRIVATE + mtest.c +) +target_link_libraries(METIS_Test PRIVATE METIS_METIS) + +# TODO: Add actual add_test using ../graphs From 693318002212c1db4416f1bb38737235f39cac7f Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 17:30:22 +0200 Subject: [PATCH 08/21] Add basic CMakePresets Signed-off-by: Cristian Le --- .gitignore | 3 + CMakePresets.json | 12 ++ cmake/CMakePresets-CI.json | 305 +++++++++++++++++++++++++++++++ cmake/CMakePresets-defaults.json | 54 ++++++ 4 files changed, 374 insertions(+) create mode 100644 CMakePresets.json create mode 100644 cmake/CMakePresets-CI.json create mode 100644 cmake/CMakePresets-defaults.json diff --git a/.gitignore b/.gitignore index 1349ce5..424c5df 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ GKlib include/metis.h +### Project specific +CMakeUserPresets.json +cmake-build-* 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/cmake/CMakePresets-CI.json b/cmake/CMakePresets-CI.json new file mode 100644 index 0000000..f8b69c1 --- /dev/null +++ b/cmake/CMakePresets-CI.json @@ -0,0 +1,305 @@ +{ + "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 + } + }, + "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" + } + ] + } + ] +} From 819421a66e817cce1c1a53425d509ab3a15abd67 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 26 Oct 2023 17:43:54 +0200 Subject: [PATCH 09/21] Add basic GitHub actions Signed-off-by: Cristian Le --- .github/workflows/ci.yaml | 29 ++++++++++++++++++ .github/workflows/step_test.yaml | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/step_test.yaml 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..d0f2f6c --- /dev/null +++ b/.github/workflows/step_test.yaml @@ -0,0 +1,52 @@ +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 ] + include: + - os: windows-latest + toolchain: windows + - os: macos-latest + toolchain: macos + 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() From 7993b08310da812e78048e4201276767426d944f Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 12:48:17 +0200 Subject: [PATCH 10/21] Import GKlib from FetchContent Signed-off-by: Cristian Le --- CMakeLists.txt | 10 ++- conf/check_thread_storage.c | 5 -- conf/gkbuild.cmake | 148 ------------------------------------ 3 files changed, 7 insertions(+), 156 deletions(-) delete mode 100644 conf/check_thread_storage.c delete mode 100644 conf/gkbuild.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b236433..5956508 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,14 +70,18 @@ endif () # Define basic parameters set(BUILD_SHARED_LIBS ${METIS_SHARED_LIBS}) -include(conf/gkbuild.cmake) - #[==============================================================================================[ # External packages # ]==============================================================================================] -find_package(GKlib CONFIG) +FetchContent_Declare(GKlib + GIT_REPOSITORY https://github.com/KarypisLab/GKlib + GIT_TAG master + FIND_PACKAGE_ARGS CONFIG +) +FetchContent_MakeAvailable(GKlib) + include(METIS_PackagesInfo) feature_summary( 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 174b292..0000000 --- a/conf/gkbuild.cmake +++ /dev/null @@ -1,148 +0,0 @@ -# Helper modules. -include(CheckFunctionExists) -include(CheckIncludeFile) - -# Setup options. -option(GKLIB_GDB "enable use of GDB" OFF) -option(GKLIB_ASSERT "turn asserts on" OFF) -option(GKLIB_ASSERT2 "additional assertions" OFF) -option(GKLIB_DEBUG "add debugging support" OFF) -option(GKLIB_GPROF "add gprof support" OFF) -option(GKLIB_VALGRIND "add valgrind support" OFF) -option(GKLIB_OPENMP "enable OpenMP support" OFF) -option(GKLIB_PCRE "enable PCRE support" OFF) -option(GKLIB_GKREGEX "enable GKREGEX support" OFF) -option(GKLIB_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(GKLIB_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(GKLIB_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(GKLIB_OPENMP) - include(FindOpenMP) - if(GKLIB_OPENMP_FOUND) - set(GK_COPTIONS "${GK_COPTIONS} -D__OPENMP__ ${OpenMP_C_FLAGS}") - else() - message(WARNING "OpenMP was requested but support was not found") - endif(GKLIB_OPENMP_FOUND) -endif(GKLIB_OPENMP) - - -# Add various definitions. -if(GKLIB_GDB) - set(GK_COPTS "${GK_COPTS} -g") - set(GK_COPTIONS "${GK_COPTIONS} -Werror") -else() - set(GK_COPTS "-O3") -endif(GKLIB_GDB) - - -if(GKLIB_DEBUG) - set(GK_COPTS "-Og") - set(GK_COPTIONS "${GK_COPTIONS} -DDEBUG") -endif(GKLIB_DEBUG) - -if(GKLIB_GPROF) - set(GK_COPTS "-pg") -endif(GKLIB_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(GKLIB_PCRE) - set(GK_COPTIONS "${GK_COPTIONS} -D__WITHPCRE__") -endif(GKLIB_PCRE) - -if(GKLIB_GKREGEX) - set(GK_COPTIONS "${GK_COPTIONS} -DUSE_GKREGEX") -endif(GKLIB_GKREGEX) - -if(GKLIB_GKRAND) - set(GK_COPTIONS "${GK_COPTIONS} -DUSE_GKRAND") -endif(GKLIB_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_CURRENT_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}") - From 3d1068b0acbbab3ede480521d0dab6e1c231f8dd Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 12:48:57 +0200 Subject: [PATCH 11/21] [Temp] Link to fork project Signed-off-by: Cristian Le --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5956508..0053ab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,8 +76,8 @@ set(BUILD_SHARED_LIBS ${METIS_SHARED_LIBS}) ]==============================================================================================] FetchContent_Declare(GKlib - GIT_REPOSITORY https://github.com/KarypisLab/GKlib - GIT_TAG master + GIT_REPOSITORY https://github.com/LecrisUT/GKlib + GIT_TAG cmake/modernization FIND_PACKAGE_ARGS CONFIG ) FetchContent_MakeAvailable(GKlib) From 21ce25b6f136bc33a8d2df11ed833dfbffedc5ef Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 14:47:06 +0200 Subject: [PATCH 12/21] [Temp] Add -fPIC flag to imported GKlib Signed-off-by: Cristian Le --- libmetis/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt index bac6d50..6c55f40 100644 --- a/libmetis/CMakeLists.txt +++ b/libmetis/CMakeLists.txt @@ -37,6 +37,10 @@ target_sources(METIS_METIS PRIVATE ) 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 From 47c8e6beaac787d06d8a6e428b9cda6d7c4285c5 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 14:47:36 +0200 Subject: [PATCH 13/21] Refactor testsuite Signed-off-by: Cristian Le --- test/CMakeLists.txt | 71 ++++++++++++++++++++++++++++++++++----- test/mtest/CMakeLists.txt | 19 +++++++++++ test/{ => mtest}/mtest.c | 0 test/{ => mtest}/proto.h | 0 4 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 test/mtest/CMakeLists.txt rename test/{ => mtest}/mtest.c (100%) rename test/{ => mtest}/proto.h (100%) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d232e9e..8611b75 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,12 +1,65 @@ -add_executable(METIS_Test) +function(METIS_add_test test) + #[===[.md + # METIS_add_test -set_target_properties(METIS_Test PROPERTIES - OUTPUT_NAME mtest -) + Internal helper for adding GKlib tests -target_sources(METIS_Test PRIVATE - mtest.c -) -target_link_libraries(METIS_Test PRIVATE METIS_METIS) + ## 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 -# TODO: Add actual add_test using ../graphs + `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 + mtest +) + METIS_add_test(${test}) +endforeach () diff --git a/test/mtest/CMakeLists.txt b/test/mtest/CMakeLists.txt new file mode 100644 index 0000000..20927cb --- /dev/null +++ b/test/mtest/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.15) + +project(mtest + LANGUAGES C +) + +include(FetchContent) +FetchContent_Declare(METIS + GIT_REPOSITORY https://github.com/KarypisLab/GKlib + GIT_TAG master + FIND_PACKAGE_ARGS CONFIG +) +FetchContent_MakeAvailable(METIS) + +add_executable(mtest mtest.c) +target_link_libraries(mtest PRIVATE METIS::METIS) + +# TODO: Add actual add_test using ../../graphs +enable_testing() 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 From 2aab48924477f9eb25eb906113d740ba7e319ca1 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 14:50:33 +0200 Subject: [PATCH 14/21] Refactor project location to intuitive location Signed-off-by: Cristian Le --- CMakeLists.txt | 8 ++------ src/CMakeLists.txt | 4 ++++ {libmetis => src/libmetis}/CMakeLists.txt | 0 {libmetis => src/libmetis}/auxapi.c | 0 {libmetis => src/libmetis}/balance.c | 0 {libmetis => src/libmetis}/bucketsort.c | 0 {libmetis => src/libmetis}/checkgraph.c | 0 {libmetis => src/libmetis}/coarsen.c | 0 {libmetis => src/libmetis}/compress.c | 0 {libmetis => src/libmetis}/contig.c | 0 {libmetis => src/libmetis}/debug.c | 0 {libmetis => src/libmetis}/defs.h | 0 {libmetis => src/libmetis}/fm.c | 0 {libmetis => src/libmetis}/fortran.c | 0 {libmetis => src/libmetis}/frename.c | 0 {libmetis => src/libmetis}/gklib.c | 0 {libmetis => src/libmetis}/gklib_defs.h | 0 {libmetis => src/libmetis}/gklib_rename.h | 0 {libmetis => src/libmetis}/graph.c | 0 {libmetis => src/libmetis}/initpart.c | 0 {libmetis => src/libmetis}/kmetis.c | 0 {libmetis => src/libmetis}/kwayfm.c | 0 {libmetis => src/libmetis}/kwayrefine.c | 0 {libmetis => src/libmetis}/macros.h | 0 {libmetis => src/libmetis}/mcutil.c | 0 {libmetis => src/libmetis}/mesh.c | 0 {libmetis => src/libmetis}/meshpart.c | 0 {libmetis => src/libmetis}/metislib.h | 0 {libmetis => src/libmetis}/minconn.c | 0 {libmetis => src/libmetis}/mincover.c | 0 {libmetis => src/libmetis}/mmd.c | 0 {libmetis => src/libmetis}/ometis.c | 0 {libmetis => src/libmetis}/options.c | 0 {libmetis => src/libmetis}/parmetis.c | 0 {libmetis => src/libmetis}/pmetis.c | 0 {libmetis => src/libmetis}/proto.h | 0 {libmetis => src/libmetis}/refine.c | 0 {libmetis => src/libmetis}/rename.h | 0 {libmetis => src/libmetis}/separator.c | 0 {libmetis => src/libmetis}/sfm.c | 0 {libmetis => src/libmetis}/srefine.c | 0 {libmetis => src/libmetis}/stat.c | 0 {libmetis => src/libmetis}/stdheaders.h | 0 {libmetis => src/libmetis}/struct.h | 0 {libmetis => src/libmetis}/timing.c | 0 {libmetis => src/libmetis}/util.c | 0 {libmetis => src/libmetis}/wspace.c | 0 {programs => src/programs}/CMakeLists.txt | 0 {programs => src/programs}/cmdline_gpmetis.c | 0 {programs => src/programs}/cmdline_m2gmetis.c | 0 {programs => src/programs}/cmdline_mpmetis.c | 0 {programs => src/programs}/cmdline_ndmetis.c | 0 {programs => src/programs}/cmpfillin.c | 0 {programs => src/programs}/defs.h | 0 {programs => src/programs}/gpmetis.c | 0 {programs => src/programs}/graphchk.c | 0 {programs => src/programs}/io.c | 0 {programs => src/programs}/m2gmetis.c | 0 {programs => src/programs}/metisbin.h | 0 {programs => src/programs}/mpmetis.c | 0 {programs => src/programs}/ndmetis.c | 0 {programs => src/programs}/proto.h | 0 {programs => src/programs}/smbfactor.c | 0 {programs => src/programs}/stat.c | 0 {programs => src/programs}/struct.h | 0 65 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 src/CMakeLists.txt rename {libmetis => src/libmetis}/CMakeLists.txt (100%) rename {libmetis => src/libmetis}/auxapi.c (100%) rename {libmetis => src/libmetis}/balance.c (100%) rename {libmetis => src/libmetis}/bucketsort.c (100%) rename {libmetis => src/libmetis}/checkgraph.c (100%) rename {libmetis => src/libmetis}/coarsen.c (100%) rename {libmetis => src/libmetis}/compress.c (100%) rename {libmetis => src/libmetis}/contig.c (100%) rename {libmetis => src/libmetis}/debug.c (100%) rename {libmetis => src/libmetis}/defs.h (100%) rename {libmetis => src/libmetis}/fm.c (100%) rename {libmetis => src/libmetis}/fortran.c (100%) rename {libmetis => src/libmetis}/frename.c (100%) rename {libmetis => src/libmetis}/gklib.c (100%) rename {libmetis => src/libmetis}/gklib_defs.h (100%) rename {libmetis => src/libmetis}/gklib_rename.h (100%) rename {libmetis => src/libmetis}/graph.c (100%) rename {libmetis => src/libmetis}/initpart.c (100%) rename {libmetis => src/libmetis}/kmetis.c (100%) rename {libmetis => src/libmetis}/kwayfm.c (100%) rename {libmetis => src/libmetis}/kwayrefine.c (100%) rename {libmetis => src/libmetis}/macros.h (100%) rename {libmetis => src/libmetis}/mcutil.c (100%) rename {libmetis => src/libmetis}/mesh.c (100%) rename {libmetis => src/libmetis}/meshpart.c (100%) rename {libmetis => src/libmetis}/metislib.h (100%) rename {libmetis => src/libmetis}/minconn.c (100%) rename {libmetis => src/libmetis}/mincover.c (100%) rename {libmetis => src/libmetis}/mmd.c (100%) rename {libmetis => src/libmetis}/ometis.c (100%) rename {libmetis => src/libmetis}/options.c (100%) rename {libmetis => src/libmetis}/parmetis.c (100%) rename {libmetis => src/libmetis}/pmetis.c (100%) rename {libmetis => src/libmetis}/proto.h (100%) rename {libmetis => src/libmetis}/refine.c (100%) rename {libmetis => src/libmetis}/rename.h (100%) rename {libmetis => src/libmetis}/separator.c (100%) rename {libmetis => src/libmetis}/sfm.c (100%) rename {libmetis => src/libmetis}/srefine.c (100%) rename {libmetis => src/libmetis}/stat.c (100%) rename {libmetis => src/libmetis}/stdheaders.h (100%) rename {libmetis => src/libmetis}/struct.h (100%) rename {libmetis => src/libmetis}/timing.c (100%) rename {libmetis => src/libmetis}/util.c (100%) rename {libmetis => src/libmetis}/wspace.c (100%) rename {programs => src/programs}/CMakeLists.txt (100%) rename {programs => src/programs}/cmdline_gpmetis.c (100%) rename {programs => src/programs}/cmdline_m2gmetis.c (100%) rename {programs => src/programs}/cmdline_mpmetis.c (100%) rename {programs => src/programs}/cmdline_ndmetis.c (100%) rename {programs => src/programs}/cmpfillin.c (100%) rename {programs => src/programs}/defs.h (100%) rename {programs => src/programs}/gpmetis.c (100%) rename {programs => src/programs}/graphchk.c (100%) rename {programs => src/programs}/io.c (100%) rename {programs => src/programs}/m2gmetis.c (100%) rename {programs => src/programs}/metisbin.h (100%) rename {programs => src/programs}/mpmetis.c (100%) rename {programs => src/programs}/ndmetis.c (100%) rename {programs => src/programs}/proto.h (100%) rename {programs => src/programs}/smbfactor.c (100%) rename {programs => src/programs}/stat.c (100%) rename {programs => src/programs}/struct.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0053ab3..d4a0ee9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,13 +107,9 @@ set_target_properties(METIS_METIS PROPERTIES ) add_library(METIS::METIS ALIAS METIS_METIS) -# Main definitions inside libmetis +# Main definitions inside src add_subdirectory(include) -add_subdirectory(libmetis) - -if (METIS_PROGRAMS) - add_subdirectory(programs) -endif () +add_subdirectory(src) # Testing if (METIS_TESTS) 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/libmetis/CMakeLists.txt b/src/libmetis/CMakeLists.txt similarity index 100% rename from libmetis/CMakeLists.txt rename to src/libmetis/CMakeLists.txt 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 100% rename from libmetis/metislib.h rename to src/libmetis/metislib.h 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/programs/CMakeLists.txt b/src/programs/CMakeLists.txt similarity index 100% rename from programs/CMakeLists.txt rename to src/programs/CMakeLists.txt 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 100% rename from programs/metisbin.h rename to src/programs/metisbin.h 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 From 75c14c3b184c0b61ac207116602d8be3c60b8bc6 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 15:12:32 +0200 Subject: [PATCH 15/21] Use standard OpenMP macros Signed-off-by: Cristian Le --- src/libmetis/metislib.h | 2 +- src/programs/metisbin.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libmetis/metislib.h b/src/libmetis/metislib.h index dc224f4..50274f0 100644 --- a/src/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/src/programs/metisbin.h b/src/programs/metisbin.h index ce9b54e..cbaf5a2 100644 --- a/src/programs/metisbin.h +++ b/src/programs/metisbin.h @@ -22,7 +22,7 @@ #include -#if defined(ENABLE_OPENMP) +#if defined(_OPENMP) #include #endif From d86ab47521b0229e3c8c7f04dfdcba6c6e0b9ac0 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 15:54:20 +0200 Subject: [PATCH 16/21] Add OpenMP option Signed-off-by: Cristian Le --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4a0ee9..1131126 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,8 @@ 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) @@ -75,10 +77,18 @@ set(BUILD_SHARED_LIBS ${METIS_SHARED_LIBS}) # External packages # ]==============================================================================================] +set(gklib_find_package_args CONFIG) +if (METIS_OpenMP) + set(GKLIB_OpenMP ON CACHE BOOL "METIS: overload" FORCE) + 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 CONFIG + FIND_PACKAGE_ARGS ${gklib_find_package_args} ) FetchContent_MakeAvailable(GKlib) From 40fa369b7c632e51a71e6f335c42c7607228249e Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 15:19:46 +0200 Subject: [PATCH 17/21] Add OpenMP GitHub action Signed-off-by: Cristian Le --- .github/workflows/step_test.yaml | 3 +++ cmake/CMakePresets-CI.json | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/step_test.yaml b/.github/workflows/step_test.yaml index d0f2f6c..1d7763a 100644 --- a/.github/workflows/step_test.yaml +++ b/.github/workflows/step_test.yaml @@ -17,11 +17,14 @@ jobs: fail-fast: false matrix: toolchain: [ gcc, llvm, intel, windows, macos ] + openmp: [ ON, OFF ] include: - os: windows-latest toolchain: windows - os: macos-latest toolchain: macos + env: + WITH_OPENMP: ${{ matrix.openmp }} steps: - name: Enable msvc toolchain on windows uses: ilammy/msvc-dev-cmd@v1 diff --git a/cmake/CMakePresets-CI.json b/cmake/CMakePresets-CI.json index f8b69c1..8d0ac90 100644 --- a/cmake/CMakePresets-CI.json +++ b/cmake/CMakePresets-CI.json @@ -19,6 +19,10 @@ "METIS_PROGRAMS": { "type": "BOOL", "value": true + }, + "METIS_OpenMP": { + "type": "BOOL", + "value": "$env{WITH_OPENMP}" } }, "errors": { From 777936690ef3978c59a4fcf5d0ac9219c1c40ec9 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 16:26:23 +0200 Subject: [PATCH 18/21] Disable tests. They are completely broken Signed-off-by: Cristian Le --- src/programs/CMakeLists.txt | 2 ++ test/CMakeLists.txt | 8 ++++++-- test/mtest/CMakeLists.txt | 28 ++++++++++++---------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/programs/CMakeLists.txt b/src/programs/CMakeLists.txt index d656408..9854ed8 100644 --- a/src/programs/CMakeLists.txt +++ b/src/programs/CMakeLists.txt @@ -46,6 +46,8 @@ target_sources(METIS_cli PRIVATE 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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8611b75..8090f66 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,7 +59,11 @@ function(METIS_add_test test) endfunction() foreach (test IN ITEMS - mtest ) - METIS_add_test(${test}) + # 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/mtest/CMakeLists.txt b/test/mtest/CMakeLists.txt index 20927cb..5f848da 100644 --- a/test/mtest/CMakeLists.txt +++ b/test/mtest/CMakeLists.txt @@ -1,19 +1,15 @@ -cmake_minimum_required(VERSION 3.15) - -project(mtest - LANGUAGES C +add_executable(METIS_mtest mtest.c) +set_target_properties(METIS_mtest PROPERTIES + OUTPUT_NAME mtest ) - -include(FetchContent) -FetchContent_Declare(METIS - GIT_REPOSITORY https://github.com/KarypisLab/GKlib - GIT_TAG master - FIND_PACKAGE_ARGS CONFIG +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 ) -FetchContent_MakeAvailable(METIS) - -add_executable(mtest mtest.c) -target_link_libraries(mtest PRIVATE METIS::METIS) -# TODO: Add actual add_test using ../../graphs -enable_testing() +# TODO: Link mtest to actual add_test From d8721f0811e4859f27be5a216820187b23072b9d Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 17:23:17 +0200 Subject: [PATCH 19/21] Add FetchContent wrapper This resolves the compatibility with `set_package_properties()` Signed-off-by: Cristian Le --- CMakeLists.txt | 5 +-- cmake/METIS.cmake | 35 +++++++++++++++++++++ cmake/compat/FetchContentGKlib_After.cmake | 4 +++ cmake/compat/FetchContentGKlib_Before.cmake | 3 ++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 cmake/METIS.cmake create mode 100644 cmake/compat/FetchContentGKlib_After.cmake create mode 100644 cmake/compat/FetchContentGKlib_Before.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1131126..6cc77b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,8 @@ add_feature_info(METIS_REAL64 METIS_REAL64 "Build with 64 bit floats") ]==============================================================================================] list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +# Add some helper functions +include(METIS) # Include basic tools include(FetchContent) @@ -79,7 +81,6 @@ set(BUILD_SHARED_LIBS ${METIS_SHARED_LIBS}) set(gklib_find_package_args CONFIG) if (METIS_OpenMP) - set(GKLIB_OpenMP ON CACHE BOOL "METIS: overload" FORCE) if (NOT COMPONENTS IN_LIST gklib_find_package_args) list(APPEND gklib_find_package_args COMPONENTS) endif () @@ -90,7 +91,7 @@ FetchContent_Declare(GKlib GIT_TAG cmake/modernization FIND_PACKAGE_ARGS ${gklib_find_package_args} ) -FetchContent_MakeAvailable(GKlib) +METIS_FetchContent_MakeAvailable(GKlib) include(METIS_PackagesInfo) 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/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 () From d5cd35837a5c1efe1265f921d26dc249100eb181 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 17:30:11 +0200 Subject: [PATCH 20/21] [Temp] Mark some environments as experimental Signed-off-by: Cristian Le --- .github/workflows/step_test.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/step_test.yaml b/.github/workflows/step_test.yaml index 1d7763a..15ee578 100644 --- a/.github/workflows/step_test.yaml +++ b/.github/workflows/step_test.yaml @@ -21,8 +21,15 @@ jobs: 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: From c2af072c1aea436f47ab9bf6fdd94a315ef58e65 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 27 Oct 2023 18:44:46 +0200 Subject: [PATCH 21/21] Remove outdated files and references Signed-off-by: Cristian Le --- .gitmodules | 0 BUILD-Windows.txt | 52 ----------------- Makefile | 101 --------------------------------- README.md | 66 ++------------------- test/Makefile | 44 -------------- utils/int2idxtype.sh | 12 ---- utils/listunescapedsymbols.csh | 4 -- utils/mkdist.sh | 13 ----- utils/s+r.sh | 10 ---- vsgen.bat | 8 --- 10 files changed, 4 insertions(+), 306 deletions(-) delete mode 100644 .gitmodules delete mode 100644 BUILD-Windows.txt delete mode 100644 Makefile delete mode 100644 test/Makefile delete mode 100755 utils/int2idxtype.sh delete mode 100755 utils/listunescapedsymbols.csh delete mode 100755 utils/mkdist.sh delete mode 100755 utils/s+r.sh delete mode 100644 vsgen.bat 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/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/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/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 ..\..\