vcpkg/ports/metis/build-fixes.patch
Billy O'Neal 63d08e949d
[gklib,metis,parmetis] Update sources for metis et al. to GitHub (#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 https://github.com/microsoft/vcpkg/issues/25764

Competes with https://github.com/microsoft/vcpkg/pull/25953

* [parmetis] Update source to github.

* Add licenses.

* Fix GKlib case.

* Fix metis install.
2022-08-03 18:59:36 -07:00

145 lines
4.4 KiB
Diff

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