Skip to content

Commit

Permalink
Update CMakeLists: configure_file, C++17, include dirs
Browse files Browse the repository at this point in the history
Modified `configure_file` to include `ESCAPE_QUOTES` and `@ONLY` options for proper variable replacement and quote escaping. Removed `add_library` for `lib` target. Added `set_target_properties` to set C++17 standard for `lib`. Added `target_include_directories` to specify `../AppModel/include` as a private include directory for `lib`.

Refactor build process and remove Octave support

Separated and streamlined the build process for Octave and MATLAB MEX files. Updated build scripts to compile Octave MEX files in the `OctaveMex` directory. Modified CMake configuration to focus on MATLAB MEX files, removing Octave-specific configurations and source files. Removed `find_package(Octave)` call and related configurations from CMakeLists.txt. Cleaned up source files to remove Octave-specific code and dependencies. Removed `mexlibczi_Config.h.in` file.

Removed several header and source files related to `CziReader`, `CziReaderManager`, `CziReaderSubBlockStore`, and `CziUtilities` classes, indicating a significant refactor or deprecation of their functionality. Also removed files related to `CziWriter`, `CziWriterManager`, and various utility functions for handling arguments, logging, and specific operations with CZI files.

Updated `CMakeLists.txt` to remove `matlabMexSourceFiles` and `MatlabCZI` library target, adding new targets for `lib` and `libmexlibczi`. Updated `notes.txt` to reflect new directory path and command for building with Octave. Overall, reorganized and simplified the project's build system and source code structure.
  • Loading branch information
ptahmose committed Oct 18, 2024
1 parent 4d9a211 commit 9676534
Show file tree
Hide file tree
Showing 73 changed files with 50 additions and 4,824 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,43 @@ jobs:
REM downside is that installing octave takes a long time.
REM Note that we are using cmd.exe here, because it can "execute" the .lnk file.
"%OCTAVECLI_LINK%" --version
REM echo "cd %GITHUB_WORKSPACE%/OctaveOct , mkoctfile --mex octavelibczi.c"
REM echo "cd %GITHUB_WORKSPACE%/OctaveMex , mkoctfile --mex octavelibczi.c"
set "GITHUB_WORKSPACE_FORWARD_SLASHES=%GITHUB_WORKSPACE:\=/%
"%OCTAVECLI_LINK%" --eval "cd %GITHUB_WORKSPACE_FORWARD_SLASHES%/OctaveOct , mkoctfile --mex octavelibczi.c"
dir %GITHUB_WORKSPACE%\OctaveOct
- name: Prepare artifact (Windows)
"%OCTAVECLI_LINK%" --eval "cd %GITHUB_WORKSPACE_FORWARD_SLASHES%/OctaveMex , mkoctfile --mex octavelibczi.c"
# now, copy the libmexlibczi.dll to this folder
cp build/MEXlibCZI/Release/libmexlibczi.dll %GITHUB_WORKSPACE%\OctaveMex
dir %GITHUB_WORKSPACE%\OctaveMex
- name: Prepare MATLAB-mex artifact (Windows)
id: prepare_windows_artifact
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p artifacts
name="MEXlibCZI-windows-x64-$(git describe --always)"
name="MATLAB-MEXlibCZI-windows-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp build/MEXlibCZI/Release/MEXlibCZI.mexw64 artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
#echo "::set-output name=windowsx64_build::${name}"
echo "windowsx64_build=${name}" >> $GITHUB_OUTPUT
- name: Upload artifacts
echo "windowsx64_matlab_build=${name}" >> $GITHUB_OUTPUT
- name: Upload MATLAB-mex artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.artifactPath }}/
name: ${{ env.artifactName }}
- name: Prepare Octave-mex artifact (Windows)
id: prepare_windows_artifact
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p artifacts
name="Octave-MEXlibCZI-windows-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp ${GITHUB_WORKSPACE}/OctaveMex/libmexlibczi.dll artifacts/${name}/
cp ${GITHUB_WORKSPACE}/OctaveMex/octavelibczi.mex artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
echo "windowsx64_octave_build=${name}" >> $GITHUB_OUTPUT
- name: Upload Octave-mex artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.artifactPath }}/
Expand All @@ -111,7 +130,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Download All Artifacts
if: needs.build.outputs.linuxx64_artifact != '' || needs.build.outputs.windowsx64_artifact != ''
if: needs.build.outputs.linuxx64_artifact != '' || needs.build.outputs.windowsx64_matlab_artifact != ''
uses: actions/download-artifact@v4
with:
path: ./artifacts # download to a specific folder
Expand All @@ -132,6 +151,6 @@ jobs:
tag_name: ${{ env.tagName }}
files: |
./artifacts/${{ needs.build.outputs.linuxx64_artifact }}/MEXlibCZI.mexa64
./artifacts/${{ needs.build.outputs.windowsx64_artifact }}/MEXlibCZI.mexw64
./artifacts/${{ needs.build.outputs.windowsx64_matlab_artifact }}/MEXlibCZI.mexw64
prerelease: true

12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ message(STATUS "OCTAVE_INCLUDE_DIRS: " ${OCTAVE_INCLUDE_DIRS})
message("########################################")
]]

add_subdirectory ("MEXlibCZI")

# build the static library containing the MEX functions
add_subdirectory("lib")
add_subdirectory("MatlabMex")

# build the Matlab-MEX file
add_subdirectory ("MEXlibCZI")

##set(OCTAVE_CONFIGEXECUTABLE_PATHHINT "D:/SW/octave-9.2.0-w64/mingw64/bin")
set(OCTAVE_CONFIGEXECUTABLE_PATHHINT "/d/SW/octave-9.2.0-w64/mingw64/bin/")
find_package(Octave)
#set(OCTAVE_CONFIGEXECUTABLE_PATHHINT "/d/SW/octave-9.2.0-w64/mingw64/bin/")
#find_package(Octave)

#add_subdirectory("OctaveOct")

# build a dynamic library containing the MEX functions (which is used by the mex-file for Octave)
add_subdirectory("libmexlibczi")
160 changes: 12 additions & 148 deletions MEXlibCZI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,162 +1,26 @@
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(mexlibczi_ENABLE_LOGGING 1)
else()
set(mexlibczi_ENABLE_LOGGING 0)
endif()

set(mexlibczi_LOGLEVEL 1)


set(mexlibczi_VERSION_MAJOR ${MEXCZI_MAJOR})
set(mexlibczi_VERSION_MINOR ${MEXCZI_MINOR})
set(mexlibczi_VERSION_PATCH ${MEXCZI_PATCH})
set(mexlibczi_VERSION_EXT ${MEXCZI_EXT})

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/mexlibczi_Config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/mexlibczi_Config.h"
ESCAPE_QUOTES @ONLY)

set(mexoctaveSourceFiles
"mexFunction.cpp"
"mexFunctions.h"
"include_matlabheaders.h"
"mexFunctions.cpp"
"src/libraryInfo.h"
"src/libraryInfo.cpp"
"src/inc_libczi.h"
"src/func_getversion.h"
"src/func_getversion.cpp"
"src/func_open.cpp"
"src/func_getsubblockbitmap.h"
"src/func_getsubblockbitmap.cpp"
"src/CziReaderManager.h"
"src/CziReaderManager.cpp"
"src/CziWriterManager.h"
"src/CziWriterManager.cpp"
"src/CziReader.h"
"src/CziReader.cpp"
"src/CziWriter.h"
"src/CziWriter.cpp"
"src/argsutils.h"
"src/argsutils.cpp"
"src/func_getmultichannelscalingtilecomposite.h"
"src/func_getmultichannelscalingtilecomposite.cpp"
"src/CziUtilities.h"
"src/CziUtilities.cpp"
"src/utils.h"
"src/utils.cpp"
"src/func_getinfo.h"
"src/func_getinfo.cpp"
"src/func_getscaling.h"
"src/func_getscaling.cpp"
"src/func_getmetadataxml.cpp"
"src/func_getmetadataxml.h"
"src/func_getsinglechannelscalingtilecomposite.cpp"
"src/func_getsinglechannelscalingtilecomposite.h"
"src/func_close.cpp"
"src/func_close.h"
"src/mexapi.h"
"src/mexapi.cpp"
"errorcodes.h"
"errorcodes.cpp"
"src/dbgprint.h"
"src/dbgprint.cpp"
"src/func_getdefaultdisplaysettings.cpp"
"src/func_getdefaultdisplaysettings.h"
"src/CziReaderSbBlkStore.h"
"src/CziReaderSbBlkStore.cpp"
"src/func_getsubblock.h"
"src/func_getsubblock.cpp"
"src/func_createcziwriter.h"
"src/func_createcziwriter.cpp"
"src/func_addsubblock.h"
"src/func_addsubblock.cpp"
"src/func_closecziwriter.h"
"src/func_closecziwriter.cpp"
"src/include_rapidjson.h"
set(matlabMexSourceFiles
"app_api_implementation.c"
"app_api_implementation.h"
"mex_function.cpp"
)

add_library (MEXlibCZI SHARED
${mexoctaveSourceFiles})
${matlabMexSourceFiles})

target_compile_features(MEXlibCZI PRIVATE c_std_11)
set_target_properties(MEXlibCZI PROPERTIES CXX_STANDARD 17)

target_include_directories(MEXlibCZI PRIVATE ${Matlab_INCLUDE_DIRS} ${RAPIDJSON_INCLUDE_DIR})
target_link_libraries(MEXlibCZI PRIVATE ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} lib)
target_include_directories(MEXlibCZI PRIVATE ${Matlab_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/../AppModel/include")
target_include_directories(MEXlibCZI PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../lib")

target_include_directories(MEXlibCZI PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # this is necessary so that we can find "wllczi_Config.h" which we created above
target_include_directories(MEXlibCZI PRIVATE ${LIBCZI_INCLUDE_DIR})
target_link_libraries(MEXlibCZI PRIVATE ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY})
target_link_libraries(MEXlibCZI PRIVATE libCZIStatic JxrDecodeStatic)
# this definition is necessary so that "mexFunction" is exported
target_compile_definitions(MEXlibCZI PRIVATE MW_NEEDS_VERSION_H=1)

if(WIN32)
set_target_properties(MEXlibCZI PROPERTIES SUFFIX ".mexw64")
elseif(UNIX)
set_target_properties(MEXlibCZI PROPERTIES SUFFIX ".mexa64")
target_link_options(MEXlibCZI PRIVATE -static-libgcc -static-libstdc++ )
set_target_properties(MEXlibCZI PROPERTIES PREFIX "") # otherwise "lib" is prepended
endif()

SET_TARGET_PROPERTIES (MEXlibCZI PROPERTIES DEFINE_SYMBOL "MATLABMEXBUILD")

# this definition is necessary so that "mexFunction" is exported
target_compile_definitions(MEXlibCZI PRIVATE MW_NEEDS_VERSION_H=1)

if(WIN32)
target_compile_definitions(MEXlibCZI PRIVATE _WIN32API=1)
endif()

#------------------------------------------------------------------------------------------

#[[
add_library (OctlibCZI SHARED
${mexoctaveSourceFiles})

set_target_properties(OctlibCZI PROPERTIES CXX_STANDARD 11)
target_include_directories(OctlibCZI PRIVATE ${OCTAVE_INCLUDE_DIRS} ${RAPIDJSON_INCLUDE_DIR})

target_include_directories(OctlibCZI PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # this is necessary so that we can find "wllczi_Config.h" which we created above
target_include_directories(OctlibCZI PRIVATE ${LIBCZI_INCLUDE_DIR})
target_link_libraries(OctlibCZI PRIVATE libCZIStatic JxrDecodeStatic)
SET_TARGET_PROPERTIES(OctlibCZI PROPERTIES DEFINE_SYMBOL "OCTAVEBUILD")

if(WIN32)
target_compile_definitions(OctlibCZI PRIVATE _WIN32API=1)
endif()

set_target_properties(OctlibCZI PROPERTIES SUFFIX ".oct")
]]
















#[[
# building a mex-file for Octave:
# * "mx"-functions are found in liboctinterp-7 - DLL
# * need to build an import-library for the DLL
# * not all mx-functions are present (not the typed "mxGetInt8s"-etc. functions, not mxArrayToUTF8String)
# * extension must be ".mex" I suppose, not ".mexw64" or so

target_include_directories(MEXlibCZI PRIVATE ${OCTAVE_INCLUDE_DIRS} ${RAPIDJSON_INCLUDE_DIR})

target_include_directories(MEXlibCZI PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # this is necessary so that we can find "wllczi_Config.h" which we created above
target_include_directories(MEXlibCZI PRIVATE ${LIBCZI_INCLUDE_DIR})
target_link_libraries(MEXlibCZI PRIVATE "D:/Temp/octave/liboctinterp-7.lib")
target_link_libraries(MEXlibCZI PRIVATE libCZIStatic JxrDecodeStatic)

set_target_properties(MEXlibCZI PROPERTIES SUFFIX ".mex")
SET_TARGET_PROPERTIES(MEXlibCZI PROPERTIES LINK_FLAGS "/export:mexFunction")
SET_TARGET_PROPERTIES (MEXlibCZI PROPERTIES DEFINE_SYMBOL "OCTAVEMEXBUILD" )
]]
endif()
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions MEXlibCZI/errorcodes.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions MEXlibCZI/errorcodes.h

This file was deleted.

36 changes: 0 additions & 36 deletions MEXlibCZI/exportedFunctions.h

This file was deleted.

3 changes: 0 additions & 3 deletions MEXlibCZI/include_matlabheaders.h

This file was deleted.

Loading

0 comments on commit 9676534

Please sign in to comment.