https://github.com/rawleyfowler/distribution-builder-cmake
A simple builder for C/C++ project FFI with Raku and CMake
https://github.com/rawleyfowler/distribution-builder-cmake
Last synced: about 1 year ago
JSON representation
A simple builder for C/C++ project FFI with Raku and CMake
- Host: GitHub
- URL: https://github.com/rawleyfowler/distribution-builder-cmake
- Owner: rawleyfowler
- License: artistic-2.0
- Created: 2023-01-25T22:18:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-15T14:42:40.000Z (over 3 years ago)
- Last Synced: 2025-02-13T08:54:22.817Z (over 1 year ago)
- Language: Raku
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
Distribution::Builder::Cmake
====
A dead simple way to build a CMake project for FFI with Raku.
[](https://github.com/rawleyfowler/Distribution-Builder-Cmake/actions)
Synopsis
========
Installation
=========
```shell
zef install Distribution::Builder::Cmake
```
Usage
=========
Assuming your Raku project keeps its CMake project in a folder called `my-cmake-project`, and your exported lib is `my-lib`.
Note, the final `.so` file will be `libmy-lib.so`.
In your `META6.json` you'll add the following:
```
{
...
"builder": "Distribution::Builder::Cmake",
"build": {
"lib": "my-lib",
"src-dir": "my-cmake-project"
}
...
}
```
**Note**: You may also provide a `install` field to specify the directory to install the library. This defaults to: `resources/libraries/lib.so`
The typical CMake project will look like (assuming your lib is `my-lib`):
```cmake
cmake_minimum_required(VERSION 3.9)
project(my-lib VERSION 1.0.0 DESCRIPTION "My lib!")
add_library(my-lib SHARED my-lib.cc)
set_target_properties(my-lib PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(my-lib PROPERTIES SOVERSION 1)
set_target_properties(my-lib PROPERTIES PUBLIC_HEADER my-lib.hh)
target_include_directories(my-lib PRIVATE .)
install(TARGETS my-lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
```
You can see an example of this in action in [this repo](https://github.com/rawleyfowler/Raku-Cpp-Example)
(Obviously, you'll need Make and CMake installed)
Author
======
COPYRIGHT AND LICENSE
=====================
Copyright 2023
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.