Skip to content

Commit

Permalink
Update build config, CI, and documentation
Browse files Browse the repository at this point in the history
- Increment patch version in CMakeLists.txt and add MATLAB mex build option
- Remove Windows-x64, Linux-x64, and upload release jobs from azure-pipelines.yml
- Expand building.markdown with detailed MATLAB and Octave build instructions
- Correct typo in building.drawio
- Simplify libCZI.cmake by setting build options and using FetchContent_MakeAvailable
  • Loading branch information
ptahmose committed Oct 19, 2024
1 parent 2039e0e commit 08a67af
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 95 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required (VERSION 3.11)

set(MEXLIBCZI_MAJOR 0)
set(MEXLIBCZI_MINOR 3)
set(MEXLIBCZI_PATCH 2)
set(MEXLIBCZI_PATCH 3)
set(MEXLIBCZI_EXT "alpha")

if(WIN32)
Expand All @@ -22,6 +22,8 @@ project ("MEXlibCZI"
DESCRIPTION "mex extension (for MATLAB and Octave) for reading/writing CZI-files with libCZI")

# Options controlling the CMake-build are gathered here

# When this option is ON, we build the mex extension for MATLAB. Otherwise, we don't build the mex extension for MATLAB.
option(MEXLIBCZI_BUILD_MATLABMEX "Build the mex extension for MATLAB" ON)

# include RapidJSON -> https://www.jibbow.com/posts/rapidjson-cmake/
Expand Down
82 changes: 0 additions & 82 deletions azure-pipelines.yml

This file was deleted.

28 changes: 28 additions & 0 deletions doc/building.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,31 @@ within Octave itself.
This way, the code for MATLAB and Octave is shared, but the build process is different.

![Building overview](pictures/build_architecture.png)]

## CMake

Executing the following command in the root directory of the project will build the mex-file for MATLAB
and the dynamic library for the Octave-mex-file:

```bash
mkdir build
cd build
cmake ..
cmake --build . -j
```

The CMake build system will try to located the MATLAB installation automatically. It is also possible to specify the paths for the folders containing the necessary headers and libraries
manually. This can be done by setting the CMake variables `MEXLIBCZI_HEADERS` and `MEXLIBCZI_LIBS`.

## Building the Octave mex-file

The Octave-mex-file is built from within Octave itself. The following commands are executed in the root directory of the project:

```bash
cd D:\dev\MyGitHub\MEXlibCZI\OctaveMex
mkoctfile --mex octavelibczi.c
```

This will create the mex-file "octavelibczi.mex" in the current directory. This mex-file is a stub and at runtime loads the dynamic library "libmexlibczi".
For the Octave-mex-file to work, the dynamic library "libmexlibczi" must be present in the same directory. This library is built using CMake, and must be copied
manually to the directory where the mex-file is located.
2 changes: 1 addition & 1 deletion doc/pictures/building.drawio
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<mxPoint x="670" y="140" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="BRgU4PrnbskxXR9fhvR0-17" value="dynamically liks&lt;br&gt;to at runtime" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxCell id="BRgU4PrnbskxXR9fhvR0-17" value="dynamically links&lt;br&gt;to at runtime" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="585" y="210" width="110" height="40" as="geometry" />
</mxCell>
</root>
Expand Down
17 changes: 6 additions & 11 deletions modules/libCZI.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include(FetchContent)

# Set necessary build options for libCZI
set(LIBCZI_BUILD_CZICMD OFF CACHE BOOL "" FORCE)
set(LIBCZI_BUILD_DYNLIB OFF CACHE BOOL "" FORCE)
set(LIBCZI_BUILD_UNITTESTS OFF CACHE BOOL "" FORCE)

FetchContent_Declare(
libCZI
Expand All @@ -8,14 +12,5 @@ FetchContent_Declare(
GIT_TAG origin/main
)

if(NOT libCZI_POPULATED)
message(STATUS "Fetching libCZI")
FetchContent_Populate(libCZI)

set(LIBCZI_BUILD_CZICMD OFF CACHE BOOL "" FORCE)
set(LIBCZI_BUILD_DYNLIB OFF CACHE BOOL "" FORCE)
set(LIBCZI_BUILD_UNITTESTS OFF CACHE BOOL "" FORCE)

add_subdirectory(${libczi_SOURCE_DIR} ${libczi_BINARY_DIR})
endif()

# Fetch the content and make it available
FetchContent_MakeAvailable(libCZI)

0 comments on commit 08a67af

Please sign in to comment.