Commit 74658931 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

add the wrapper demo version

parent 90ae6cfc
name = "SBML"
uuid = "e5567a89-2604-4b09-9718-f5f78e97c3bb"
authors = ["Mirek Kratochvil <exa.exa@gmail.com>"]
version = "0.1.0"
# SBML.jl
\ No newline at end of file
# SBML.jl
.*.swp
*.o
*.so
/build
project(sbml-cxxwrapjl)
cmake_minimum_required(VERSION 3.18)
set(CMAKE_MACOSX_RPATH 1)
#TODO why? set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
find_package(JlCxx REQUIRED)
get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION)
get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}")
message(STATUS "Found JlCxx at ${JlCxx_location}")
find_package(PkgConfig)
pkg_check_modules(SBML libsbml REQUIRED)
add_library(sbml-cxxwrapjl SHARED
src/cxxwrap.cpp
src/versions.cpp
)
target_include_directories(sbml-cxxwrapjl PUBLIC ${SBML_INCLUDEDIR})
target_link_directories(sbml-cxxwrapjl PUBLIC ${SBML_LIBDIR})
target_link_libraries(sbml-cxxwrapjl
${SBML_LIBRARIES}
JlCxx::cxxwrap_julia)
# libSBML CxxWrap julia integration
Dependencies:
- libSBML installed in `SBMLPREFIX` (replace below)
- `CxxWrap` package installed in Julia
Compilation:
```sh
mkdir build; cd build
PKG_CONFIG_PATH=$SBMLPREFIX/lib/pkgconfig cmake \
-DCMAKE_INSTALL_PREFIX=$SBMLPREFIX \
-DCMAKE_PREFIX_PATH=`julia -e 'using CxxWrap; println(CxxWrap.prefix_path());'` \
..
make
```
You can use `make install` to actually install it to the SBML prefix location,
but the library can also be loaded right from the build directory.
Loading from Julia:
```julia
module SBML
using CxxWrap
@wrapmodule("path-to-build/libsbml-cxxwrapjl.so")
function __init__()
@initcxx
end
end
```
Usage from Julia:
```julia
julia> SBML.getLibSBMLDottedVersion()
"5.19.0"
```
#include "jlcxx/jlcxx.hpp"
#include "versions.hpp"
JLCXX_MODULE
define_julia_module(jlcxx::Module &mod)
{
define_sbml_versions(mod);
}
#!/bin/sh
cd `dirname $0`
clang-format -style='{BasedOnStyle: Mozilla, AccessModifierOffset: -1, IndentCaseBlocks: false, PointerAlignment: Right}' -verbose -i *.cpp *.hpp
#include "versions.hpp"
#include <sbml/SBMLTypes.h>
#include <string>
inline static std::string
notnull_string(const char *s)
{
if (s)
return std::string(s);
else
return std::string();
}
JLCXX_MODULE
define_sbml_versions(jlcxx::Module &mod)
{
mod.method("getLibSBMLDottedVersion",
[]() -> std::string { return getLibSBMLDottedVersion(); });
mod.method("getLibSBMLVersionString",
[]() -> std::string { return getLibSBMLVersionString(); });
mod.method("getLibSBMLVersion", []() { return getLibSBMLVersion(); });
mod.method("isLibSBMLCompiledWith", [](const std::string &s) -> bool {
return isLibSBMLCompiledWith(s.c_str());
});
mod.method("getLibSBMLDependencyVersionOf",
[](const std::string &s) -> std::string {
return notnull_string(getLibSBMLDependencyVersionOf(s.c_str()));
});
}
#include "jlcxx/jlcxx.hpp"
JLCXX_MODULE
define_sbml_versions(jlcxx::Module &);
module SBML
using CxxWrap
# TODO: load the libsbml project from the BinaryBuilder destination
@wrapmodule("./libsbml-cxxwrapjl.so")
function __init__()
@initcxx
end
end # module
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment