cmake-js

CMake.js - a Node.js native addon build tool

MIT License

Downloads
656.1K
Stars
859
Committers
60

Bot releases are visible (Hide)

cmake-js - v7.0.0 Latest Release

Published by Julusian about 2 years ago

This is a breaking change and will likely require some small changes to your cmake config to keep your project building.

Summary

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.

Upgrading

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.

All changes:

  • update dependencies
  • replace some dependencies with modern language features
  • follow node-gyp behaviour for visual-studio version detection and selection
  • automatically locate node-addon-api and add to include paths
  • avoid downloads when building for node-api
  • encourage use of MT builds with MSVC, rather than MD
cmake-js - v6.3.2 - 06/06/22

Published by Julusian over 2 years ago

  • fix: if --runtimeVerison must be explicitly specified if building for a different runtime
  • Update baseurl for electron mirror
cmake-js - Full support of Visual Studio 2019 (Gregor Jasny)

Published by unbornchikken over 4 years ago

cmake-js -

Published by unbornchikken over 4 years ago

cmake-js - VS detect fixes

Published by unbornchikken about 5 years ago

cmake-js - Electron 4+ compatibility

Published by unbornchikken over 5 years ago

cmake-js -

Published by unbornchikken over 5 years ago

cmake-js -

Published by unbornchikken over 5 years ago

cmake-js -

Published by unbornchikken about 6 years ago

cmake-js - Locating NAN and CMake.js fixed

Published by unbornchikken over 9 years ago

Bugxfix: Locating NAN and CMake.js fixed

cmake-js - Electron support

Published by unbornchikken over 9 years ago

cmake-js - Can be used as a library

Published by unbornchikken over 9 years ago

cmake-js - Fixing config placement in application's package.json file

Published by unbornchikken over 9 years ago

Root cmake-js key used instead of subkey of the standard config section.

cmake-js - v0.9.5

Published by unbornchikken over 9 years ago

Added nw.js compatibility.