Add CMake + Vcpkg example by Pospelove · Pull Request #575 · nodejs/node-addon-examples

Hello everyone, and thanks for the interest! I’m planning to finish this PR by adding a C++ example and running the necessary tests.

There are a few points I’d like to discuss further, as they might need some consensus:

  1. vcpkg submodule: In the draft, I’ve included a vcpkg submodule, which is the recommended approach for manifest mode. Do you think we should stick with this? Or would it be better to simply mention it as an option, provide a link to the relevant documentation, and let users rely on their system-installed vcpkg instead?

  2. CMake/CMake.js naming: @gabrielschulhof raised a good point about the naming inconsistency between cmake and cmakejs. I’d love to hear your thoughts on how we can make this clearer.

I updated the CMake.js section of the docs because the mismatch between CMake and CMake.js can be confusing for developers who are coming from a C++ background.

To provide some context, the node-api-headers and node-addon-api vcpkg ports are quite handy for building native addons without needing CMake.js or npm at all. Here’s why they might be a good fit for many projects:

  1. They’re ideal for existing C++ projects that are already managed with CMake and vcpkg, where CMake.js isn’t typically used.
  2. They make it straightforward to connect Node.js to your C++ code—similar to integrating Lua or Boost.Python. But! Unlike the C++ Embedder API, this method still creates a native addon.