CMake.js - a Node.js native addon build tool
MIT License
Bot releases are hidden (Show)
This is a breaking change and will likely require some small changes to your cmake config to keep your project building.
A lot of work has gone into this release, to try and make the general usage of the library smoother. It has better support for building modules with node-api. The on disk footprint of the library is much smaller than before, with various dependencies removed, or updated.
We recommend having the following at the top of your cmake file, before the project(...)
definition.
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)
This will force MSVC to do a MT build, so if you were doing that another way, it should be possible to remove that. If you need to keep it building as MD, you can add set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
in your cmake file.
If you are using node-api, make sure that your package.json
has the following, but with the correct NAPI_VERSION filled in. We use this to autodetect that your module is building with node-api.
"binary": {
"napi_versions": [7]
},
You should also add the following to the bottom of your cmake file. This lets us avoid downloading the full nodejs headers, and lets us use bundle a much more lightweight copy instead
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
endif()
If you have something like:
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
in your file, it is no longer needed. We will inject the correct include paths for you, similar to what is done for nan
.
That should be everything.
If we missed something in these steps, or if you are having problems getting your module building again, let us know in an issue.
Published by Julusian over 2 years ago
Published by unbornchikken over 4 years ago
Published by unbornchikken about 5 years ago
Published by unbornchikken over 5 years ago
Published by unbornchikken over 9 years ago
Bugxfix: Locating NAN and CMake.js fixed
Published by unbornchikken over 9 years ago
Published by unbornchikken over 9 years ago
Published by unbornchikken over 9 years ago
Root cmake-js
key used instead of subkey of the standard config
section.
Published by unbornchikken over 9 years ago
Added nw.js compatibility.