4.0.3 • Published 6 months ago

cnoke v4.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Table of contents

Introduction

CNoke is a simpler alternative to CMake.js, without any dependency, designed to build native Node addons based on CMake.

Install it like this:

npm install cnoke

It obviously requires CMake and a proper C/C++ toolchain:

  • Windows: Visual C++ Build Tools or a recent version of Visual C++ will do (the free Community version works well)
  • POSIX (Linux, macOS, etc.): Clang or GCC, and Make (Ninja is preferred if available)

Get started

In order to build a native Node.js addon with CNoke, you can use the following CMakeLists.txt template to get started:

cmake_minimum_required(VERSION 3.11)
project(hello C CXX)

find_package(CNoke)

add_node_addon(NAME hello SOURCES hello.cc)

You can also do it manually (without the module) if you prefer:

cmake_minimum_required(VERSION 3.11)
project(hello C CXX)

add_library(hello SHARED hello.cc ${NODE_JS_SOURCES})
set_target_properties(hello PROPERTIES PREFIX "" SUFFIX ".node")
target_include_directories(hello PRIVATE ${NODE_JS_INCLUDE_DIRS})
target_link_libraries(hello PRIVATE ${NODE_JS_LIBRARIES})
target_compile_options(hello PRIVATE ${NODE_JS_COMPILE_FLAGS})
target_link_options(hello PRIVATE ${NODE_JS_LINK_FLAGS})

In order for this to run when npm install runs (directly or when someone else installs your dependency), add the following script to package.json:

"scripts": {
    "install": "cnoke"
}

Command usage

You can find the same help text by running cnoke --help:

Usage: cnoke [command] [options...] [targets...]

Commands:
    configure                            Configure CMake build
    build                                Build project (configure if needed)
    clean                                Clean build files

Options:
    -d, --directory <DIR>                Change project directory
                                         (default: current working directory)

    -B, --config <CONFIG>                Change build type: RelWithDebInfo, Debug, Release
                                         (default: RelWithDebInfo)
    -D, --debug                          Shortcut for --config Debug

        --prebuild <URL>                 Set URL template to download prebuilt binaries
        --require <PATH>                 Require specified module, drop prebuild if it fails

    -a, --arch <ARCH>                    Change architecture and ABI
                                         (default: x64)
    -v, --runtime-version <VERSION>      Change node version
                                         (default: v16.14.0)
    -t, --toolset <TOOLSET>              Change default CMake toolset
    -C, --prefer-clang                   Use Clang instead of default CMake compiler

        --verbose                        Show build commands while building

The ARCH value is similar to process.arch, with the following differences:

  • arm is changed to arm32hf or arm32sf depending on the floating-point ABI used (hard-float, soft-float)
  • riscv32 is changed to riscv32sf, riscv32hf32, riscv32hf64 or riscv32hf128 depending on the floating-point ABI
  • riscv64 is changed to riscv64sf, riscv64hf32, riscv64hf64 or riscv64hf128 depending on the floating-point ABI
4.0.1

8 months ago

4.0.0

8 months ago

4.0.3

6 months ago

4.0.2

8 months ago

3.3.2

1 year ago

3.3.1

1 year ago

3.3.0

1 year ago

3.2.2

1 year ago

3.2.1

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.4

2 years ago

3.0.0

2 years ago

1.0.2

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.9.25

2 years ago

0.9.26

2 years ago

0.9.24

2 years ago

0.9.23

2 years ago

0.9.22

2 years ago

0.9.21

2 years ago

0.9.20

2 years ago

0.9.19

2 years ago

0.9.18

2 years ago

0.9.17

2 years ago

0.9.16

2 years ago

0.9.15

2 years ago

0.9.14

2 years ago

0.9.13

2 years ago

0.9.12

2 years ago

0.9.11

2 years ago

0.9.10

2 years ago

0.9.9

2 years ago

0.9.8

2 years ago

0.9.7

2 years ago

0.9.6

2 years ago