metis: fix msvc runtime (#4150)

* metis: fix msvc runtime

* use xmake
pull/4152/head
star9029 6 months ago committed by GitHub
parent f43d0f9cfe
commit 78a87612e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      packages/g/gklib/port/xmake.lua
  2. 61
      packages/m/metis/patches/5.2.1/gklib.patch
  3. 59
      packages/m/metis/port/xmake.lua
  4. 28
      packages/m/metis/xmake.lua

@ -1,6 +1,6 @@
option("openmp", {showmenu = true, default = false})
option("regex", {showmenu = true, default = false})
option("rand", {showmenu = true, default = false})
option("openmp", {default = false})
option("regex", {default = false})
option("rand", {default = false})
add_rules("mode.debug", "mode.release")

@ -1,61 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a15d19a..7fb5cd0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,11 +3,7 @@ project(METIS C)
set(SHARED FALSE CACHE BOOL "build a shared library")
-if(MSVC)
- set(METIS_INSTALL FALSE)
-else()
- set(METIS_INSTALL TRUE)
-endif()
+set(METIS_INSTALL TRUE)
# Configure libmetis library.
if(SHARED)
@@ -16,7 +12,7 @@ else()
set(METIS_LIBRARY_TYPE STATIC)
endif(SHARED)
-include(./conf/gkbuild.cmake)
+include(${GKLIB_PATH}/GKlibSystem.cmake)
# METIS' custom options
#option(IDX64 "enable 64 bit ints" OFF)
@@ -37,8 +33,8 @@ include(./conf/gkbuild.cmake)
# Add include directories.
# i.e., the -I equivalent
-include_directories(build/xinclude)
-include_directories(${GKLIB_PATH}/include)
+include_directories(include)
+include_directories(${GKLIB_PATH})
include_directories(${CMAKE_INSTALL_PREFIX}/include)
# List of paths that the compiler will search for library files.
@@ -47,6 +43,5 @@ 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")
diff --git a/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt
index fc6cec6..e713c2c 100644
--- a/libmetis/CMakeLists.txt
+++ b/libmetis/CMakeLists.txt
@@ -5,7 +5,10 @@ include_directories(.)
file(GLOB metis_sources *.c)
# Build libmetis.
-add_library(metis ${METIS_LIBRARY_TYPE} ${metis_sources})
+if (MSVC)
+ set(GKlib_sources ${GKlib_sources} ${GKLIB_PATH}/win32/adapt.c)
+endif (MSVC)
+add_library(metis ${METIS_LIBRARY_TYPE} ${metis_sources} ${GKlib_sources})
if(METIS_INSTALL)
install(TARGETS metis

@ -0,0 +1,59 @@
option("tools", {default = false})
add_rules("mode.debug", "mode.release")
add_requires("gklib")
add_packages("gklib")
add_includedirs("include")
target("metis")
set_kind("$(kind)")
add_files("libmetis/*.c")
add_headerfiles("include/metis.h")
if is_plat("windows") and is_kind("shared") then
add_rules("utils.symbols.export_all")
end
if has_config("tools") then
target("tool_lib")
set_kind("static")
add_files(
"programs/io.c",
"programs/stat.c",
"programs/smbfactor.c"
)
on_install(function(target) end)
target("gpmetis")
set_kind("binary")
add_files("programs/gpmetis.c", "programs/cmdline_gpmetis.c")
add_deps("tool_lib")
target("ndmetis")
set_kind("binary")
add_files("programs/ndmetis.c", "programs/cmdline_ndmetis.c")
add_deps("tool_lib")
target("mpmetis")
set_kind("binary")
add_files("programs/mpmetis.c", "programs/cmdline_mpmetis.c")
add_deps("tool_lib")
target("m2gmetis")
set_kind("binary")
add_files("programs/m2gmetis.c", "programs/cmdline_m2gmetis.c")
add_deps("tool_lib")
target("graphchk")
set_kind("binary")
add_files("programs/graphchk.c")
add_deps("tool_lib")
target("cmpfillin")
set_kind("binary")
add_files("programs/cmpfillin.c")
add_deps("tool_lib")
end

@ -1,37 +1,29 @@
package("metis")
set_homepage("http://glaros.dtc.umn.edu/gkhome/metis/metis/overview")
set_description("Serial Graph Partitioning and Fill-reducing Matrix Ordering")
set_license("Apache-2.0")
add_urls("https://github.com/KarypisLab/METIS/archive/refs/tags/$(version).tar.gz")
add_versions("v5.2.1", "1a4665b2cd07edc2f734e30d7460afb19c1217c2547c2ac7bf6e1848d50aff7a")
add_urls("https://github.com/KarypisLab/METIS/archive/refs/tags/$(version).tar.gz",
"https://github.com/KarypisLab/METIS.git")
add_patches("5.2.1", "patches/5.2.1/gklib.patch", "63e5035241f23ee664800ec1811ea8baa69895c71ec007ab1a95103a290c11eb")
add_resources("5.2.1", "gklib", "https://github.com/KarypisLab/GKlib.git", "8bd6bad750b2b0d90800c632cf18e8ee93ad72d7")
add_versions("v5.2.1", "1a4665b2cd07edc2f734e30d7460afb19c1217c2547c2ac7bf6e1848d50aff7a")
add_configs("long_index", {description = "Use 64-bit uint as index.", default = false, type = "boolean"})
add_configs("double", {description = "Use double precision floats.", default = true, type = "boolean"})
add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
add_deps("gklib")
add_deps("cmake")
if is_plat("linux") then
add_syslinks("m")
end
on_install("windows", "macosx", "linux", function (package)
on_install("!iphoneos", function (package)
local idx_width = package:config("long_index") and 64 or 32
io.gsub(path.join("include", "metis.h"), "//#define IDXTYPEWIDTH %d+", "#define IDXTYPEWIDTH " .. idx_width)
local real_width = package:config("double") and 64 or 32
io.gsub(path.join("include", "metis.h"), "//#define REALTYPEWIDTH %d+", "#define REALTYPEWIDTH " .. real_width)
io.replace(path.join(package:resourcefile("gklib"), "gk_arch.h"), "gk_ms_stdint.h", "stdint.h", {plain = true})
io.replace(path.join(package:resourcefile("gklib"), "gk_arch.h"), "gk_ms_inttypes.h", "inttypes.h", {plain = true})
local configs = {}
table.insert(configs, "-DDEBUG=" .. (package:debug() and "ON" or "OFF"))
table.insert(configs, "-DSHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DGKLIB_PATH=" .. package:resourcefile("gklib"):gsub("\\", "/"))
import("package.tools.cmake").install(package, configs)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
import("package.tools.xmake").install(package, {tools = package:config("tools")})
end)
on_test(function (package)
assert(package:has_cxxfuncs("METIS_SetDefaultOptions", {includes = "metis.h"}))
assert(package:has_cfuncs("METIS_SetDefaultOptions", {includes = "metis.h"}))
end)

Loading…
Cancel
Save