vcpkg/ports/vtk/FindLZMA.patch
Alexander Neumann 03766d0834
[CGNS/ParaView] Add new ports (#9960)
* [cgns] add port cgns

* [paraview] add new port

* [paraview] correct dependencies; disable catalyst

* [VTK/ParaView] Make ParaView build

* [paraview] add missing patch

* [paraview] add cgns patch

* [paraview] add qt plugin patches back in. Remove in the future

* [vtk] slightly improved patches

* [vtk] don't disable findPython

* [paraview] add more features

* [paraview] remove X11Extras from OSX

* [vtk] make vtk workcorrectly with python and prepare for paraview with python

* [paraview] Python fixes

* [paraview] small bin -> lib replacement fix for static builds

* [vtk] fix patch path

* update baseline to exclude paraview for the time being on osx and linux.
requires a fix in qt5-base linkage of libpq.

* [paraview]try setting LD_LIBRARY_PATH for unix systems

* [paraview] a bit of cleanup

* update baseline

* fix typo in baseline

* [paraview] remove unnecessary patch

* [vtk] replace custom patch with upstream patch

* [paraview] cleanup in the portfile.

* Update ports/paraview/CONTROL

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
2020-06-23 10:20:18 -07:00

86 lines
3.2 KiB
Diff

diff --git a/CMake/FindLZMA.cmake b/CMake/FindLZMA.cmake
index 0c8c7943c..d60669484 100644
--- a/CMake/FindLZMA.cmake
+++ b/CMake/FindLZMA.cmake
@@ -1,9 +1,17 @@
find_path(LZMA_INCLUDE_DIR
NAMES lzma.h
DOC "lzma include directory")
-find_library(LZMA_LIBRARY
+# Note LZMA_LIBRARY is set somewhere else. Maybe one of the configs/wrappers installed by VCPKG defines it.
+# The original FindLZMA chokes on it since it contains optimized/debug keywords
+# VTK should probably switch to FindLibLZMA from CMake
+find_library(LZMA_LIBRARY_RELEASE
NAMES lzma
DOC "lzma library")
+find_library(LZMA_LIBRARY_DEBUG
+ NAMES lzmad lzma NAMES_PER_DIR
+ DOC "lzma library")
+ include(SelectLibraryConfigurations)
+ select_library_configurations( LZMA )
if (LZMA_INCLUDE_DIR)
file(STRINGS "${LZMA_INCLUDE_DIR}/lzma/version.h" _lzma_version_lines
@@ -20,22 +26,50 @@ endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZMA
- REQUIRED_VARS LZMA_LIBRARY LZMA_INCLUDE_DIR
+ REQUIRED_VARS LZMA_LIBRARY LZMA_LIBRARY_RELEASE LZMA_LIBRARY_DEBUG LZMA_INCLUDE_DIR
VERSION_VAR LZMA_VERSION)
if (LZMA_FOUND)
set(LZMA_LIBRARIES "${LZMA_LIBRARY}")
set(LZMA_INCLUDE_DIRS "${LZMA_INCLUDE_DIR}")
-
+
if (NOT TARGET LZMA::LZMA)
include(vtkDetectLibraryType)
- vtk_detect_library_type(lzma_library_type
- PATH "${LZMA_LIBRARY}")
- add_library(LZMA::LZMA "${lzma_library_type}" IMPORTED)
- unset(lzma_library_type)
- set_target_properties(LZMA::LZMA PROPERTIES
- IMPORTED_LOCATION "${LZMA_LIBRARY}"
- IMPORTED_IMPLIB "${LZMA_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${LZMA_INCLUDE_DIR}")
- endif ()
+ if(LZMA_LIBRARY_RELEASE)
+ vtk_detect_library_type(lzma_library_type
+ PATH "${LZMA_LIBRARY_RELEASE}")
+ elseif(LZMA_LIBRARY_DEBUG)
+ vtk_detect_library_type(lzma_library_type
+ PATH "${LZMA_LIBRARY_DEBUG}")
+ else()
+ vtk_detect_library_type(lzma_library_type
+ PATH "${LZMA_LIBRARY}")
+ endif()
+
+ add_library(LZMA::LZMA "${lzma_library_type}" IMPORTED)
+ set_target_properties(LZMA::LZMA PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${LZMA_INCLUDE_DIR}")
+ if(LZMA_LIBRARY_RELEASE)
+ set_target_properties(LZMA::LZMA PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LZMA_LIBRARY_RELEASE}"
+ IMPORTED_IMPLIB_RELEASE "${LZMA_LIBRARY_RELEASE}")
+ endif()
+ if(LZMA_LIBRARY_DEBUG)
+ set_target_properties(LZMA::LZMA PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${LZMA_LIBRARY_DEBUG}"
+ IMPORTED_IMPLIB_DEBUG "${LZMA_LIBRARY_DEBUG}")
+ endif()
+
+ # Guard against possible stupidity of depending projects reading only LOCATION without configuration
+ if(CMAKE_BUILD_TYPE MATCHES "Debug")
+ set_target_properties(LZMA::LZMA PROPERTIES
+ IMPORTED_LOCATION "${LZMA_LIBRARY_DEBUG}"
+ IMPORTED_IMPLIB "${LZMA_LIBRARY_DEBUG}")
+ else()
+ set_target_properties(LZMA::LZMA PROPERTIES
+ IMPORTED_LOCATION "${LZMA_LIBRARY_RELEASE}"
+ IMPORTED_IMPLIB "${LZMA_LIBRARY_RELEASE}")
+ endif()
+ endif()
+ #set_target_properties(LZMA::LZMA PROPERTIES IMPORTED_GLOBAL TRUE)
endif ()