[vcpkg-cmake-toolchain] Remove some hardcoded find_package helpers and guard all remaining ones

This commit is contained in:
Robert Schumacher 2018-04-05 21:39:47 -07:00
parent 47ee755807
commit 35f5a0de53

View File

@ -187,7 +187,7 @@ macro(find_package name)
unset(Boost_USE_STATIC_RUNTIME)
set(Boost_COMPILER "-vc140")
_find_package(${ARGV})
elseif("${name}" STREQUAL "ICU")
elseif("${name}" STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/unicode/utf.h")
function(_vcpkg_find_in_list)
list(FIND ARGV "COMPONENTS" COMPONENTS_IDX)
set(COMPONENTS_IDX ${COMPONENTS_IDX} PARENT_SCOPE)
@ -198,7 +198,7 @@ macro(find_package name)
else()
_find_package(${ARGV})
endif()
elseif("${name}" STREQUAL "TIFF")
elseif("${name}" STREQUAL "TIFF" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/tiff.h")
_find_package(${ARGV})
find_package(LibLZMA)
if(TARGET TIFF::TIFF)
@ -207,24 +207,7 @@ macro(find_package name)
if(TIFF_LIBRARIES)
list(APPEND TIFF_LIBRARIES ${LIBLZMA_LIBRARIES})
endif()
elseif("${name}" STREQUAL "Freetype")
_find_package(${ARGV})
find_package(ZLIB)
find_package(PNG)
find_package(BZip2)
if(TARGET Freetype::Freetype)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2 PNG::PNG ZLIB::ZLIB)
endif()
if(FREETYPE_LIBRARIES)
list(APPEND FREETYPE_LIBRARIES ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
endif()
elseif("${name}" STREQUAL "tinyxml2")
_find_package(${ARGV})
if(TARGET tinyxml2_static AND NOT TARGET tinyxml2)
_add_library(tinyxml2 INTERFACE IMPORTED)
set_target_properties(tinyxml2 PROPERTIES INTERFACE_LINK_LIBRARIES "tinyxml2_static")
endif()
elseif(("${name}" STREQUAL "HDF5" OR "${name}" STREQUAL "hdf5") AND NOT PROJECT_NAME STREQUAL "VTK")
elseif(("${name}" STREQUAL "HDF5" OR "${name}" STREQUAL "hdf5") AND NOT PROJECT_NAME STREQUAL "VTK" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/hdf5.h")
# This is a hack to make VTK work. TODO: find another way to suppress the built-in find module.
_find_package(${ARGV} CONFIG)
# Fill in missing static/shared targets
@ -237,7 +220,7 @@ macro(find_package name)
set_target_properties(hdf5::${HDF5TARGET}-static PROPERTIES INTERFACE_LINK_LIBRARIES "hdf5::${HDF5TARGET}-shared")
endif()
endforeach()
elseif("${name}" STREQUAL "GSL")
elseif("${name}" STREQUAL "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/gsl")
_find_package(${ARGV})
if(GSL_FOUND AND TARGET GSL::gsl)
set_property( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Release )
@ -249,7 +232,7 @@ macro(find_package name)
set_target_properties( GSL::gslcblas PROPERTIES IMPORTED_LOCATION_DEBUG "${GSL_CBLAS_LIBRARY_DEBUG}" )
endif()
endif()
elseif("${name}" STREQUAL "CURL")
elseif("${name}" STREQUAL "CURL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/curl")
_find_package(${ARGV})
if(CURL_FOUND)
if(EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/nghttp2.lib")
@ -258,16 +241,6 @@ macro(find_package name)
"optimized" "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/nghttp2.lib")
endif()
endif()
elseif("${name}" STREQUAL "LibXml2")
_find_package(${ARGV})
if(LibXml2_FOUND AND (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore"))
list(APPEND LIBXML2_LIBRARIES
debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/libiconv.lib
optimized ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libiconv.lib
debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/libcharset.lib
optimized ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libcharset.lib
ws2_32)
endif()
else()
_find_package(${ARGV})
endif()