Skip to content

Commit 402c02b

Browse files
fix(nix): windows build of mt-kahypar
1 parent c3d628b commit 402c02b

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"x86_64-linux"
1717
];
1818

19+
# The Windows build of Boost seems to be broken, so we use an older version instead.
20+
boost = pkgs: if pkgs.stdenv.hostPlatform.isWindows then pkgs.boost183 else pkgs.boost;
21+
1922
# If building for Windows, appends -windows, otherwise nothing.
2023
windowsSuffix = pkgs: name: if pkgs.stdenv.hostPlatform.isWindows then "${name}-windows" else name;
2124

@@ -107,11 +110,13 @@
107110
arjun = pkgs-static.callPackage ./nix/arjun.nix {
108111
cryptominisat = self.packages.${system}.cryptominisat;
109112
sbva = self.packages.${system}.sbva;
113+
boost = boost pkgs-static;
110114
};
111115

112116
arjun-windows = pkgs-windows.callPackage ./nix/arjun.nix {
113117
cryptominisat = self.packages.${system}.cryptominisat-windows;
114118
sbva = self.packages.${system}.sbva-windows;
119+
boost = boost pkgs-windows;
115120
};
116121

117122
gpmc = pkgs-static.callPackage ./nix/gpmc.nix {
@@ -124,8 +129,8 @@
124129
cryptominisat = self.packages.${system}.cryptominisat-windows;
125130
};
126131

127-
mt-kahypar = pkgs.callPackage ./nix/mt-kahypar.nix { };
128-
mt-kahypar-windows = pkgs-windows.callPackage ./nix/mt-kahypar.nix { };
132+
mt-kahypar = pkgs.callPackage ./nix/mt-kahypar.nix { boost = boost pkgs; };
133+
mt-kahypar-windows = pkgs-windows.callPackage ./nix/mt-kahypar.nix { boost = boost pkgs-windows; };
129134

130135
d4 = pkgs.callPackage ./nix/d4.nix {
131136
mt-kahypar = self.packages.${system}.mt-kahypar;
@@ -136,6 +141,7 @@
136141
glucose = self.packages.${system}.glucose;
137142
cadical = self.packages.${system}.cadical;
138143
cadiback = self.packages.${system}.cadiback;
144+
boost = boost pkgs;
139145
};
140146

141147
d4-windows = pkgs-windows.callPackage ./nix/d4.nix {
@@ -147,6 +153,7 @@
147153
glucose = self.packages.${system}.glucose-windows;
148154
cadical = self.packages.${system}.cadical-windows;
149155
cadiback = self.packages.${system}.cadiback-windows;
156+
boost = boost pkgs-windows;
150157
};
151158

152159
container = pkgs.dockerTools.buildLayeredImage {

nix/mt-kahypar-cmake.patch

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 62b55d3a..22d067f9 100644
2+
index 854e52a6..64064719 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -262,30 +262,32 @@ set(KAHYPAR_PYBIND11_VERSION v2.13.6)
5+
@@ -263,30 +263,27 @@ set(KAHYPAR_PYBIND11_VERSION v2.13.6)
66
message(STATUS "Fetching dependencies...")
77

88
# Include header-only dependencies
@@ -15,38 +15,34 @@ index 62b55d3a..22d067f9 100644
1515
+ OVERRIDE_FIND_PACKAGE
1616
)
1717
-FetchContent_Populate(
18-
+
1918
+FetchContent_Declare(
2019
WHFC QUIET EXLUDE_FROM_ALL
2120
GIT_REPOSITORY https://github.com/larsgottesbueren/WHFC.git
2221
GIT_TAG ${KAHYPAR_WHFC_TAG}
2322
SOURCE_DIR external_tools/WHFC
24-
+ OVERRIDE_FIND_PACKAGE
25-
)
23+
-)
2624
-FetchContent_Populate(
2725
- growt QUIET EXLUDE_FROM_ALL
2826
- GIT_REPOSITORY https://github.com/TooBiased/growt.git
2927
- GIT_TAG ${KAHYPAR_GROWT_TAG}
3028
- SOURCE_DIR external_tools/growt
31-
-)
32-
+
33-
+find_package(kahypar-shared-resources)
34-
+find_package(WHFC)
35-
+
36-
+include(CMakePrintHelpers)
29+
+ OVERRIDE_FIND_PACKAGE
30+
)
3731

38-
target_include_directories(MtKaHyPar-Include INTERFACE
32+
-target_include_directories(MtKaHyPar-Include INTERFACE
3933
- ${CMAKE_CURRENT_BINARY_DIR}/external_tools/kahypar-shared-resources
4034
- ${CMAKE_CURRENT_BINARY_DIR}/external_tools/growt
4135
- ${CMAKE_CURRENT_BINARY_DIR}/external_tools/WHFC)
36+
+find_package(kahypar-shared-resources)
37+
+find_package(WHFC)
38+
39+
+target_include_directories(MtKaHyPar-Include INTERFACE
4240
+ ${kahypar-shared-resources_SOURCE_DIR}
4341
+ ${WHFC_SOURCE_DIR})
4442

45-
+cmake_print_properties(TARGETS ${PROJECT_NAME} PROPERTIES LOCATION INCLUDE_DIRECTORIES)
46-
4743
if (KAHYPAR_ENABLE_TESTING)
4844
FetchContent_Declare(
49-
@@ -437,11 +439,6 @@ if (KAHYPAR_X86 AND KAHYPAR_ENABLE_EXTENDED_INSTRUCTIONS)
45+
@@ -438,11 +435,6 @@ if (KAHYPAR_X86 AND KAHYPAR_ENABLE_EXTENDED_INSTRUCTIONS)
5046
if(BUILTIN_POPCNT)
5147
target_compile_options(MtKaHyPar-BuildFlags INTERFACE -msse4.2)
5248
endif()
@@ -58,3 +54,16 @@ index 62b55d3a..22d067f9 100644
5854
endif()
5955

6056
if(KAHYPAR_ENABLE_ARCH_COMPILE_OPTIMIZATIONS)
57+
@@ -506,10 +498,8 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
58+
DEPENDS MtKaHyPar-CLI)
59+
endif()
60+
61+
- if(NOT WIN32 AND BUILD_SHARED_LIBS)
62+
- # library installation target
63+
- include(SetupInstallation)
64+
- endif()
65+
+ # library installation target
66+
+ include(SetupInstallation)
67+
68+
if(KAHYPAR_BUILD_DEBIAN_PACKAGE)
69+
# packaging via CPack

nix/mt-kahypar.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ stdenv.mkDerivation rec {
5959
cmakeFlags = [
6060
"-D FETCHCONTENT_SOURCE_DIR_KAHYPAR-SHARED-RESOURCES=${shared-resources}"
6161
"-D FETCHCONTENT_SOURCE_DIR_WHFC=${WHFC}"
62-
];
62+
] ++ lib.optionals stdenv.hostPlatform.isWindows [ "-D BUILD_SHARED_LIBS=ON" ];
6363

6464
buildPhase = "cmake --build . --target mtkahypar --parallel $NIX_BUILD_CORES";
6565
installPhase = "cmake --install .";

0 commit comments

Comments
 (0)