nodejs / abi-stable-node

Repository used by the Node-API team to manage work related to Node-API and node-addon-api
239 stars 47 forks source link

Building addons with cmake #381

Closed mhdawson closed 4 years ago

mhdawson commented 5 years ago

See: https://github.com/nodejs/node-addon-api/issues/445

Creating issue so we make sure to discuss, ideally when we have @jschlight in the meeting.

mhdawson commented 4 years ago

Nicola, we should look at existing solutions like cmake-js and see if they need any updates to support node-addon-api.

Jim, the work he did for pre-build was for cmake-js.

Nicola, maybe we can move some of what Jim did for pre-build to cmake-js so that all dependencies can leverage that.

Jim, cmake-js is pretty generic, did not have to do much, only document what you needed there.

Nicola then it might just be a matter of documentation.

Jim will:

gengjiawen commented 4 years ago

node-gyp already support generate cmake config. I have used it in Clion, works pretty well (code autocomplete and debug).

jschlight commented 4 years ago

I've added a comment here about building N-API addons using CMake.js: https://github.com/nodejs/node-addon-api/issues/445#issuecomment-536057129

jschlight commented 4 years ago

During today's call we discussed the behavior of CMake.js when the underlying CMake executable is not installed. Here's what I found:

spare:~ jim$ npm install -g cmake-js
/Users/jim/.nvm/versions/node/v10.16.3/bin/cmake-js -> /Users/jim/.nvm/versions/node/v10.16.3/lib/node_modules/cmake-js/bin/cmake-js
+ cmake-js@6.0.0
added 140 packages from 108 contributors in 8.486s
spare:~ jim$ cmake
-bash: cmake: command not found
spare:~ jim$ cmake-js
[ '/Users/jim/.nvm/versions/node/v10.16.3/bin/node',
  '/Users/jim/.nvm/versions/node/v10.16.3/bin/cmake-js' ]
info TOOL Using Unix Makefiles generator.
ERR! OMG CMake executable is not found. Please use your system's package manager to install it, or you can get installers from there: http://cmake.org.
spare:~ jim$ 

CMake.js displays a message instructing the user to install the CMake executable if it is not found.

mhdawson commented 4 years ago

@jschlight thanks for checking that out. Great to see that it shows a good message.

jschlight commented 4 years ago

The PR merge should have closed this issue? But maybe the automatic close does not work between repos?