vcpkg/ports/itk/portfile.cmake
Alexander Neumann 8e76503a76
[ITK] Update to 5.1 (#11208)
* [vtk-m] new port vtk-m

* [VTK] Update to 9.0

* include local buildtree changes

* [pcl] disable VTK due to API changes in VTK 9.0

* [vtk-m] add supports field to be only x64

* [vtk-dicom] add python executable.

* fix vtkm dependency

* [vtk-dicom] fix missing std:: namespace

* [vtk-m] add uwp to unsupported triplets

* [vtk] add pegtl include patch, reenable IOMotionFX

* remove hdf5 changes for testing

* use different pgetl patch which redirects to the installed config of pegtl

* [pegtl-2] version file needs renaming too

* [vtk] change dependency to pgetl-2 and fix the patch

* [vtk] put in hdf5 fix again and correct manually installed include files

* remove deprecated function to retrigger CI

* [lz4] correctly lowercase the lz4 config

* [vtk] remove unnecessary code

* [pegtl-2] add homepage

* [pegtl] modernize portfiles

* [vtk-dicom] add homepage

* [vtk-dicom] modernize portfile

* [vtk-m] remove empty build depends

* [vtk] try fixing the permission issue

* [vtk] minimal dependency correction

* [itk] update

* fix portfile errors

* WIP commit

* should make ITK green in VCPKG CI but there a still issues with features

* more dependencies and features....

* remove itk from baseline failure so the check can get green

* more dependency updating.

* minor build fixes

* [openjpeg] Fix dll location

* fix other issues

* add rtkcuda

* [openjpeg] remove default features to make arm and uwp platforms happy

* [itk] more dependency fixes

* [openjpeg] fix no tools case

* [itk] fix wip patch

* [itk] split up patches & cleanup & and move rtk tools if build

* [itk] fix patch and remove old and wip patch

* [nifticlib] Add new port required by minc

* [nifticlib] change repo and add features

* [nifticilib] add zlib dependency & cleanup

* [minc] add new port

* [vcpkg/scripts] add swig to find acquire programm

* [itk/minc] update for external minc

* add supports field for nifticlib

* [itk] make python a default feature for testing

* [itk] cleanup python vars a bit
[vcpkg/scripts] correct swig hash

* [vcpkg/scripts] fix swig

* [itk] fix python include path on unix system

* [itk] remove python as a default. A bit of feature cleanup

* [itk] update remote RTK

* [itk|rtk] remove RTK module before configure to allow patching

* [opencl] update opencl wrapper

* [itk] fix opencl static linkage

* [itk] add cufftw fix

* update baseline

* [itk] fix itk[tbb]

* [itk] update python paths to 3.8

* [itk] add failure messages for unsupported architectures for some features

* [vcpkg_find_acquire_program] update swig to 4.0.2

* Update portfile.cmake

* [itk] move the module removal out of the if for people reusing the old source tree

* [itk] add missing auto_clean to vcpkg_copy_tools

* Update ports/nifticlib/CONTROL

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>

* Update ports/openjpeg/portfile.cmake

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>

* Update scripts/cmake/vcpkg_find_acquire_program.cmake

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>

* [openjpeg] pass OPTIONS to vcpkg_configure_cmake

* [itk] fix typo and leave a todo.

* use sourceforge args for swig

* Update ports/openjpeg/CONTROL

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* Update ports/opencl/CONTROL

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* [itk] remove debug msgs from patch

* pre-install yasm on OSX

Co-authored-by: Lily <47812810+LilyWangL@users.noreply.github.com>
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
2020-08-02 15:49:20 -07:00

214 lines
10 KiB
CMake

vcpkg_buildpath_length_warning(37)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO InsightSoftwareConsortium/ITK
REF d3286c9cc04ba16cc8f73de9a98fbcd7c02f3c7b
SHA512 c358449870d580aeb10e32f8be0ca39e8a76d8dc06fda973788fafb5971333e546611c399190be49d40f5f3c18a1105d9699eef271a560aff25ce168a396926e
HEAD_REF master
PATCHES
hdf5.patch
double-conversion.patch
openjpeg.patch
openjpeg2.patch
var_libraries.patch
wrapping.patch
python_gpu_wrapping.patch
opencl.patch
cufftw.patch
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
"vtk" Module_ITKVtkGlue
"cuda" Module_ITKCudaCommon # Requires RTK?
#"cuda" CUDA_HAVE_GPU # Automatically set by FindCUDA?
"cufftw" ITK_USE_CUFFTW
"opencl" ITK_USE_GPU
"tbb" Module_ITKTBB
"rtk" Module_RTK
"tools" RTK_BUILD_APPLICATIONS
# There are a lot of more (remote) modules and options in ITK
# feel free to add those as a feature
)
if("cufftw" IN_LIST FEATURES)
# Alternativly set CUFFT_LIB and CUFFTW_LIB
if(WIN32)
file(TO_CMAKE_PATH "$ENV{CUDA_PATH}" CUDA_PATH)
set(CUDA_LIB_PATH "${CUDA_PATH}")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL x64)
string(APPEND CUDA_LIB_PATH "/lib/x64")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
string(APPEND CUDA_LIB_PATH "/lib/Win32")
message(FATAL_ERROR "CUFFTW is not supported on architecture ${VCPKG_TARGET_ARCHITECTURE}")
else()
message(FATAL_ERROR "Architecture ${VCPKG_TARGET_ARCHITECTURE} not supported !")
endif()
list(APPEND ADDITIONAL_OPTIONS
"-DFFTW_LIB_SEARCHPATH=${CUDA_LIB_PATH}"
"-DFFTW_INCLUDE_PATH=${CUDA_PATH}/include"
"-DCUFFTW_INCLUDE_PATH=${CUDA_PATH}/include"
)
endif()
endif()
if("rtk" IN_LIST FEATURES)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
message(FATAL_ERROR "RTK is not supported on architecture ${VCPKG_TARGET_ARCHITECTURE}")
endif()
SET(BUILD_RTK ON)
list(APPEND ADDITIONAL_OPTIONS
"-DModule_RTK_GIT_TAG=8099212f715231d093f7d6a1114daecf45d871ed" # RTK latest versions (11.05.2020)
)
if("cuda" IN_LIST FEATURES)
list(APPEND ADDITIONAL_OPTIONS "-DRTK_USE_CUDA=ON")
#RTK + CUDA + PYTHON + dynamic library linkage will fail and needs upstream fixes.
endif()
endif()
file(REMOVE_RECURSE "${SOURCE_PATH}/Modules/Remote/RTK")
if("opencl" IN_LIST FEATURES)
list(APPEND ADDITIONAL_OPTIONS # Wrapping options required by OpenCL if build with Python Wrappers
-DITK_WRAP_unsigned_long_long=ON
-DITK_WRAP_signed_long_long=ON
)
endif()
if("tools" IN_LIST FEATURES)
if("rtk" IN_LIST FEATURES)
list(APPEND TOOL_NAMES rtkadmmtotalvariation rtkadmmwavelets rtkamsterdamshroud rtkbackprojections rtkbioscangeometry rtkcheckimagequality rtkconjugategradient
rtkdigisensgeometry rtkdrawgeometricphantom rtkdrawshepploganphantom rtkdualenergysimplexdecomposition rtkelektasynergygeometry rtkextractphasesignal
rtkextractshroudsignal rtkfdk rtkfdktwodweights rtkfieldofview rtkforwardprojections rtkfourdconjugategradient rtkfourdfdk rtkfourdrooster rtkfourdsart
rtkgaincorrection rtki0estimation rtkimagxgeometry rtkiterativefdk rtklagcorrection rtklastdimensionl0gradientdenoising rtklut rtkmaskcollimation rtkmcrooster
rtkmotioncompensatedfourdconjugategradient rtkorageometry rtkosem rtkoverlayphaseandshroud rtkparkershortscanweighting rtkprojectgeometricphantom
rtkprojectionmatrix rtkprojections rtkprojectshepploganphantom rtkramp rtkrayboxintersection rtkrayquadricintersection rtkregularizedconjugategradient
rtksart rtkscatterglarecorrection rtksimulatedgeometry rtkspectraldenoiseprojections rtkspectralforwardmodel rtkspectralonestep rtkspectralrooster rtkspectralsimplexdecomposition
rtksubselect rtktotalnuclearvariationdenoising rtktotalvariationdenoising rtktutorialapplication rtkvarianobigeometry rtkvarianprobeamgeometry rtkvectorconjugategradient
rtkwangdisplaceddetectorweighting rtkwarpedbackprojectsequence rtkwarpedforwardprojectsequence rtkwaveletsdenoising rtkxradgeometry)
endif()
endif()
if("vtk" IN_LIST FEATURES)
vcpkg_find_acquire_program(PYTHON3)
list(APPEND ADDITIONAL_OPTIONS
"-DPython3_EXECUTABLE:PATH=${PYTHON3}" # Required by mvtk if vtk[python] was build
)
endif()
if("python" IN_LIST FEATURES)
message(STATUS "${PORT} builds a long time (>1h) with python wrappers enabled!")
vcpkg_find_acquire_program(PYTHON3)
vcpkg_find_acquire_program(SWIG) # Swig is only required for wrapping!
get_filename_component(SWIG_DIR "${SWIG}" DIRECTORY)
list(APPEND ADDITIONAL_OPTIONS
-DITK_WRAP_PYTHON=ON
-DPython3_FIND_REGISTRY=NEVER
"-DPython3_EXECUTABLE:PATH=${PYTHON3}" # Required by more than one feature
"-DSWIG_EXECUTABLE=${SWIG}"
"-DSWIG_DIR=${SWIG_DIR}"
)
# Due to ITKs internal shenanigans with the variables ......
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND ADDITIONAL_OPTIONS "-DPython3_LIBRARY_RELEASE:PATH=${CURRENT_INSTALLED_DIR}/lib/python38.lib"
"-DPython3_LIBRARY_DEBUG:PATH=${CURRENT_INSTALLED_DIR}/debug/lib/python38_d.lib"
"-DPython3_INCLUDE_DIR:PATH=${CURRENT_INSTALLED_DIR}/include/python3.8")
list(APPEND OPTIONS_DEBUG "-DPython3_LIBRARY=${CURRENT_INSTALLED_DIR}/debug/lib/python38_d.lib")
list(APPEND OPTIONS_RELEASE "-DPython3_LIBRARY=${CURRENT_INSTALLED_DIR}/lib/python38.lib")
elseif(VCPKG_TARGET_IS_LINUX)
list(APPEND ADDITIONAL_OPTIONS "-DPython3_LIBRARY_RELEASE:PATH=${CURRENT_INSTALLED_DIR}/lib/libpython38m.a"
"-DPython3_LIBRARY_DEBUG:PATH=${CURRENT_INSTALLED_DIR}/debug/lib/libpython38md.a"
"-DPython3_INCLUDE_DIR:PATH=${CURRENT_INSTALLED_DIR}/include/python3.8m")
list(APPEND OPTIONS_DEBUG "-DPython3_LIBRARY=${CURRENT_INSTALLED_DIR}/debug/lib/libpython38md.a")
list(APPEND OPTIONS_RELEASE "-DPython3_LIBRARY=${CURRENT_INSTALLED_DIR}/lib/libpython38m.a")
elseif(VCPKG_TARGET_IS_OSX)
#Need Python3 information on OSX within VCPKG
endif()
#ITK_PYTHON_SITE_PACKAGES_SUFFIX should be set to the install dir of the site-packages within vcpkg
endif()
set(USE_64BITS_IDS OFF)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL x64 OR VCPKG_TARGET_ARCHITECTURE STREQUAL arm64)
set(USE_64BITS_IDS ON)
endif()
file(REMOVE_RECURSE "${SOURCE_PATH}/CMake/FindOpenCL.cmake")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DBUILD_TESTING=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_PKGCONFIG_FILES=OFF
-DITK_DOXYGEN_HTML=OFF
-DDO_NOT_INSTALL_ITK_TEST_DRIVER=ON
-DITK_SKIP_PATH_LENGTH_CHECKS=ON
-DITK_INSTALL_DATA_DIR=share/itk/data
-DITK_INSTALL_DOC_DIR=share/itk/doc
-DITK_INSTALL_PACKAGE_DIR=share/itk
-DITK_USE_64BITS_IDS=${USE_64BITS_IDS}
-DITK_USE_CONCEPT_CHECKING=ON
#-DITK_USE_SYSTEM_LIBRARIES=ON # enables USE_SYSTEM for all third party libraries, some of which do not have vcpkg ports such as CastXML, SWIG, MINC etc
-DITK_USE_SYSTEM_DOUBLECONVERSION=ON
-DITK_USE_SYSTEM_EXPAT=ON
-DITK_USE_SYSTEM_JPEG=ON
-DITK_USE_SYSTEM_PNG=ON
-DITK_USE_SYSTEM_TIFF=ON
-DITK_USE_SYSTEM_ZLIB=ON
-DITK_USE_SYSTEM_EIGEN=ON
-DITK_USE_SYSTEM_FFTW=ON
-DITK_USE_SYSTEM_HDF5=ON # HDF5 was problematic in the past and still is. ITK still has not figured out how to do it correctly!
-DITK_USE_SYSTEM_GDCM=ON
-DITK_USE_SYSTEM_OpenJPEG=ON # Added by VCPKG
-DITK_USE_SYSTEM_DCMTK=ON
-DDCMTK_USE_ICU=ON
-DITK_USE_SYSTEM_ICU=ON
#-DITK_USE_SYSTEM_VXL=ON
#-DITK_USE_SYSTEM_CASTXML=ON # needs to be added to vcpkg_find_acquire_program https://data.kitware.com/api/v1/file/hashsum/sha512/b8b6f0aff11fe89ab2fcd1949cc75f2c2378a7bc408827a004396deb5ff5a9976bffe8a597f8db1b74c886ea39eb905e610dce8f5bd7586a4d6c196d7349da8d/download
-DITK_USE_SYSTEM_MINC=ON
-DITK_USE_SYSTEM_SWIG=ON
-DITK_FORBID_DOWNLOADS=OFF # This should be turned on some day, however for now ITK does download specific versions so it shouldn't spontaneously break. Remote Modules would probably break with this!
-DINSTALL_GTEST=OFF
-DITK_USE_SYSTEM_GOOGLETEST=ON
-DEXECUTABLE_OUTPUT_PATH=tools/${PORT}
# TODO
#-DVXL_USE_GEOTIFF=ON
-DVXL_USE_LFS=ON
-DITK_MINIMUM_COMPLIANCE_LEVEL:STRING=1 # To Display all remote modules within cmake-gui
#-DModule_IOSTL=ON # example how to turn on a non-default module
#-DModule_MorphologicalContourInterpolation=ON # example how to turn on a remote module
#-DModule_RLEImage=ON # example how to turn on a remote module
# Some additional wraping options
#-DITK_WRAP_double=ON
#-DITK_WRAP_complex_double=ON
#-DITK_WRAP_covariant_vector_double=ON
#-DITK_WRAP_vector_double=ON
${FEATURE_OPTIONS}
${ADDITIONAL_OPTIONS}
OPTIONS_DEBUG ${OPTIONS_DEBUG}
OPTIONS_RELEASE ${OPTIONS_RELEASE}
)
if(BUILD_RTK) # Remote Modules are only downloaded on configure.
# TODO: In the future try to download via vcpkg_from_github and move the files. That way patching does not need this workaround
vcpkg_apply_patches(SOURCE_PATH "${SOURCE_PATH}/Modules/Remote/RTK" QUIET PATCHES rtk/already_defined.patch rtk/unresolved.patch)
endif()
vcpkg_install_cmake()
vcpkg_copy_pdbs()
vcpkg_fixup_cmake_targets()
if(TOOL_NAMES)
vcpkg_copy_tools(TOOL_NAMES ${TOOL_NAMES} AUTO_CLEAN)
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/cmake")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)