Skip to content

MikeMitterer/cmake-dart-extension-master

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmake-dart-extension-master

A quick and simple example for using CMAKE to build Dart native extension.

It is essentially for my own usage, but I'd be happy if it is useful to someone else. I am open to improvement and contributions.

This project creates the Dart package native_sample

Original Dart Documentation

Because it is so outdated 2012 I try to collect some useful information's here on CPP-Master

If you have some tips, tricks or other useful information's please file an issue report or add something to the Wiki! - Thanks!

Prepare your machine to build the LIB

This project uses "Config" and "configDart" CMake-File for configuration. You can find these file as usual on GitHub

    cmake_minimum_required(VERSION 3.6)
    
    # ENV is defined in .bashrc
    #   ( cmake-configs on GH: https://github.com/MikeMitterer/cmake)
    set(CMAKE_MODULE_PATH $ENV{CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH})
    
    # ┌──────────────────────────────────────────────────────────────────┐
    # │  Projects Settings                                               │
    # └──────────────────────────────────────────────────────────────────┘
    
    project(sample_extension)
    
    # Output bin, c++11 usw
    include(Config)
    
    # Only necessary if this module has QT-Siblings
    set(CMAKE_AUTOMOC OFF)
    
    # ┌──────────────────────────────────────────────────────────────────┐
    # │  Dart (Make sure you have '-std=c++11' for CMAKE_CXX_FLAGS       │
    # └──────────────────────────────────────────────────────────────────┘
    
    include(configDart)
    #...

Prerequisites

  • cmake
  • clang (I'm using clang 8 on Mac and 3.8 on Linux)
  • Dart

What to do next

**This should build the native lib on your system and copy it to dart/lib/native **

Why spdlog

I am just curios how it plays together with Dart + native extensions...

Hint

Check out entr

cmake-dart-extension-master $

    ls * | entr sh -c "cd dart; dart bin/random.dart"

Every time a file in cmake-dart-extension-master changes "entr" executes dart bin/random.dart - nice for testing!