From 08a67af928f10131b6986f397829ba4d0b33dd91 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Sun, 20 Oct 2024 00:28:18 +0200 Subject: [PATCH] Update build config, CI, and documentation - 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 --- CMakeLists.txt | 4 +- azure-pipelines.yml | 82 ------------------------------------ doc/building.markdown | 28 ++++++++++++ doc/pictures/building.drawio | 2 +- modules/libCZI.cmake | 17 +++----- 5 files changed, 38 insertions(+), 95 deletions(-) delete mode 100644 azure-pipelines.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index b749971..8acd736 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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/ diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 5a8f37b..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,82 +0,0 @@ -# Build MEXlibCZI for Windows-x64 and Linux-x64 - -trigger: -- master - -jobs: -- job: Windowsx64 - pool: - vmImage: 'windows-latest' - steps: - - task: DownloadSecureFile@1 - inputs: - secureFile: 'mlfiles2.zip' - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: '$(Agent.TempDirectory)/mlfiles2.zip' - destinationFolder: 'matlabheaders' - cleanDestinationFolder: true - - task: CMake@1 - inputs: - workingDirectory: $(Build.SourcesDirectory)/build - cmakeArgs: '.. -A x64 -DCMAKE_BUILD_TYPE=Release -DMEXLIBCZI_HEADERS=$(Build.SourcesDirectory)\matlabheaders\include -DMEXLIBCZI_LIBS=$(Build.SourcesDirectory)\matlabheaders\lib' - - task: CmdLine@2 - inputs: - script: 'cmake --build .\build --config Release' - - task: PublishPipelineArtifact@1 - inputs: - targetPath: $(Build.SourcesDirectory)/build/MEXlibCZI/Release/MEXlibCZI.mexw64 - artifactName: MEXlibCZIWinx64 - - script: echo Hello, world! - displayName: 'Run a one-line script' -- job: Linuxx64 - pool: - vmImage: 'ubuntu-latest' - steps: - - task: DownloadSecureFile@1 - inputs: - secureFile: 'mlfiles2.zip' - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: '$(Agent.TempDirectory)/mlfiles2.zip' - destinationFolder: 'matlabheaders' - cleanDestinationFolder: true - - task: CMake@1 - inputs: - cmakeArgs: '.. -DCMAKE_BUILD_TYPE=Release -DMEXLIBCZI_HEADERS=$(Build.SourcesDirectory)/matlabheaders/include -DMEXLIBCZI_LIBS=$(Build.SourcesDirectory)/matlabheaders/lib' - - script: | - cmake --build ./build --config Release - displayName: 'Build Linux-x64' - - task: PublishPipelineArtifact@1 - inputs: - targetPath: $(Build.SourcesDirectory)/build/MEXlibCZI/MEXlibCZI.mexa64 - artifactName: MEXlibCZILinuxx64 -- job: Upload_Release - dependsOn: - - Windowsx64 - - Linuxx64 - pool: - vmImage: 'ubuntu-latest' - steps: - - checkout: none #skip checking out the default repository resource - - task: DownloadPipelineArtifact@2 - inputs: - artifact: MEXlibCZILinuxx64 - patterns: '**/*' - path: $(Build.ArtifactStagingDirectory) - - task: DownloadPipelineArtifact@2 - inputs: - artifact: MEXlibCZIWinx64 - patterns: '**/*' - path: $(Build.ArtifactStagingDirectory) - - task: GitHubRelease@0 - displayName: 'Create GitHub Release' - condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/release-v') # only run this if tag starts with "release-v" - inputs: - gitHubConnection: 'github.com_ptahmose' - repositoryName: 'ptahmose/MEXlibCZI' - action: 'create' - tagSource: manual - tag: $(Build.BuildNumber) - assets: $(Build.ArtifactStagingDirectory)/* - isPreRelease: true diff --git a/doc/building.markdown b/doc/building.markdown index b6e7c71..bad7c10 100644 --- a/doc/building.markdown +++ b/doc/building.markdown @@ -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. diff --git a/doc/pictures/building.drawio b/doc/pictures/building.drawio index 684fea5..0a0bd54 100644 --- a/doc/pictures/building.drawio +++ b/doc/pictures/building.drawio @@ -40,7 +40,7 @@ - + diff --git a/modules/libCZI.cmake b/modules/libCZI.cmake index 2499545..18ea9e3 100644 --- a/modules/libCZI.cmake +++ b/modules/libCZI.cmake @@ -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 @@ -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)