vcpkg/ports/clapack/FindLAPACK.cmake
Stefano Sinigardi 47d206e149 [many ports] improvements for linux/wsl (#6730)
* [many ports] improve compatibility with WSL and mixed case filesystems

* [treehopper] express dependency on libusb, which was not working on non-win32 platforms and is still broken there

* [libharu] add compatibility with non-win32 platforms

* [geogram] fix openblas on linux
[clapack] better integration with linux environment
[visit-struct] put cmake config file in the expected folder
[geogram] remove trailing underscore to enable compatibility with OpenBLAS

* [openblas] playing with underscore, without success

* [openblas/lapack] fix library integration

* [clapack] improve target handling in cmake module

* [openblas] promote self-generated config to default cmake module, otherwise internal ones thinks wrongly that openblas can also solve lapack libs

* [clapack,openblas] improve libraries integration

* [many ports] fix cmake unnecessary target paths, wrong config paths, empty default dependencies, unnecessary [core] tags

* [suitesparse] improve integration with new lapack/openblas mechanism

* [suitesparse] add no underscore postfix also for linux

* [ceres] fix integration with newer openblas/lapack configs

* [aws-c-event-stream] fix regression

* [systemc] fix regression

* [libwebp,geogram] trigger rebuild

* [libwebp,pthread4w] fix regressions

* [glbinding] fix cmake module installation

* [globjects] disentangle unnecessary dependency from qt5

* [jasper] remove broken and unnecessary patches

* [libwebp] fix regression

* [many ports] avoid using BUILD_SHARED_LIBS which is uninitialized in port files

* [clapack] correctly find dlls

* [clapack] use a generic blas as dependency

* [fizz,g2o] restore expected version

* fix mistake

* [many ports] remove WIN32, APPLE and UNIX (again, they keep creeping in) from ports since they are broken and usually break non-win32 ports

* [libressl,openssl] do not try to build one if the other is already installed

* [itk] update ref and patch to avoid regression

* [libressl,openssl] implement full strategy to fix CI

* [libwebp] disable components that are broken on macOS

* [ogre] enable macOS build

* [freeimage,jxrlib,ogre,openexr,protobuf] port patches from #5169

* [ogre] add missing install command

* [ffmpeg] enable wrapper for cmake module

* [ffmpeg] add avresample module finder

* [ffmpeg] improve module detection and exported symbols

* [ffmpeg] add variables to cache

* [thrift] remove unnecessary build option

* [allegro5] fix shared/static inversion

* [protobuf] cleanup

* [libressl] cleanup

* [moos-core] cleanup

* commented features must not be separated from other features, otherwise vcpkg complains

* [itk] fix regression

* [shogun,itk] fix regressions

* [ogre] fix regression

* [opusfile] add compatibility with non-win32

* [itk] fix regression

* [sndfile,libsndfile] remove duplicate, redirect sndfile to libsndfile

* add missing dependencies

* [ismrmrd] fix regression

* [ffmpeg] trigger rebuild

* [clapack,openblas,libogg] fix regressions on macOS

* [libtins] fix regression

* force rebuild windows regressions, unable to reproduce locally

* [mosquitto] enable non-win32 builds

* [json-dto] force rebuild, unable to reproduce regression locally

* [many ports] uniform naming and path length requests

* fix regression

* fix regression

* [ffmpeg] fixes for downstream projects

* clean up - thanks to reviewers

* trigger rebuild of regressions on macOS

* trigger rebuild of regressions on macOS - part2

* Add core back

* Use VCPKG_CONCURRENCY

* Add core back to suitesparse

* Add core back to curl

* Add core back to magnum

* Add core back to magnum

* Add core back to magnum

* Add core back to cgal
2019-06-20 19:11:54 -07:00

238 lines
9.8 KiB
CMake

#.rst:
# clapack config for vcpkg
# ------------
#
# Find the clapack includes and library.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This script defines the following variables:
#
# ``CLAPACK_FOUND``
# True if clapack library found
#
# ``CLAPACK_VERSION``
# Containing the clapack version tag (manually defined)
#
# ``CLAPACK_INCLUDE_DIR``
# Location of clapack headers
#
# ``CLAPACK_LIBRARY``
# List of libraries to link with when using clapack
#
# Result Targets
# ^^^^^^^^^^^^^^
#
# This script defines the following targets:
#
# ``clapack::clapack``
# Target to use clapack
#
# Compatibility Variables
# ^^^^^^^^^^^^^^^^^^^^^^^
#
# This script defines the following variables for compatibility reasons:
#
# ``F2C_FOUND``
# True if f2c (fortran-to-c wrap layer) library found
#
# ``F2C_INCLUDE_DIR``
# Location of clapack headers
#
# ``F2C_LIBRARY``
# Library containing the fortran-to-c wrap layer, necessary for clapack and automatically included when used
#
# ``LAPACK_FOUND``
# True if clapack library found
#
# ``LAPACK_VERSION``
# Containing the clapack version tag (manually defined)
#
# ``LAPACK_INCLUDE_DIR``
# Location of clapack headers
#
# ``LAPACK_LIBRARY``
# List of libraries to link with when using clapack
#
# Compatibility Targets
# ^^^^^^^^^^^^^^
#
# This script defines the following targets for compatibility reasons:
#
# ``lapack``
# Target to use lapack
include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
include(${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
include(${CMAKE_ROOT}/Modules/CMakeFindDependencyMacro.cmake)
set(CLAPACK_VERSION "3.2.1")
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_dependency(Threads)
if(UNIX)
find_library(ADDITIONAL_LAPACK_LIBRARY m)
set(PTHREAD_LINK_NAME "-pthread")
endif()
if(NOT F2C_LIBRARY)
find_library(F2C_LIBRARY_RELEASE NAMES f2c libf2c)
find_library(F2C_LIBRARY_DEBUG NAMES f2cd libf2cd)
select_library_configurations(F2C)
#keep a list of "pure" f2c libs, without dependencies
set(oF2C_LIBRARY_RELEASE ${F2C_LIBRARY_RELEASE})
set(oF2C_LIBRARY_DEBUG ${F2C_LIBRARY_DEBUG})
set(oF2C_LIBRARY ${F2C_LIBRARY})
list(APPEND F2C_LIBRARY ${ADDITIONAL_LAPACK_LIBRARY})
endif()
if(NOT LAPACK_LIBRARY)
find_library(LAPACK_LIBRARY_RELEASE NAMES lapack)
find_library(LAPACK_LIBRARY_DEBUG NAMES lapackd)
#keep a list of "pure" lapack libs, without dependencies
set(oLAPACK_LIBRARY_RELEASE ${LAPACK_LIBRARY_RELEASE})
set(oLAPACK_LIBRARY_DEBUG ${LAPACK_LIBRARY_DEBUG})
select_library_configurations(oLAPACK)
list(APPEND LAPACK_LIBRARY_RELEASE ${F2C_LIBRARY_RELEASE})
list(APPEND LAPACK_LIBRARY_DEBUG ${F2C_LIBRARY_DEBUG})
find_dependency(BLAS)
get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB_RELEASE)
if(NOT _loc)
get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_RELEASE)
endif()
set(LAPACK_BLAS_LIBRARY_RELEASE ${_loc})
get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB_DEBUG)
if(NOT _loc)
get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_DEBUG)
endif()
set(LAPACK_BLAS_LIBRARY_DEBUG ${_loc})
select_library_configurations(LAPACK_BLAS)
list(APPEND LAPACK_LIBRARY_RELEASE ${LAPACK_BLAS_LIBRARY_RELEASE})
list(APPEND LAPACK_LIBRARY_DEBUG ${LAPACK_BLAS_LIBRARY_DEBUG})
select_library_configurations(LAPACK)
list(APPEND LAPACK_LIBRARY Threads::Threads)
endif()
if(NOT F2C_INCLUDE_DIR)
find_path(F2C_INCLUDE_DIR NAMES f2c.h)
endif()
if(NOT LAPACK_INCLUDE_DIR)
find_path(LAPACK_INCLUDE_DIR NAMES clapack.h)
endif()
list(APPEND LAPACK_INCLUDE_DIR ${F2C_INCLUDE_DIR})
set(LAPACK_INCLUDE_DIR "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE)
set(LAPACK_INCLUDE_DIRS "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE)
set(CLAPACK_INCLUDE_DIR "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE)
set(CLAPACK_INCLUDE_DIRS "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE)
set(F2C_INCLUDE_DIRS "${F2C_INCLUDE_DIR}" CACHE PATH "" FORCE)
set(LAPACK_DLL_DIR ${LAPACK_INCLUDE_DIR})
list(TRANSFORM LAPACK_DLL_DIR APPEND "/../bin")
message(STATUS "LAPACK_DLL_DIR: ${LAPACK_DLL_DIR}")
if(WIN32)
find_file(LAPACK_LIBRARY_RELEASE_DLL NAMES lapack.dll PATHS ${LAPACK_DLL_DIR})
find_file(LAPACK_LIBRARY_DEBUG_FOLDER NAMES lapackd.dll PATHS ${LAPACK_DLL_DIR})
find_file(F2C_LIBRARY_RELEASE_DLL NAMES f2c.dll libf2c.dll PATHS ${LAPACK_DLL_DIR})
find_file(F2C_LIBRARY_DEBUG_DLL NAMES f2cd.dll libf2cd.dll PATHS ${LAPACK_DLL_DIR})
endif()
set(LAPACK_BLAS_LIBRARY "${LAPACK_BLAS_LIBRARY}" CACHE STRING "" FORCE)
set(F2C_LIBRARIES "${F2C_LIBRARY}" CACHE STRING "" FORCE)
set(LAPACK_VERSION "${CLAPACK_VERSION}" CACHE STRING "" FORCE)
set(LAPACK_LIBRARIES "${LAPACK_LIBRARY}" CACHE STRING "" FORCE)
set(CLAPACK_LIBRARY "${LAPACK_LIBRARY}" CACHE STRING "" FORCE)
set(CLAPACK_LIBRARIES "${LAPACK_LIBRARY}" CACHE STRING "" FORCE)
set(LAPACK_LIBRARY "${LAPACK_LIBRARY}" CACHE STRING "" FORCE)
set(F2C_LIBRARY "${F2C_LIBRARY}" CACHE STRING "" FORCE)
set(LAPACK_LIBRARY_RELEASE "${LAPACK_LIBRARY_RELEASE}" CACHE STRING "" FORCE)
set(LAPACK_LIBRARY_DEBUG "${LAPACK_LIBRARY_DEBUG}" CACHE STRING "" FORCE)
set(F2C_LIBRARY_RELEASE "${F2C_LIBRARY_RELEASE}" CACHE STRING "" FORCE)
set(F2C_LIBRARY_DEBUG "${F2C_LIBRARY_DEBUG}" CACHE STRING "" FORCE)
find_package_handle_standard_args(CLAPACK DEFAULT_MSG CLAPACK_LIBRARY CLAPACK_INCLUDE_DIR)
mark_as_advanced(CLAPACK_INCLUDE_DIR CLAPACK_LIBRARY)
find_package_handle_standard_args(LAPACK DEFAULT_MSG LAPACK_LIBRARY LAPACK_INCLUDE_DIR)
mark_as_advanced(LAPACK_INCLUDE_DIR LAPACK_LIBRARY)
find_package_handle_standard_args(F2C DEFAULT_MSG F2C_LIBRARY F2C_INCLUDE_DIR)
mark_as_advanced(F2C_INCLUDE_DIR F2C_LIBRARY)
#TARGETS
if(CLAPACK_FOUND AND NOT TARGET clapack::clapack)
if(EXISTS "${LAPACK_LIBRARY_RELEASE_DLL}")
add_library(clapack::clapack SHARED IMPORTED)
set_target_properties(clapack::clapack PROPERTIES
IMPORTED_LOCATION_RELEASE "${LAPACK_LIBRARY_RELEASE_DLL}"
IMPORTED_IMPLIB_RELEASE "${oLAPACK_LIBRARY_RELEASE}"
INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:${oF2C_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${oF2C_LIBRARY_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${LAPACK_BLAS_LIBRARY_DEBUG}>;$<LINK_ONLY:${ADDITIONAL_LAPACK_LIBRARY}>;$<LINK_ONLY:${PTHREAD_LINK_NAME}>"
IMPORTED_CONFIGURATIONS Release
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
if(EXISTS "${LAPACK_LIBRARY_DEBUG_DLL}")
set_property(TARGET clapack::clapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug)
set_target_properties(clapack::clapack PROPERTIES
IMPORTED_LOCATION_DEBUG "${LAPACK_LIBRARY_DEBUG_DLL}"
IMPORTED_IMPLIB_DEBUG "${oLAPACK_LIBRARY_DEBUG}")
endif()
else()
add_library(clapack::clapack UNKNOWN IMPORTED)
set_target_properties(clapack::clapack PROPERTIES
IMPORTED_LOCATION_RELEASE "${oLAPACK_LIBRARY_RELEASE}"
INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:${oF2C_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${oF2C_LIBRARY_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${LAPACK_BLAS_LIBRARY_DEBUG}>;$<LINK_ONLY:${ADDITIONAL_LAPACK_LIBRARY}>;$<LINK_ONLY:${PTHREAD_LINK_NAME}>"
IMPORTED_CONFIGURATIONS Release
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
if(EXISTS "${LAPACK_LIBRARY_DEBUG}")
set_property(TARGET clapack::clapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug)
set_target_properties(clapack::clapack PROPERTIES
IMPORTED_LOCATION_DEBUG "${oLAPACK_LIBRARY_DEBUG}")
endif()
endif()
endif()
if(CLAPACK_FOUND AND NOT TARGET lapack)
if(EXISTS "${LAPACK_LIBRARY_RELEASE_DLL}")
add_library(lapack SHARED IMPORTED)
set_target_properties(lapack PROPERTIES
IMPORTED_LOCATION_RELEASE "${LAPACK_LIBRARY_RELEASE_DLL}"
IMPORTED_IMPLIB_RELEASE "${oLAPACK_LIBRARY_RELEASE}"
INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:${oF2C_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${oF2C_LIBRARY_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${LAPACK_BLAS_LIBRARY_DEBUG}>;$<LINK_ONLY:${ADDITIONAL_LAPACK_LIBRARY}>;$<LINK_ONLY:${PTHREAD_LINK_NAME}>"
IMPORTED_CONFIGURATIONS Release
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
if(EXISTS "${LAPACK_LIBRARY_DEBUG_DLL}")
set_property(TARGET lapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug)
set_target_properties(lapack PROPERTIES
IMPORTED_LOCATION_DEBUG "${LAPACK_LIBRARY_DEBUG_DLL}"
IMPORTED_IMPLIB_DEBUG "${oLAPACK_LIBRARY_DEBUG}")
endif()
else()
add_library(lapack UNKNOWN IMPORTED)
set_target_properties(lapack PROPERTIES
IMPORTED_LOCATION_RELEASE "${oLAPACK_LIBRARY_RELEASE}"
INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}"
IMPORTED_CONFIGURATIONS Release
INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:${oF2C_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${oF2C_LIBRARY_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$<CONFIG:DEBUG>:${LAPACK_BLAS_LIBRARY_DEBUG}>;$<LINK_ONLY:${ADDITIONAL_LAPACK_LIBRARY}>;$<LINK_ONLY:${PTHREAD_LINK_NAME}>"
IMPORTED_LINK_INTERFACE_LANGUAGES "C")
if(EXISTS "${LAPACK_LIBRARY_DEBUG}")
set_property(TARGET lapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug)
set_target_properties(lapack PROPERTIES
IMPORTED_LOCATION_DEBUG "${oLAPACK_LIBRARY_DEBUG}")
endif()
endif()
endif()