2017-01-12 18:03:02 +08:00
include ( vcpkg_common_functions )
2017-08-28 16:48:30 +08:00
set ( VTK_SHORT_VERSION "8.0" )
set ( VTK_LONG_VERSION "${VTK_SHORT_VERSION}.0" )
2017-08-06 17:37:27 +08:00
vcpkg_from_github (
O U T _ S O U R C E _ P A T H S O U R C E _ P A T H
R E P O " K i t w a r e / V T K "
2017-08-28 16:48:30 +08:00
R E F " v $ { V T K _ L O N G _ V E R S I O N } "
2017-08-06 17:37:27 +08:00
S H A 5 1 2 1 a 3 2 8 f 2 4 d f 0 b 1 c 4 0 c 6 2 3 a e 8 0 c 9 d 4 9 f 8 b 2 7 5 7 0 1 4 4 b 1 0 a f 0 2 a e e d 4 1 b 9 0 b 5 0 b 8 d 4 e 0 d d 8 3 d 1 3 4 1 9 6 1 f 6 8 1 8 c d e 3 6 e 2 c d 7 9 3 c 5 7 8 e b c 9 5 a 4 6 9 5 0 c e b f c 5 1 8 f 4 8 6 f 2 4 9 7 9 1
H E A D _ R E F " m a s t e r "
2017-01-12 18:03:02 +08:00
)
2017-08-28 16:48:30 +08:00
# =============================================================================
# Options: These should be set by feature-packages when they become available
set ( VTK_WITH_QT ON ) # IMPORTANT: if ON make sure `qt5` is listed as dependency in the CONTROL file
set ( VTK_WITH_MPI ON ) # IMPORTANT: if ON make sure `mpi` is listed as dependency in the CONTROL file
set ( VTK_WITH_PYTHON OFF ) # IMPORTANT: if ON make sure `python3` is listed as dependency in the CONTROL file
set ( VTK_WITH_ALL_MODULES OFF ) # IMPORTANT: if ON make sure `qt5`, `mpi`, `python3`, `ffmpeg`, `gdal`, `fontconfig`,
# `libmysql` and `atlmfc` are listed as dependency in the CONTROL file
# =============================================================================
# Apply patches to the source code
2017-08-08 23:56:09 +08:00
vcpkg_apply_patches (
S O U R C E _ P A T H $ { S O U R C E _ P A T H }
P A T C H E S
2017-08-10 17:56:23 +08:00
# Disable ssize_t because this can conflict with ssize_t that is defined on windows.
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / d o n t - d e f i n e - s s i z e _ t . p a t c h
# We force CMake to use it's own version of the FindHDF5 module since newer versions
# shipped with CMake behave differently. E.g. the one shipped with CMake 3.9 always
# only finds the release libraries, but not the debug libraries.
# The file shipped with CMake allows us to set the libraries explicitly as it is done below.
# Maybe in the future we can disable the patch and use the new version shipped with CMake
# together with the hdf5-config.cmake that is written by HDF5 itself, but currently VTK
# disables taking the config into account explicitly.
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / u s e - f i x e d - f i n d - h d f 5 . p a t c h
# We disable a workaround in the VTK CMake scripts that can lead to the fact that a dependency
# will link to both, the debug and the release library.
2017-08-08 23:56:09 +08:00
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / d i s a b l e - w o r k a r o u n d - f i n d h d f 5 . p a t c h
2017-08-11 03:58:44 +08:00
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / f i x - f i n d - l i b p r o j 4 . p a t c h
2017-08-28 16:48:30 +08:00
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / f i x - f i n d - l i b h a r u . p a t c h
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / f i x - f i n d - m y s q l . p a t c h
$ { C M A K E _ C U R R E N T _ L I S T _ D I R } / f i x - f i n d - o d b c . p a t c h
2017-08-08 23:56:09 +08:00
)
2017-08-28 16:48:30 +08:00
# Remove the FindGLEW.cmake and FindPythonLibs.cmake that are distributed with VTK,
# since they do not detect the debug libraries correctly.
# The default files distributed with CMake (>= 3.9) should be superior by all means.
# For GDAL, the one distributed with CMake does not detect the debug libraries correctly,
# so we provide an own one.
2017-08-11 00:20:40 +08:00
file ( REMOVE ${ SOURCE_PATH } /CMake/FindGLEW.cmake )
2017-08-28 16:48:30 +08:00
file ( REMOVE ${ SOURCE_PATH } /CMake/FindPythonLibs.cmake )
file ( COPY ${ CMAKE_CURRENT_LIST_DIR } /FindGDAL.cmake DESTINATION ${ SOURCE_PATH } /CMake )
# =============================================================================
# Collect CMake options for optional components
if ( VTK_WITH_QT )
list ( APPEND ADDITIONAL_OPTIONS
- D V T K _ G r o u p _ Q t = O N
- D V T K _ Q T _ V E R S I O N = 5
- D V T K _ B U I L D _ Q T _ D E S I G N E R _ P L U G I N = O F F
)
endif ( )
if ( VTK_WITH_MPI )
list ( APPEND ADDITIONAL_OPTIONS
- D V T K _ G r o u p _ M P I = O N
)
endif ( )
if ( VTK_WITH_PYTHON )
list ( APPEND ADDITIONAL_OPTIONS
- D V T K _ W R A P _ P Y T H O N = O N
- D V T K _ P Y T H O N _ V E R S I O N = 3
)
endif ( )
if ( VTK_WITH_ALL_MODULES )
list ( APPEND ADDITIONAL_OPTIONS
- D V T K _ B U I L D _ A L L _ M O D U L E S = O N
- D V T K _ U S E _ T K = O F F # TCL/TK currently not included in vcpkg
# -DVTK_USE_SYSTEM_AUTOBAHN=ON
# -DVTK_USE_SYSTEM_SIX=ON
# -DVTK_USE_SYSTEM_MPI4PY=ON
# -DVTK_USE_SYSTEM_CONSTANTLY=ON
# -DVTK_USE_SYSTEM_INCREMENTAL=ON
# -DVTK_USE_SYSTEM_TWISTED=ON
# -DVTK_USE_SYSTEM_XDMF2=ON
# -DVTK_USE_SYSTEM_XDMF3=ON
# -DVTK_USE_SYSTEM_ZFP=ON
# -DVTK_USE_SYSTEM_ZOPE=ON
)
endif ( )
2017-08-11 00:20:40 +08:00
2017-01-12 18:03:02 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
2017-08-06 17:37:27 +08:00
list ( APPEND ADDITIONAL_OPTIONS "-DVTK_EXTERNAL_HDF5_IS_SHARED=ON" )
2017-01-12 18:03:02 +08:00
endif ( )
2017-08-28 16:48:30 +08:00
# =============================================================================
# Configure & Install
2017-01-12 18:03:02 +08:00
vcpkg_configure_cmake (
S O U R C E _ P A T H $ { S O U R C E _ P A T H }
2017-02-28 21:45:42 +08:00
P R E F E R _ N I N J A
2017-01-12 18:03:02 +08:00
O P T I O N S
2017-08-28 16:48:30 +08:00
- D V T K _ G r o u p _ I m a g i n g = O N
- D V T K _ G r o u p _ V i e w s = O N
2017-01-12 18:03:02 +08:00
- D B U I L D _ T E S T I N G = O F F
2017-02-28 21:45:42 +08:00
- D B U I L D _ E X A M P L E S = O F F
2017-01-12 18:03:02 +08:00
- D V T K _ U S E _ S Y S T E M _ E X P A T = O N
- D V T K _ U S E _ S Y S T E M _ F R E E T Y P E = O N
# -DVTK_USE_SYSTEM_GL2PS=ON
2017-08-28 16:48:30 +08:00
- D V T K _ U S E _ S Y S T E M _ L I B H A R U = O N
2017-08-11 03:58:44 +08:00
- D V T K _ U S E _ S Y S T E M _ J P E G = O N
2017-01-12 18:03:02 +08:00
- D V T K _ U S E _ S Y S T E M _ G L E W = O N
- D V T K _ U S E _ S Y S T E M _ H D F 5 = O N
- D V T K _ U S E _ S Y S T E M _ J S O N C P P = O N
2017-08-11 03:58:44 +08:00
- D V T K _ U S E _ S Y S T E M _ L I B P R O J 4 = O N
2017-01-12 18:03:02 +08:00
- D V T K _ U S E _ S Y S T E M _ L I B X M L 2 = O N
2017-08-11 03:58:44 +08:00
- D V T K _ U S E _ S Y S T E M _ L Z 4 = O N
2017-01-12 18:03:02 +08:00
# -DVTK_USE_SYSTEM_NETCDF=ON
2017-08-11 03:58:44 +08:00
# -DVTK_USE_SYSTEM_NETCDFCPP=ON
2017-08-11 16:17:32 +08:00
- D V T K _ U S E _ S Y S T E M _ O G G T H E O R A = O N
2017-01-12 18:03:02 +08:00
- D V T K _ U S E _ S Y S T E M _ P N G = O N
- D V T K _ U S E _ S Y S T E M _ T I F F = O N
- D V T K _ U S E _ S Y S T E M _ Z L I B = O N
2017-08-11 16:17:32 +08:00
- D V T K _ I N S T A L L _ I N C L U D E _ D I R = i n c l u d e
2017-01-12 18:03:02 +08:00
- D V T K _ I N S T A L L _ D A T A _ D I R = s h a r e / v t k / d a t a
- D V T K _ I N S T A L L _ D O C _ D I R = s h a r e / v t k / d o c
- D V T K _ I N S T A L L _ P A C K A G E _ D I R = s h a r e / v t k
2017-02-28 21:45:42 +08:00
- D V T K _ F O R B I D _ D O W N L O A D S = O N
2017-01-12 18:03:02 +08:00
$ { A D D I T I O N A L _ O P T I O N S }
2017-02-28 21:45:42 +08:00
O P T I O N S _ R E L E A S E
- D H D F 5 _ C _ L I B R A R Y = $ { C U R R E N T _ I N S T A L L E D _ D I R } / l i b / h d f 5 . l i b
- D H D F 5 _ C _ H L _ L I B R A R Y = $ { C U R R E N T _ I N S T A L L E D _ D I R } / l i b / h d f 5 _ h l . l i b
O P T I O N S _ D E B U G
- D H D F 5 _ C _ L I B R A R Y = $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g / l i b / h d f 5 _ D . l i b
- D H D F 5 _ C _ H L _ L I B R A R Y = $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g / l i b / h d f 5 _ h l _ D . l i b
2017-01-12 18:03:02 +08:00
)
vcpkg_install_cmake ( )
vcpkg_copy_pdbs ( )
2017-08-28 16:48:30 +08:00
# =============================================================================
# Fixup target files
2017-08-10 17:56:23 +08:00
vcpkg_fixup_cmake_targets ( )
2017-01-12 18:03:02 +08:00
2017-08-28 16:48:30 +08:00
# For some reason the references to the XDMF libraries in the target files do not end up
# correctly, so we fix them here.
if ( VTK_WITH_ALL_MODULES )
file ( READ ${ CURRENT_PACKAGES_DIR } /share/vtk/VTKTargets-release.cmake VTK_TARGETS_RELEASE_CONTENT )
string ( REPLACE "lib/../XdmfCore.lib" "lib/XdmfCore.lib" VTK_TARGETS_RELEASE_CONTENT "${VTK_TARGETS_RELEASE_CONTENT}" )
string ( REPLACE "bin/../XdmfCore.dll" "bin/XdmfCore.dll" VTK_TARGETS_RELEASE_CONTENT "${VTK_TARGETS_RELEASE_CONTENT}" )
string ( REPLACE "lib/../vtkxdmf3.lib" "lib/vtkxdmf3.lib" VTK_TARGETS_RELEASE_CONTENT "${VTK_TARGETS_RELEASE_CONTENT}" )
string ( REPLACE "bin/../vtkxdmf3.dll" "bin/vtkxdmf3.dll" VTK_TARGETS_RELEASE_CONTENT "${VTK_TARGETS_RELEASE_CONTENT}" )
file ( WRITE ${ CURRENT_PACKAGES_DIR } /share/vtk/VTKTargets-release.cmake "${VTK_TARGETS_RELEASE_CONTENT}" )
file ( READ ${ CURRENT_PACKAGES_DIR } /share/vtk/VTKTargets-debug.cmake VTK_TARGETS_DEBUG_CONTENT )
string ( REPLACE "lib/../XdmfCore.lib" "lib/XdmfCore.lib" VTK_TARGETS_DEBUG_CONTENT "${VTK_TARGETS_DEBUG_CONTENT}" )
string ( REPLACE "bin/../XdmfCore.dll" "bin/XdmfCore.dll" VTK_TARGETS_DEBUG_CONTENT "${VTK_TARGETS_DEBUG_CONTENT}" )
string ( REPLACE "lib/../vtkxdmf3.lib" "lib/vtkxdmf3.lib" VTK_TARGETS_DEBUG_CONTENT "${VTK_TARGETS_DEBUG_CONTENT}" )
string ( REPLACE "bin/../vtkxdmf3.dll" "bin/vtkxdmf3.dll" VTK_TARGETS_DEBUG_CONTENT "${VTK_TARGETS_DEBUG_CONTENT}" )
file ( WRITE ${ CURRENT_PACKAGES_DIR } /share/vtk/VTKTargets-debug.cmake "${VTK_TARGETS_DEBUG_CONTENT}" )
endif ( )
# For VTK `vcpkg_fixup_cmake_targets` is not enough:
2017-08-10 17:56:23 +08:00
# Files for system third party dependencies are written to modules that
# are located in the paths `share/vtk/Modules` and `debug/share/vtk/Modules`.
# In the release folder, only the release libraries are referenced (e.g. "C:/vcpkg/installed/x64-windows/lib/zlib.lib").
# But in the debug folder both libraries (e.g. "optimized;C:/vcpkg/installed/x64-windows/lib/zlib.lib;debug;C:/vcpkg/installed/x64-windows/debug/lib/zlibd.lib")
# or only the debug library (e.g. "C:/vcpkg/installed/x64-windows/debug/lib/hdf5_D.lib") is referenced.
# This is because VCPKG appends only the release library prefix (.../x64-windows/lib)
# when configuring release but both (.../x64-windows/lib and .../x64-windows/debug/lib)
# when configuring debug.
# Now if we delete the debug/share/Modules folder and just leave share/Modules, a library
# that links to VTK will always use the release third party dependencies, even if
# debug VTK is used.
#
# The following code merges the libraries from both release and debug:
2017-01-12 18:03:02 +08:00
2017-08-10 21:29:42 +08:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /SplitLibraryConfigurations.cmake )
2017-08-10 17:56:23 +08:00
function ( _vtk_combine_third_party_libraries MODULE_NAME )
set ( MODULE_LIBRARIES_REGEX "set\\(${MODULE_NAME}_LIBRARIES \" ( [^\ "]*)\" \\)")
# Read release libraries
file ( READ "${CURRENT_PACKAGES_DIR}/share/vtk/Modules/${MODULE_NAME}.cmake" RELEASE_MODULE_CONTENT )
if ( "${RELEASE_MODULE_CONTENT}" MATCHES "${MODULE_LIBRARIES_REGEX}" )
set ( RELEASE_LIBRARY_LIST "${CMAKE_MATCH_1}" )
else ( )
message ( FATAL_ERROR "Could not extract module libraries for ${MODULE_NAME}" )
endif ( )
# Read debug libraries
file ( READ "${CURRENT_PACKAGES_DIR}/debug/share/vtk/Modules/${MODULE_NAME}.cmake" DEBUG_MODULE_CONTENT )
if ( "${DEBUG_MODULE_CONTENT}" MATCHES "${MODULE_LIBRARIES_REGEX}" )
set ( DEBUG_LIBRARY_LIST "${CMAKE_MATCH_1}" )
else ( )
message ( FATAL_ERROR "Could not extract module libraries for ${MODULE_NAME}" )
endif ( )
2017-08-10 21:29:42 +08:00
split_library_configurations ( "${RELEASE_LIBRARY_LIST}" OPTIMIZED_RELEASE_LIBRARIES DEBUG_RELEASE_LIBRARIES GENERAL_RELEASE_LIBRARIES )
split_library_configurations ( "${DEBUG_LIBRARY_LIST}" OPTIMIZED_DEBUG_LIBRARIES DEBUG_DEBUG_LIBRARIES GENERAL_DEBUG_LIBRARIES )
# Combine libraries and wrap them in generator expressions
foreach ( LIBRARY ${ OPTIMIZED_RELEASE_LIBRARIES } ${ GENERAL_RELEASE_LIBRARIES } )
list ( APPEND LIBRARY_LIST "$<$<NOT:$<CONFIG:Debug>>:${LIBRARY}>" )
endforeach ( )
foreach ( LIBRARY ${ DEBUG_DEBUG_LIBRARIES } ${ GENERAL_DEBUG_LIBRARIES } )
list ( APPEND LIBRARY_LIST "$<$<CONFIG:Debug>:${LIBRARY}>" )
endforeach ( )
2017-08-10 17:56:23 +08:00
# Write combined libraries back
string ( REGEX REPLACE "${MODULE_LIBRARIES_REGEX}"
" set ( ${ MODULE_NAME } _LIBRARIES \"${LIBRARY_LIST}\")"
R E L E A S E _ M O D U L E _ C O N T E N T
" $ { R E L E A S E _ M O D U L E _ C O N T E N T } "
)
file ( WRITE "${CURRENT_PACKAGES_DIR}/share/vtk/Modules/${MODULE_NAME}.cmake" "${RELEASE_MODULE_CONTENT}" )
endfunction ( )
# IMPORTANT: Please make sure to extend this list whenever a new library is marked `USE_SYSTEM` in the configure step above!
set ( SYSTEM_THIRD_PARTY_MODULES
v t k e x p a t
v t k f r e e t y p e
2017-08-11 03:58:44 +08:00
v t k j p e g
2017-08-10 17:56:23 +08:00
v t k g l e w
v t k h d f 5
v t k j s o n c p p
2017-08-11 03:58:44 +08:00
v t k l i b p r o j 4
2017-08-10 17:56:23 +08:00
v t k l i b x m l 2
2017-08-11 03:58:44 +08:00
v t k l z 4
2017-08-11 16:17:32 +08:00
v t k o g g t h e o r a
2017-08-10 17:56:23 +08:00
v t k p n g
v t k t i f f
v t k z l i b
2017-08-28 16:48:30 +08:00
# vtkgl2ps
v t k l i b h a r u
2017-08-10 17:56:23 +08:00
)
2017-08-28 16:48:30 +08:00
if ( VTK_WITH_PYTHON OR VTK_WITH_ALL_MODULES )
list ( APPEND SYSTEM_THIRD_PARTY_MODULES
v t k P y t h o n
)
endif ( )
if ( VTK_WITH_ALL_MODULES )
list ( APPEND SYSTEM_THIRD_PARTY_MODULES
A u t o b a h n P y t h o n
)
endif ( )
2017-08-10 17:56:23 +08:00
foreach ( MODULE IN LISTS SYSTEM_THIRD_PARTY_MODULES )
_vtk_combine_third_party_libraries ( "${MODULE}" )
endforeach ( )
2017-08-10 23:05:43 +08:00
# Remove all explicit references to vcpkg system libraries in the general VTKTargets.cmake file
# since these references always point to the release libraries, even in the debug case.
# The dependencies should be handled by the explicit modules we fixed above, so removing
# them here shouldn't cause any problems.
file ( READ "${CURRENT_PACKAGES_DIR}/share/vtk/VTKTargets.cmake" VTK_TARGETS_CONTENT )
string ( REGEX REPLACE "${CURRENT_INSTALLED_DIR}/lib/[^\\.]*\\.lib" "" VTK_TARGETS_CONTENT "${VTK_TARGETS_CONTENT}" )
file ( WRITE "${CURRENT_PACKAGES_DIR}/share/vtk/VTKTargets.cmake" "${VTK_TARGETS_CONTENT}" )
2017-08-28 16:48:30 +08:00
# =============================================================================
# Move executable to tools directory and clean-up other directories
2017-08-10 18:06:49 +08:00
file ( MAKE_DIRECTORY ${ CURRENT_PACKAGES_DIR } /tools/vtk )
2017-01-12 18:03:02 +08:00
2017-08-28 16:48:30 +08:00
function ( _vtk_move_tool TOOL_NAME )
if ( EXISTS ${ CURRENT_PACKAGES_DIR } /bin/ ${ TOOL_NAME } .exe )
file ( RENAME ${ CURRENT_PACKAGES_DIR } /bin/ ${ TOOL_NAME } .exe ${ CURRENT_PACKAGES_DIR } /tools/vtk/ ${ TOOL_NAME } .exe )
endif ( )
file ( REMOVE ${ CURRENT_PACKAGES_DIR } /debug/bin/ ${ TOOL_NAME } .exe )
endfunction ( )
set ( VTK_TOOLS
v t k E n c o d e S t r i n g - $ { V T K _ S H O R T _ V E R S I O N }
v t k H a s h S o u r c e - $ { V T K _ S H O R T _ V E R S I O N }
v t k W r a p T c l I n i t - $ { V T K _ S H O R T _ V E R S I O N }
v t k W r a p T c l - $ { V T K _ S H O R T _ V E R S I O N }
v t k W r a p P y t h o n I n i t - $ { V T K _ S H O R T _ V E R S I O N }
v t k W r a p P y t h o n - $ { V T K _ S H O R T _ V E R S I O N }
v t k W r a p J a v a - $ { V T K _ S H O R T _ V E R S I O N }
v t k W r a p H i e r a r c h y - $ { V T K _ S H O R T _ V E R S I O N }
v t k P a r s e J a v a - $ { V T K _ S H O R T _ V E R S I O N }
v t k P a r s e O G L E x t - $ { V T K _ S H O R T _ V E R S I O N }
v t k p y t h o n
p v t k p y t h o n
)
foreach ( TOOL_NAME IN LISTS VTK_TOOLS )
_vtk_move_tool ( "${TOOL_NAME}" )
endforeach ( )
# =============================================================================
# Remove other files and directories that are not valid for vcpkg
if ( VTK_WITH_ALL_MODULES )
file ( REMOVE ${ CURRENT_PACKAGES_DIR } /XdmfConfig.cmake )
file ( REMOVE ${ CURRENT_PACKAGES_DIR } /debug/XdmfConfig.cmake )
endif ( )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL static )
2017-08-06 17:37:27 +08:00
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /bin )
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /debug/bin )
endif ( )
2017-01-12 18:03:02 +08:00
2017-08-10 17:56:23 +08:00
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /debug/include )
file ( REMOVE_RECURSE ${ CURRENT_PACKAGES_DIR } /debug/share )
2017-08-28 16:48:30 +08:00
# =============================================================================
2017-01-12 18:03:02 +08:00
# Handle copyright
file ( COPY ${ SOURCE_PATH } /Copyright.txt DESTINATION ${ CURRENT_PACKAGES_DIR } /share/vtk )
file ( RENAME ${ CURRENT_PACKAGES_DIR } /share/vtk/Copyright.txt ${ CURRENT_PACKAGES_DIR } /share/vtk/copyright )