2017-01-12 18:03:02 +08:00
include ( vcpkg_common_functions )
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 "
R E F " v 8 . 0 . 0 "
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-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-08 23:56:09 +08:00
)
2017-08-11 00:20:40 +08:00
# Remove the FindGLEW.cmake that is distributed with VTK, since it does not
# detect the debug libraries correctly.
# The default file distributed with CMake should be superior by all means.
file ( REMOVE ${ SOURCE_PATH } /CMake/FindGLEW.cmake )
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 ( )
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
- 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 _ G r o u p _ M P I = O N
- 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
# -DVTK_WRAP_PYTHON=ON
# -DVTK_PYTHON_VERSION=3
- 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-11 03:58:44 +08:00
# -DVTK_USE_SYSTEM_LIBHARU=ON
- 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-10 17:56:23 +08:00
vcpkg_fixup_cmake_targets ( )
2017-01-12 18:03:02 +08:00
2017-08-10 17:56:23 +08:00
# For VTK vcpkg_fixup_cmake_targets is not enough:
# 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
)
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}" )
# Move executable to tools directory
2017-08-10 18:06:49 +08:00
file ( MAKE_DIRECTORY ${ CURRENT_PACKAGES_DIR } /tools/vtk )
file ( RENAME ${ CURRENT_PACKAGES_DIR } /bin/vtkEncodeString-8.0.exe ${ CURRENT_PACKAGES_DIR } /tools/vtk/vtkEncodeString-8.0.exe )
file ( RENAME ${ CURRENT_PACKAGES_DIR } /bin/vtkHashSource-8.0.exe ${ CURRENT_PACKAGES_DIR } /tools/vtk/vtkHashSource-8.0.exe )
2017-01-12 18:03:02 +08:00
2017-08-06 17:37:27 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
file ( REMOVE ${ CURRENT_PACKAGES_DIR } /debug/bin/vtkEncodeString-8.0.exe )
file ( REMOVE ${ CURRENT_PACKAGES_DIR } /debug/bin/vtkHashSource-8.0.exe )
else ( )
# On static builds there should be no bin directory at all
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-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 )