Skip to content

Commit 567980e

Browse files
authored
Replace node-cmake w/ CMake.js. Fix Windows Node.js build failure for Node.js v22+ (dropped x86 support) (#7451)
1 parent b28899e commit 567980e

5 files changed

Lines changed: 368 additions & 466 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ endif()
8585
# add @loader_path/$ORIGIN to rpath to make binaries relocatable
8686
if (APPLE)
8787
set(CMAKE_BUILD_RPATH "@loader_path")
88-
else()
88+
elseif(NOT WIN32)
8989
set(CMAKE_BUILD_RPATH "\$ORIGIN")
9090
# https://stackoverflow.com/questions/6324131/rpath-origin-not-having-desired-effect
9191
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,origin")

cmake/get-node-api-def.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
// Helper used by src/nodejs/CMakeLists.txt to locate the node_api.def file
3+
// that is bundled inside the node-api-headers package (a dependency of cmake-js).
4+
// We resolve it through cmake-js's own require context so the lookup always
5+
// finds the copy that cmake-js expects, regardless of npm hoisting.
6+
'use strict'
7+
8+
const Module = require('module')
9+
const path = require('path')
10+
11+
const cmakeJsPkg = require.resolve(
12+
path.join(__dirname, '..', 'node_modules', 'cmake-js', 'package.json'))
13+
const req = Module.createRequire(cmakeJsPkg)
14+
const defPath = req('node-api-headers').def_paths.node_api_def
15+
16+
process.stdout.write(defPath)

0 commit comments

Comments
 (0)