Skip to content

Commit

Permalink
Merge pull request #1179 from jadh4v/docs-native-build
Browse files Browse the repository at this point in the history
Update docs and add scripts for native build
  • Loading branch information
thewtex authored Aug 14, 2024
2 parents 2bbb8bb + a9b4631 commit 5e8ae1a
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 5 deletions.
68 changes: 68 additions & 0 deletions dev-utils/itk-wasm-native-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
if [$OSTYPE == "cygwin"] || [$OSTYPE == "msys"] || [$OSTYPE =="win32"]; then
echo "Windows platform detected ... adding \"/Zc:__cplusplus /DNOMINMAX\" to \$CXXFLAGS"
export CXXFLAGS="/Zc:__cplusplus /DNOMINMAX"
fi
#if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" =="win32" ]]; then

cmake -BITK-build -SITK \
-DBUILD_TESTING=OFF \
-DCMAKE_CXX_STANDARD:STRING=17 \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug \
-DBUILD_EXAMPLES:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DDCMTK_LINK_STATIC=ON \
-DITK_LEGACY_REMOVE:BOOL=ON \
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON \
-DITKGroup_IO:BOOL=ON \
-DH5_HAVE_GETPWUID:BOOL=OFF \
-DModule_ITKIOMINC:BOOL=ON \
-DModule_MGHIO:BOOL=ON \
-DModule_IOMeshSWC:BOOL=ON \
-DModule_IOScanco:BOOL=ON \
-DModule_IOFDF:BOOL=ON \
-DModule_ITKDCMTK:BOOL=ON \
-DModule_ITKImageFunction:BOOL=ON \
-DModule_MinimalPathExtraction:BOOL=ON \
-DModule_MorphologicalContourInterpolation:BOOL=ON \
-DModule_SmoothingRecursiveYvvGaussianFilter:BOOL=ON \
-DModule_Cuberille:BOOL=ON \
-DModule_TotalVariation:BOOL=ON \
-DModule_IOMeshSTL:BOOL=ON \
-DModule_GenericLabelInterpolator:BOOL=ON \
-DModule_MeshToPolyData=ON \
-DDO_NOT_BUILD_ITK_TEST_DRIVER:BOOL=ON \
-DOPJ_USE_THREAD:BOOL=OFF \
-DDCMTK_WITH_THREADS:BOOL=OFF \
-DDCMTK_BUILD_APPS:BOOL=OFF \
-DNO_FLOAT_EXCEPTIONS:BOOL=ON \
-DITK_MSVC_STATIC_RUNTIME_LIBRARY=ON

cmake --build ITK-build --config Debug -j16

cmake -BITK-Wasm-build \
-SITK-Wasm \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_STANDARD:STRING=20 \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug \
-DBUILD_SHARED_LIBS=OFF \
-DITK_DIR=$PWD/ITK-build

cmake --build ITK-Wasm-build --config Debug -j16

cmake -Bpackages-dicom \
-SITK-Wasm/packages/dicom \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_STANDARD:STRING=20 \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug \
-DITK_DIR=$PWD/ITK-build

cmake --build packages-dicom --config Debug -j16

ctest --test-dir ITK-Wasm-build -C Debug

43 changes: 43 additions & 0 deletions dev-utils/itk-wasm-native-get-source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# workdir
work_dir="~/itk-wasm-native"

# main
itk_repository="https://github.com/KitwareMedical/ITK.git"
itk_branch="itkwasm-main-mutable"
dcmtk_repository="https://github.com/InsightSoftwareConsortium/DCMTK.git"
dcmtk_tag="fe7cff5de40b67ae0490d476ddf17689c06bcaf4"
wasm_repository="https://github.com/InsightSoftwareConsortium/ITK-Wasm"
wasm_branch="main"

# dev-override
#itk_repository="https://github.com/jadh4v/ITK.git"
#itk_branch="itkwasm-2024-06-06"
#wasm_repository="https://github.com/jadh4v/ITK-Wasm"
#wasm_branch="dicom-seg"

echo "itk_repository = $itk_repository"
echo "itk_branch = $itk_branch"
echo "wasm_repository = $wasm_repository"
echo "wasm_branch = $wasm_branch"

mkdir $work_dir

cd $work_dir

git clone $itk_repository --branch=$itk_branch

git clone $wasm_repository --branch=$wasm_branch

#dcmtk_repository="https://github.com/jadh4v/DCMTK.git"
#dcmtk_tag="62ebb7bb6e9ffb5311ff0f7baaa935b9b85296ec"
#echo "dcmtk_repository = $dcmtk_repository"
#echo "dcmtk_tag = $dcmtk_tag"

#sed -i -e '/^set(DCMTK_GIT_REPOSITORY/c\set(DCMTK_GIT_REPOSITORY "'$dcmtk_repository'")' \
# ITK/Modules/ThirdParty/DCMTK/DCMTKGitTag.cmake

#sed -i -e '/^set(DCMTK_GIT_TAG/c\set(DCMTK_GIT_TAG "'$dcmtk_tag'")' \
# ITK/Modules/ThirdParty/DCMTK/DCMTKGitTag.cmake

54 changes: 49 additions & 5 deletions docs/development/hacking_itk_wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,65 @@ ITK-Wasm's [C++ core](../introduction/parts.md#cxx-core) can be developed with n
2. Build the `WebAssemblyInterface` module from this module against ITK
3. Run the tests

We recommend using the scripts provided in [dev-utils](../../dev-utils/) folder
to [grab the source code](../../dev-utils/itk-wasm-native-get-source.sh) and run [native build commands](../../dev-utils/itk-wasm-native-build.sh).
Note that you will need to include certain CXX compiler flags for the native windows build as shown in the script.
The build script also demonstrates how to native build sub-packages such as @itk-wasm/dicom with additional ITK dependencies turned on.

From a command line, these steps in brief are:

```sh
# For Windows build (with mingw-bash or git-bash terminal)
export CXXFLAGS="/Zc:__cplusplus /DNOMINMAX"

# Build ITK
git clone https://github.com/InsightSoftwareConsortium/ITK
cmake -BITK-build -SITK -DBUILD_TESTING=OFF -DModule_MeshToPolyData=ON
cmake --build ITK-build
git clone https://github.com/InsightSoftwareConsortium/ITK --branch=itkwasm-main-mutable
# cmake -BITK-build -SITK -DBUILD_TESTING=OFF -DModule_MeshToPolyData=ON -DITK_MSVC_STATIC_RUNTIME_LIBRARY=ON
cmake -BITK-build -SITK \
-DBUILD_TESTING=OFF \
-DCMAKE_CXX_STANDARD:STRING=17 \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug \
-DBUILD_EXAMPLES:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DDCMTK_LINK_STATIC=ON \
-DITK_LEGACY_REMOVE:BOOL=ON \
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON \
-DModule_MeshToPolyData=ON \
-DDO_NOT_BUILD_ITK_TEST_DRIVER:BOOL=ON \
-DOPJ_USE_THREAD:BOOL=OFF \
-DDCMTK_WITH_THREADS:BOOL=OFF \
-DDCMTK_BUILD_APPS:BOOL=OFF \
-DNO_FLOAT_EXCEPTIONS:BOOL=ON \
-DITK_MSVC_STATIC_RUNTIME_LIBRARY=ON
cmake --build ITK-build --config Debug -j16

# Build the WebAssemblyInterface module from this module against ITK
git clone https://github.com/InsightSoftwareConsortium/ITK-Wasm
cmake -Bitk-wasm-build -Sitk-wasm -DBUILD_TESTING=ON -DITK_DIR=$PWD/ITK-build
cmake --build itk-wasm-build
cmake -BITK-Wasm-build \
-SITK-Wasm \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_STANDARD:STRING=20 \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug \
-DBUILD_SHARED_LIBS=OFF \
-DITK_DIR=$PWD/ITK-build
cmake --build ITK-Wasm-build --config Debug -j16

# Run the tests
ctest --test-dir itk-wasm-build

cmake -Bpackages-dicom \
-SITK-Wasm/packages/dicom \
-DBUILD_TESTING=ON \
-DCMAKE_CXX_STANDARD:STRING=20 \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug \
-DITK_DIR=$PWD/ITK-build

cmake --build packages-dicom --config Debug -j16
```

For additional guidance on C++ development, see the [ITK Software Guide].
Expand Down

0 comments on commit 5e8ae1a

Please sign in to comment.