cmake-build
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

cmake-build

Build Version Downloads

Utility for configuring and building CMake projects with NPM packages support. Basic cross-compile features are provided (building for another system from a host system).

CMake NPM packages

Link CMake projects installed from NPM packages

include(npm.cmake)
  • Add cmake-build to your package.json in dependencies section (not devDependencies because we want to resolve dependencies after install automatically)
  • Add include(npm.cmake) to the beginning of your CMakeLists.txt
  • Run npx cmake-build to generate configuration module npm.cmake with resolved NPM dependencies

Package name convention

  • Scoped NPM package name @scope/package-name transforms to CMake target scope::package-name
  • Packages without scope is not transform

Cross-compile

Status

  • [x] MacOS
    • [x] Android
    • [x] WebAssembly
    • [x] iOS
    • [x] macOS
    • [x] Windows (Mingw)
    • [x] Linux (Docker)
  • [ ] Windows
  • [ ] Linux

Requirements

macOS

Install Mingw for building Windows platform.

brew install mingw-w64

Install docker and follow guides how to build from images.

IDE

It's very hard to fix platform-side code inside generated projects (XCode, Android Studio), so we able to switch platform inside your cmake-compatible IDE (like CLion).

  1. Create Debug-Emscripten
  2. Set the path to CMake Emscripten Toolchain
# Emscripten
-DCMAKE_TOOLCHAIN_FILE=/Users/PATH_TO_emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake

# iOS (https://github.com/leetal/ios-cmake/blob/master/ios.toolchain.cmake)
-DPLATFORM=SIMULATOR64 -DCMAKE_TOOLCHAIN_FILE=./cmake/ios.cmake

# Android
-DANDROID_ABI=x86_64 -DCMAKE_TOOLCHAIN_FILE=/Users/USER/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake

# Windows from MacOS
brew install mingw-w64
-DCMAKE_TOOLCHAIN_FILE=./cmake/mingw-w64-x86_64.cmake

Docker

Docker files for cross-platform building

# build docker image for linux build
cd images/linux
docker build -t eliasku/ubuntu:1.0 .

# run docker in your current project dir
cd your/project/path
docker run -it --mount type=bind,source=$(pwd),target=/mnt eliasku/ubuntu:1.0 /bin/sh -c "cd /mnt && bash"

Readme

Keywords

none

Package Sidebar

Install

npm i cmake-build

Weekly Downloads

1

Version

0.0.6

License

ISC

Unpacked Size

68.1 kB

Total Files

19

Last publish

Collaborators

  • eliasku