Comparing version
@@ -1,2 +0,2 @@ | ||
v7.0.0 - unreleased | ||
v7.0.0 - 08/10/22 | ||
========== | ||
@@ -9,2 +9,3 @@ | ||
- avoid downloads when building for node-api | ||
- encourage use of MT builds with MSVC, rather than MD | ||
@@ -11,0 +12,0 @@ v6.3.1 - 05/06/22 |
@@ -138,2 +138,6 @@ "use strict"; | ||
// In some configurations MD builds will crash upon attempting to free memory. | ||
// This tries to encourage MT builds which are larger but less likely to have this crash. | ||
D.push({"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>"}) | ||
let incPaths = []; | ||
@@ -140,0 +144,0 @@ if (!this.options.isNodeApi) { |
@@ -24,3 +24,3 @@ { | ||
"main": "lib", | ||
"version": "7.0.0-3", | ||
"version": "7.0.0", | ||
"author": "Gábor Mező aka unbornchikken", | ||
@@ -53,11 +53,11 @@ "maintainers": [ | ||
"rc": "^1.2.7", | ||
"semver": "^7.3.7", | ||
"semver": "^7.3.8", | ||
"tar": "^6.1.11", | ||
"url-join": "^4.0.1", | ||
"which": "^2.0.2", | ||
"yargs": "^17.4.1" | ||
"yargs": "^17.6.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"nan": "^2.1.0", | ||
"nan": "^2.16.0", | ||
"node-addon-api": "^5.0.0" | ||
@@ -64,0 +64,0 @@ }, |
@@ -11,4 +11,6 @@ # CMake.js (MIT) | ||
- [NW.js](https://github.com/nwjs/nw.js): all CMake.js based native modules are compatible with NW.js out-of-the-box, there is no [nw-gyp like magic](https://github.com/nwjs/nw.js/wiki/Using-Node-modules#3rd-party-modules-with-cc-addons) required | ||
- [Electron](https://github.com/electron/electron) (formerly known as atom-shell): out-of-the-box build support, [no post build steps required](https://github.com/electron/electron/blob/main/docs/tutorial/using-native-node-modules.md) | ||
- [Electron](https://github.com/electron/electron): out-of-the-box build support, [no post build steps required](https://github.com/electron/electron/blob/main/docs/tutorial/using-native-node-modules.md) | ||
If you use `node-api` for your module instead of `nan` it should be able to run on all the runtimes above without needing to be built separately for each. | ||
## Installation | ||
@@ -100,4 +102,10 @@ | ||
```cmake | ||
cmake_minimum_required(VERSION 3.15) | ||
cmake_policy(SET CMP0091 NEW) | ||
cmake_policy(SET CMP0042 NEW) | ||
project (your-addon-name-here) | ||
add_definitions(-DNAPI_VERSION=4) | ||
include_directories(${CMAKE_JS_INC}) | ||
@@ -108,6 +116,9 @@ | ||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") | ||
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) | ||
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) | ||
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() | ||
``` | ||
@@ -125,6 +136,8 @@ | ||
In your module folder you can access cmake-js commands if you install cmake-js globally: | ||
With cmake-js installed as a depdendency or devDependency of your module, you can access run commands directly with: | ||
``` | ||
npm install -g cmake-js | ||
npx cmake-js --help | ||
# OR | ||
yarn cmake-js --help | ||
``` | ||
@@ -258,2 +271,34 @@ | ||
#### Node-API and `node-addon-api` | ||
[ABI-stable Node.js API | ||
(Node-API)](https://nodejs.org/api/n-api.html#n_api_node_api), | ||
which was previously known as N-API, supplies a set of C | ||
APIs that allow to compilation and loading of native modules by | ||
different versions of Node.js that support Node-API which includes | ||
all versions of Node.js v10.x and later. | ||
To compile a native module that uses only the | ||
[plain `C` Node-API calls](https://nodejs.org/api/n-api.html#n_api_node_api), | ||
follow the directions for plain `node` native modules. | ||
You must also add the following lines to your CMakeLists.txt, to allow for building on windows | ||
``` | ||
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() | ||
``` | ||
To compile a native module that uses the header-only C++ wrapper | ||
classes provided by | ||
[`node-addon-api`](https://github.com/nodejs/node-addon-api), | ||
you need to make your package depend on it with: | ||
npm install --save node-addon-api | ||
cmake-js will then add it to the include search path automatically | ||
#### Electron | ||
@@ -276,3 +321,3 @@ | ||
To make compatible your NW.js application with any CMake.js based modules, write the following to your application's package.json file: | ||
To make compatible your NW.js application with any NAN CMake.js based modules, write the following to your application's package.json file (this is not neccessary for node-api modules): | ||
@@ -317,32 +362,2 @@ ```json | ||
#### Node-API and `node-addon-api` | ||
[ABI-stable Node.js API | ||
(Node-API)](https://nodejs.org/api/n-api.html#n_api_node_api), | ||
which was previously known as N-API, supplies a set of C | ||
APIs that allow to compilation and loading of native modules by | ||
different versions of Node.js that support Node-API which includes | ||
all versions of Node.js v10.x and later. | ||
To compile a native module that uses only the | ||
[plain `C` Node-API calls](https://nodejs.org/api/n-api.html#n_api_node_api), | ||
follow the directions for plain `node` native modules. | ||
You must also add the following lines to your CMakeLists.txt, to allow for building on windows | ||
``` | ||
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() | ||
``` | ||
To compile a native module that uses the header-only C++ wrapper | ||
classes provided by | ||
[`node-addon-api`](https://github.com/nodejs/node-addon-api), | ||
you need to make your package depend on it with: | ||
npm install --save node-addon-api | ||
cmake-js will then add it to the include search path automatically | ||
## Tutorials | ||
@@ -349,0 +364,0 @@ |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
108374
1.57%1856
0.16%1
-50%378
4.13%Updated
Updated