-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
970 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ImageIOIndex.ts.in | ||
dist | ||
emscripten-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
include(FetchContent) | ||
option(ZSTD_BUILD_CONTRIB "BUILD_CONTRIB" OFF) | ||
option(ZSTD_BUILD_PROGRAMS "BUILD_PROGRAMS" OFF) | ||
option(ZSTD_BUILD_SHARED "BUILD_SHARED" OFF) | ||
option(ZSTD_BUILD_STATIC "BUILD_STATIC" ON) | ||
option(ZSTD_BUILD_TESTS "BUILD_TESTS" OFF) | ||
option(ZSTD_BUILD_LEGACY_SUPPORT "BUILD_LEGACY_SUPPORT" OFF) | ||
option(ZSTD_MULTITHREAD_SUPPORT "BUILD_MULTITHREAD_SUPPORT" OFF) | ||
option(ZSTD_BUILD_PROGRAMS_LINK_SHARED "BUILD_PROGRAMS_LINK_SHARED" OFF) | ||
option(ZSTD_BUILD_LZ4 "BUILD_LZ4" OFF) | ||
option(ZSTD_BUILD_LZMA "BUILD_LZMA" OFF) | ||
option(ZSTD_BUILD_ZLIB "BUILD_ZLIB" OFF) | ||
set(zstd_GIT_REPOSITORY "https://github.com/facebook/zstd.git") | ||
# v1.5.2 | ||
set(zstd_GIT_TAG c9c7be85f49f45a581ec00c309afda5c62ba9ef2) | ||
FetchContent_Declare( | ||
zstd_lib | ||
GIT_REPOSITORY ${zstd_GIT_REPOSITORY} | ||
GIT_TAG ${zstd_GIT_TAG} | ||
) | ||
|
||
FetchContent_MakeAvailable(zstd_lib) | ||
set(zstd_lib_INCLUDE_DIR "${zstd_lib_SOURCE_DIR}/lib") | ||
include_directories(${zstd_lib_INCLUDE_DIR}) | ||
add_subdirectory("${zstd_lib_SOURCE_DIR}/build/cmake" "${zstd_lib_BINARY_DIR}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(convert-image) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
if (NOT TARGET libzstd_static) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/BuildZstd.cmake) | ||
endif() | ||
|
||
if(WASI) | ||
set(WebAssemblyInterface_ImageIOModules | ||
"ITKIOPNG" | ||
"ITKIOMeta" | ||
"ITKIOTIFF" | ||
"ITKIONIFTI" | ||
"ITKIOJPEG" | ||
"ITKIONRRD" | ||
"ITKIOVTK" | ||
"ITKIOBMP" | ||
"ITKIOMRC" | ||
"ITKIOLSM" | ||
"MGHIO" | ||
"ITKIOBioRad" | ||
"ITKIOGIPL" | ||
"ITKIOGE" | ||
"ITKIOGDCM" | ||
"IOScanco" | ||
"IOFDF" | ||
CACHE STRING | ||
"String delimited list of ITK image IO modules to support.") | ||
else() | ||
# This list should be ordered from approximately most commonly to least | ||
# commonly used modules. | ||
set(WebAssemblyInterface_ImageIOModules | ||
"ITKIOPNG" | ||
"ITKIOMeta" | ||
"ITKIOTIFF" | ||
"ITKIONIFTI" | ||
"ITKIOJPEG" | ||
"ITKIONRRD" | ||
"ITKIOVTK" | ||
"ITKIOBMP" | ||
"ITKIOHDF5" | ||
"ITKIOMINC" | ||
"ITKIOMRC" | ||
"ITKIOLSM" | ||
"MGHIO" | ||
"ITKIOBioRad" | ||
"ITKIOGIPL" | ||
"ITKIOGE" | ||
"ITKIOGDCM" | ||
"IOScanco" | ||
"IOFDF" | ||
CACHE STRING | ||
"String delimited list of ITK image IO modules to support.") | ||
endif() | ||
set(imageios_ITKIOPNG itkPNGImageIO) | ||
set(imageio_id_itkPNGImageIO 0) | ||
|
||
set(imageios_ITKIOMeta itkMetaImageIO) | ||
set(imageio_id_itkMetaImageIO 1) | ||
|
||
set(imageios_ITKIOTIFF itkTIFFImageIO) | ||
set(imageio_id_itkTIFFImageIO 2) | ||
|
||
set(imageios_ITKIONIFTI itkNiftiImageIO) | ||
set(imageio_id_itkNiftiImageIO 3) | ||
|
||
set(imageios_ITKIOJPEG itkJPEGImageIO) | ||
set(imageio_id_itkJPEGImageIO 4) | ||
|
||
set(imageios_ITKIONRRD itkNrrdImageIO) | ||
set(imageio_id_itkNrrdImageIO 5) | ||
|
||
set(imageios_ITKIOVTK itkVTKImageIO) | ||
set(imageio_id_itkVTKImageIO 6) | ||
|
||
set(imageios_ITKIOBMP itkBMPImageIO) | ||
set(imageio_id_itkBMPImageIO 7) | ||
|
||
set(imageios_ITKIOHDF5 itkHDF5ImageIO) | ||
set(imageio_id_itkHDF5ImageIO 8) | ||
|
||
set(imageios_ITKIOMINC itkMINCImageIO) | ||
set(imageio_id_itkMINCImageIO 9) | ||
|
||
set(imageios_ITKIOMRC itkMRCImageIO) | ||
set(imageio_id_itkMRCImageIO 10) | ||
|
||
set(imageios_ITKIOLSM itkLSMImageIO) | ||
set(imageio_id_itkLSMImageIO 11) | ||
|
||
set(imageios_MGHIO itkMGHImageIO) | ||
set(imageio_id_itkMGHImageIO 12) | ||
|
||
set(imageios_ITKIOBioRad itkBioRadImageIO) | ||
set(imageio_id_itkBioRadImageIO 13) | ||
|
||
set(imageios_ITKIOGIPL itkGiplImageIO) | ||
set(imageio_id_itkGiplImageIO 14) | ||
|
||
set(imageios_ITKIOGE itkGEAdwImageIO itkGE4ImageIO itkGE5ImageIO) | ||
set(imageio_id_itkGE4ImageIO 15) | ||
set(imageio_id_itkGE5ImageIO 16) | ||
set(imageio_id_itkGEAdwImageIO 17) | ||
|
||
set(imageios_ITKIOGDCM itkGDCMImageIO) | ||
set(imageio_id_itkGDCMImageIO 18) | ||
|
||
set(imageios_IOScanco itkScancoImageIO) | ||
set(imageio_id_itkScancoImageIO 19) | ||
|
||
set(imageios_IOFDF itkFDFImageIO) | ||
set(imageio_id_itkFDFImageIO 20) | ||
|
||
set(imageios_WebAssemblyInterface itkWasmImageIO itkWasmZstdImageIO) | ||
set(imageio_id_itkWasmImageIO 21) | ||
set(imageio_id_itkWasmZstdImageIO 22) | ||
|
||
set(ITK_NO_IMAGEIO_FACTORY_REGISTER_MANAGER 1) | ||
set(ImageIOIndex_ARRAY "") | ||
foreach(io_module ${WebAssemblyInterface_ImageIOModules} WebAssemblyInterface) | ||
if (DEFINED WebAssemblyInterface_INCLUDE_DIRS) | ||
if(${io_module} STREQUAL "WebAssemblyInterface") | ||
find_package(ITK REQUIRED COMPONENTS ITKIOImageBase) | ||
include(${ITK_USE_FILE}) | ||
include_directories(${WebAssemblyInterface_INCLUDE_DIRS}) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
list(APPEND ITK_LIBRARIES ${WebAssemblyInterface_LIBRARIES}) | ||
else() | ||
find_package(ITK REQUIRED COMPONENTS ${io_module} WebAssemblyInterface) | ||
include(${ITK_USE_FILE}) | ||
endif() | ||
else() | ||
find_package(ITK REQUIRED COMPONENTS ${io_module} WebAssemblyInterface) | ||
include(${ITK_USE_FILE}) | ||
endif() | ||
|
||
if(NOT DEFINED imageios_${io_module}) | ||
message(FATAL_ERROR "Unknown ImageIOBase classes for module ${io_module}") | ||
endif() | ||
foreach(imageio ${imageios_${io_module}}) | ||
string(SUBSTRING "${imageio}" 3 -1 ioname) | ||
set(read_binary "${ioname}-read-image") | ||
set(write_binary "${ioname}-write-image") | ||
set(ImageIOIndex_ARRAY "${ImageIOIndex_ARRAY}'${ioname}', ") | ||
set(extra_srcs) | ||
if(${imageio} STREQUAL "itkWasmZstdImageIO") | ||
list(APPEND ITK_LIBRARIES libzstd_static) | ||
list(APPEND extra_srcs itkWasmZstdImageIO.cxx) | ||
endif() | ||
|
||
add_executable(${read_binary} read-image.cxx ${extra_srcs}) | ||
target_link_libraries(${read_binary} PUBLIC ${ITK_LIBRARIES}) | ||
target_compile_definitions(${read_binary} PUBLIC -DIMAGE_IO_CLASS=${imageio_id_${imageio}}) | ||
add_executable(${write_binary} write-image.cxx ${extra_srcs}) | ||
target_link_libraries(${write_binary} PUBLIC ${ITK_LIBRARIES}) | ||
target_compile_definitions(${write_binary} PUBLIC -DIMAGE_IO_CLASS=${imageio_id_${imageio}}) | ||
if (EMSCRIPTEN) | ||
set(target_esm_read "${read_binary}") | ||
set(target_umd_read "${read_binary}.umd") | ||
set(target_esm_write "${write_binary}") | ||
set(target_umd_write "${write_binary}.umd") | ||
target_compile_definitions(${target_umd_read} PUBLIC -DIMAGE_IO_CLASS=${imageio_id_${imageio}}) | ||
target_compile_definitions(${target_umd_write} PUBLIC -DIMAGE_IO_CLASS=${imageio_id_${imageio}}) | ||
foreach(target ${target_esm_read} ${target_umd_read} ${target_esm_write} ${target_umd_write}) | ||
set(exception_catching ) | ||
if(${io_module} STREQUAL "ITKIOGE") | ||
set(exception_catching " -s DISABLE_EXCEPTION_CATCHING=0") | ||
endif() | ||
set(imageio_common_link_flags " -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s SUPPORT_LONGJMP=1") | ||
get_property(link_flags TARGET ${target} PROPERTY LINK_FLAGS) | ||
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${imageio_common_link_flags} ${link_flags}") | ||
set_property(TARGET ${target} | ||
PROPERTY RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_CURRENT_SOURCE_DIR}/typescript/dist/pipelines | ||
) | ||
endforeach() | ||
elseif (WASI) | ||
foreach(target ${read_binary} ${write_binary}) | ||
set(exception_catching ) | ||
set_property(TARGET ${target} | ||
PROPERTY RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_CURRENT_SOURCE_DIR}/typescript/wasi/pipelines | ||
) | ||
endforeach() | ||
endif() | ||
endforeach() | ||
endforeach() | ||
if(EMSCRIPTEN) | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ImageIOIndex.ts.in | ||
${CMAKE_CURRENT_SOURCE_DIR}/typescript/src/ImageIOIndex.ts @ONLY) | ||
endif() |
Oops, something went wrong.