Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
[gklib,metis,parmetis] Update sources for metis et al. to GitHub (mic…
Browse files Browse the repository at this point in the history
…rosoft#26020)

* Remove bogus arguments in the `vcpkg create` template.

* [gklib] Add new port in support of metis and parmetis.

New port checklist:
* Review the code :)
* Check the name against https://repology.org/ There are 2 packages, both of which seem to be the same thing
* Check the name against Bing/Google. It's the first entry.
* Check the source code for optional `find_package`s There are none.
* Check that the versioning scheme and license match what upstream says They have none.
* Check that the source code comes from the upstream project's authoritative source. We did.
* Check that the generated usage is accurate.
* Check that the reported license is accurate. We hope so.

* [metis] Update source to github.

Resolves microsoft#25764

Competes with microsoft#25953

* [parmetis] Update source to github.

* Add licenses.

* Fix GKlib case.

* Fix metis install.
  • Loading branch information
BillyONeal authored and ooeygui committed Aug 25, 2022
1 parent 3848fb7 commit 0e822ca
Show file tree
Hide file tree
Showing 27 changed files with 463 additions and 309 deletions.
87 changes: 87 additions & 0 deletions ports/gklib/build-fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9cd1b4b..a6b629e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.22)
project(GKlib C)

option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
@@ -22,10 +22,12 @@ if(UNIX)
target_link_libraries(GKlib m)
endif(UNIX)

-include_directories("test")
-add_subdirectory("test")
-
-install(TARGETS GKlib
- ARCHIVE DESTINATION lib/${LINSTALL_PATH}
- LIBRARY DESTINATION lib/${LINSTALL_PATH})
-install(FILES ${GKlib_includes} DESTINATION include/${HINSTALL_PATH})
+install(TARGETS GKlib EXPORT GKlibTargets
+ INCLUDES DESTINATION "include/GKlib"
+ )
+install(FILES ${GKlib_includes} DESTINATION "include/GKlib")
+install(FILES "win32/adapt.h" DESTINATION "include/GKlib/win32")
+install(EXPORT GKlibTargets FILE "GKlibTargets.cmake" DESTINATION "share/GKlib")
+file(WRITE "${CMAKE_INSTALL_PREFIX}/share/GKlib/GKlibConfig.cmake" [=[
+include("${CMAKE_CURRENT_LIST_DIR}/GKlibTargets.cmake")
+]=])
diff --git a/GKlibSystem.cmake b/GKlibSystem.cmake
index d83b208..8019067 100644
--- a/GKlibSystem.cmake
+++ b/GKlibSystem.cmake
@@ -16,7 +16,6 @@ option(GKRAND "enable GKRAND support" OFF)

# Add compiler flags.
if(MSVC)
- set(GKlib_COPTS "/Ox")
set(GKlib_COPTIONS "-DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE -DUSE_GKREGEX")
elseif(MINGW)
set(GKlib_COPTS "-DUSE_GKREGEX")
@@ -34,7 +33,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC")
endif(NOT MINGW)
# GCC warnings.
- set(GKlib_COPTIONS "${GKlib_COPTIONS} -Werror -Wall -pedantic -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label")
+ set(GKlib_COPTIONS "${GKlib_COPTIONS} -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(GKlib_COPTIONS "${GKlib_COPTIONS} -xc99")
@@ -60,7 +59,7 @@ endif(OPENMP)
if(GDB)
set(GKlib_COPTS "${GKlib_COPTS} -g")
set(GKlib_COPTIONS "${GKlib_COPTIONS} -Werror")
-else()
+elseif(0)
set(GKlib_COPTS "-O3")
endif(GDB)

diff --git a/gk_arch.h b/gk_arch.h
index 8c8ac50..122e087 100644
--- a/gk_arch.h
+++ b/gk_arch.h
@@ -31,9 +31,9 @@
#endif


-#ifdef __MSC__
- #include "ms_stdint.h"
- #include "ms_inttypes.h"
+#ifdef __MSC__
+ #include <stdint.h>
+ #include <inttypes.h>
#include "ms_stat.h"
#include "win32/adapt.h"
#else
@@ -60,9 +60,4 @@ typedef ptrdiff_t ssize_t;
#define PTRDIFF_MAX INT64_MAX
#endif

-/* MSC does not have INFINITY defined */
-#ifndef INFINITY
-#define INFINITY FLT_MAX
-#endif
-
#endif
25 changes: 25 additions & 0 deletions ports/gklib/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KarypisLab/GKlib
REF b1cb3bd7f6bf4da641af901c8d455c0f858c816f
SHA512 e906c7af8b40ce1c4c4ea43cbfca3e3970e5595686333ac9ac80c6cbc558feb0e833f530f034161927030edac5272234c6ac9cad5287cb6edab0c0671ba3644c
PATCHES
build-fixes.patch
)

# Delete files that are workarounds for very old copies of msvc.
file(REMOVE "${SOURCE_PATH}/ms_inttypes.h" "${SOURCE_PATH}/ms_stdint.h")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME GKlib)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" [=[
gklib provides CMake targets:
find_package(GKlib CONFIG REQUIRED)
target_link_libraries(main PRIVATE GKlib)
]=])
17 changes: 17 additions & 0 deletions ports/gklib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "gklib",
"version-date": "2022-07-27",
"description": "General helper libraries for KarypisLab.",
"homepage": "https://github.com/KarypisLab/GKlib/",
"license": "Apache-2.0",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
144 changes: 144 additions & 0 deletions ports/metis/build-fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a15d19a..7210a61 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,9 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.22)
project(METIS C)

set(SHARED FALSE CACHE BOOL "build a shared library")

-if(MSVC)
+if(0)
set(METIS_INSTALL FALSE)
else()
set(METIS_INSTALL TRUE)
@@ -34,19 +34,13 @@ include(./conf/gkbuild.cmake)
#
#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("include")
add_subdirectory("libmetis")
-add_subdirectory("programs")
+
+install(EXPORT metisTargets FILE "metisTargets.cmake" DESTINATION "share/metis")
+file(WRITE "${CMAKE_INSTALL_PREFIX}/share/metis/metisConfig.cmake" [=[
+include(CMakeFindDependencyMacro)
+find_dependency(GKlib CONFIG)
+include("${CMAKE_CURRENT_LIST_DIR}/metisTargets.cmake")
+]=])
diff --git a/conf/gkbuild.cmake b/conf/gkbuild.cmake
index 96435e5..ff43f05 100644
--- a/conf/gkbuild.cmake
+++ b/conf/gkbuild.cmake
@@ -16,7 +16,6 @@ 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")
@@ -38,7 +37,7 @@ endif(VALGRIND)
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")
+ set(GK_COPTIONS "${GK_COPTIONS} -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")
@@ -69,7 +68,7 @@ endif(OPENMP)
if(GDB)
set(GK_COPTS "${GK_COPTS} -g")
set(GK_COPTIONS "${GK_COPTIONS} -Werror")
-else()
+elseif(0)
set(GK_COPTS "-O3")
endif(GDB)

diff --git a/include/metis.h b/include/metis.h
index 7fef0e7..f8e5dcf 100644
--- a/include/metis.h
+++ b/include/metis.h
@@ -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 32


/*--------------------------------------------------------------------------
@@ -40,7 +40,7 @@
32 : single precission floating point (float)
64 : double precission floating point (double)
--------------------------------------------------------------------------*/
-//#define REALTYPEWIDTH 32
+#define REALTYPEWIDTH 32



@@ -72,10 +72,14 @@ typedef __int64 int64_t;
#define PRId64 "I64d"
#define SCNd32 "ld"
#define SCNd64 "I64d"
+#ifdef _WIN32
+#include <stdint.h>
+#else
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
+#endif // ^^^ !_WIN32
#else
#include <inttypes.h>
#endif
diff --git a/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt
index fc6cec6..8aeb89a 100644
--- a/libmetis/CMakeLists.txt
+++ b/libmetis/CMakeLists.txt
@@ -6,10 +6,9 @@ file(GLOB metis_sources *.c)

# Build libmetis.
add_library(metis ${METIS_LIBRARY_TYPE} ${metis_sources})
+find_package(GKlib CONFIG REQUIRED)
+target_link_libraries(metis PUBLIC GKlib)
+target_include_directories(metis PRIVATE "../include")

-if(METIS_INSTALL)
- install(TARGETS metis
- LIBRARY DESTINATION lib
- RUNTIME DESTINATION lib
- ARCHIVE DESTINATION lib)
-endif()
+install(TARGETS metis EXPORT metisTargets
+ INCLUDES DESTINATION include)
diff --git a/libmetis/metislib.h b/libmetis/metislib.h
index dc224f4..1efccda 100644
--- a/libmetis/metislib.h
+++ b/libmetis/metislib.h
@@ -31,7 +31,7 @@
#include "proto.h"


-#if defined(COMPILER_MSC)
+#if defined(COMPILER_MSC) && (_MSC_VER < 1900)
#if defined(rint)
#undef rint
#endif
8 changes: 0 additions & 8 deletions ports/metis/disable-programs.patch

This file was deleted.

15 changes: 0 additions & 15 deletions ports/metis/enable-install.patch

This file was deleted.

34 changes: 0 additions & 34 deletions ports/metis/fix-INT_MIN_define.patch

This file was deleted.

11 changes: 0 additions & 11 deletions ports/metis/fix-gklib-vs14-math.patch

This file was deleted.

14 changes: 0 additions & 14 deletions ports/metis/fix-linux-build-error.patch

This file was deleted.

11 changes: 0 additions & 11 deletions ports/metis/fix-metis-vs14-math.patch

This file was deleted.

10 changes: 0 additions & 10 deletions ports/metis/fix-runtime-install-destination.patch

This file was deleted.

Loading

0 comments on commit 0e822ca

Please sign in to comment.