vcpkg/ports/suitesparse/suitesparse.patch
Sean Yen 7c9bf0a6cd
[suitesparse] Fixing SuiteSparse_INCLUDE_DIRS is not usable from the port. (#11945)
* correct _SuiteSparse_PREFIX.

* Update portfile.cmake
2020-06-30 14:43:32 -07:00

152 lines
6.5 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3486f05..b8c2e63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -191,68 +191,14 @@ if(WITH_CUDA)
ENDIF(${CUDA_FOUND})
endif()
-find_package(BLAS)
-find_package(LAPACK)
-if (LAPACK_FOUND AND BLAS_FOUND)
+find_package(BLAS REQUIRED)
+find_package(LAPACK REQUIRED)
+if(LAPACK_FOUND AND BLAS_FOUND)
message(STATUS "found lapack and blas config file. Linking targets lapack and blas")
set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
-else () # LAPACK is not found
-
-## Need to use SuiteSparse_LINKER_LAPACK_BLAS_LIBS in our subproject in case of SHARED flag is set to ON
-SET(SUITESPARSE_USE_CUSTOM_BLAS_LAPACK_LIBS OFF CACHE BOOL "Check if you have custom LAPACK/BLAS libraries (AMD,...)")
-IF (SUITESPARSE_USE_CUSTOM_BLAS_LAPACK_LIBS)
- SET(SUITESPARSE_CUSTOM_BLAS_LIB "" CACHE FILE "Path to custom library file for BLAS")
- SET(SUITESPARSE_CUSTOM_LAPACK_LIB "" CACHE FILE "Path to custom library file for LAPACK")
- IF (NOT EXISTS "${SUITESPARSE_CUSTOM_BLAS_LIB}" OR NOT EXISTS "${SUITESPARSE_CUSTOM_LAPACK_LIB}")
- MESSAGE("*Error*: Correctly set SUITESPARSE_CUSTOM_BLAS_LIB and SUITESPARSE_CUSTOM_LAPACK_LIB or uncheck SUITESPARSE_USE_CUSTOM_BLAS_LAPACK_LIBS")
- ELSE()
- SET(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${SUITESPARSE_CUSTOM_BLAS_LIB} ${SUITESPARSE_CUSTOM_LAPACK_LIB})
- ENDIF()
-ELSE()
- IF (UNIX)
- SET(SuiteSparse_LINKER_LAPACK_BLAS_LIBS lapack blas rt)
- ELSE()
- IF(CMAKE_SIZEOF_VOID_P EQUAL 8) # Size in bytes!
- set(PATH_WORD_SIZE "x64")
- ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) # Size in bytes!
- set(PATH_WORD_SIZE "x32")
- ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
-
- add_library(blas SHARED IMPORTED)
- set_property(TARGET blas PROPERTY IMPORTED_LOCATION ${SuiteSparseProject_SOURCE_DIR}/lapack_windows/${PATH_WORD_SIZE}/libblas.dll)
- set_property(TARGET blas PROPERTY IMPORTED_IMPLIB ${SuiteSparseProject_SOURCE_DIR}/lapack_windows/${PATH_WORD_SIZE}/libblas.lib)
-
- add_library(lapack SHARED IMPORTED)
- set_property(TARGET lapack PROPERTY IMPORTED_LOCATION ${SuiteSparseProject_SOURCE_DIR}/lapack_windows/${PATH_WORD_SIZE}/liblapack.dll)
- set_property(TARGET lapack PROPERTY IMPORTED_IMPLIB ${SuiteSparseProject_SOURCE_DIR}/lapack_windows/${PATH_WORD_SIZE}/liblapack.lib)
-
- SET(SuiteSparse_LINKER_LAPACK_BLAS_LIBS blas lapack)
-
- ## install lapack and blas dependencies
- file(GLOB lapack_blas_windows_libs "${CMAKE_SOURCE_DIR}/lapack_windows/${PATH_WORD_SIZE}/*.lib")
- file(GLOB lapack_blas_windows_dll "${CMAKE_SOURCE_DIR}/lapack_windows/${PATH_WORD_SIZE}/*.dll")
- if(lapack_blas_windows_dll AND lapack_blas_windows_libs)
- set(SuiteSparse_LAPACK_BLAS_LIB_DIR "lib${LIB_POSTFIX}/lapack_blas_windows")
- install(FILES ${lapack_blas_windows_libs}
- ${lapack_blas_windows_dll}
- DESTINATION ${SuiteSparse_LAPACK_BLAS_LIB_DIR}
- )
- endif()
- ENDIF()
-ENDIF()
-ENDIF() # LAPACK found
-
-if(SuiteSparse_LAPACK_BLAS_LIB_DIR) # "Export" the imported targets in config.cmake manually
- set(ExternConfig "add_library(blas SHARED IMPORTED)
- set_property(TARGET blas PROPERTY IMPORTED_LOCATION \${_SuiteSparse_PREFIX}/${SuiteSparse_LAPACK_BLAS_LIB_DIR}/libblas.dll)
- set_property(TARGET blas PROPERTY IMPORTED_IMPLIB \${_SuiteSparse_PREFIX}/${SuiteSparse_LAPACK_BLAS_LIB_DIR}/libblas.lib)
-
- add_library(lapack SHARED IMPORTED)
- set_property(TARGET lapack PROPERTY IMPORTED_LOCATION \${_SuiteSparse_PREFIX}/${SuiteSparse_LAPACK_BLAS_LIB_DIR}/liblapack.dll)
- set_property(TARGET lapack PROPERTY IMPORTED_IMPLIB \${_SuiteSparse_PREFIX}/${SuiteSparse_LAPACK_BLAS_LIB_DIR}/liblapack.lib)")
-endif()
+endif() # LAPACK is not found
-IF(BUILD_METIS)
+IF(BUILD_METIS OR USE_VCPKG_METIS)
set(SuiteSparse_LINKER_METIS_LIBS "metis")
## namespaced library target for config
set(SuiteSparse_EXPORTED_METIS_LIBS "SuiteSparse::metis")
@@ -311,7 +257,7 @@ configure_file(cmake/SuiteSparse-config-install.cmake.in
## do the EXPORT for allowing other project to easily use suitesparse with cmake
install(EXPORT SuiteSparseTargets
FILE
- SuiteSparse-targets.cmake
+ suitesparse-targets.cmake
NAMESPACE
SuiteSparse::
DESTINATION
diff --git a/SuiteSparse/CHOLMOD/Include/cholmod_blas.h b/SuiteSparse/CHOLMOD/Include/cholmod_blas.h
index aef3e63..907512b 100644
--- a/SuiteSparse/CHOLMOD/Include/cholmod_blas.h
+++ b/SuiteSparse/CHOLMOD/Include/cholmod_blas.h
@@ -27,6 +27,7 @@
#elif defined (__linux) || defined (MGLNX86) || defined (ARCH_GLNX86)
#define CHOLMOD_LINUX
#define CHOLMOD_ARCHITECTURE "Linux"
+#define BLAS_NO_UNDERSCORE
#elif defined (__APPLE__)
#define CHOLMOD_MAC
diff --git a/SuiteSparse/CMakeLists.txt b/SuiteSparse/CMakeLists.txt
index c6e2834..5ef08a6 100644
--- a/SuiteSparse/CMakeLists.txt
+++ b/SuiteSparse/CMakeLists.txt
@@ -12,11 +12,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
# Global flags:
-IF (BUILD_METIS)
+IF (BUILD_METIS OR USE_VCPKG_METIS)
INCLUDE_DIRECTORIES("${METIS_SOURCE_DIR}/include")
-ELSE (BUILD_METIS)
+ELSE ()
ADD_DEFINITIONS(-DNPARTITION)
-ENDIF ( BUILD_METIS)
+ENDIF ()
# Disable COMPLEX numbers: disable it by default, since it causes problems in some platforms.
SET(HAVE_COMPLEX OFF CACHE BOOL "Enables building SuiteSparse with complex numbers (disabled by default to avoid problems in some platforms)")
diff --git a/cmake/SuiteSparse-config-install.cmake.in b/cmake/SuiteSparse-config-install.cmake.in
index cb1f51f..12f654c 100644
--- a/cmake/SuiteSparse-config-install.cmake.in
+++ b/cmake/SuiteSparse-config-install.cmake.in
@@ -2,15 +2,11 @@
get_filename_component(_SuiteSparse_SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_SuiteSparse_PREFIX "${_SuiteSparse_SELF_DIR}" PATH)
get_filename_component(_SuiteSparse_PREFIX "${_SuiteSparse_PREFIX}" PATH)
-get_filename_component(_SuiteSparse_PREFIX "${_SuiteSparse_PREFIX}" PATH)
-find_package(LAPACK CONFIG)
-if (NOT LAPACK_FOUND) # Load the LAPACK package with which we were built.
- @ExternConfig@
-endif ()
+find_package(LAPACK REQUIRED)
# Load targets from the install tree.
-include(${_SuiteSparse_SELF_DIR}/SuiteSparse-targets.cmake)
+include(${_SuiteSparse_SELF_DIR}/suitesparse-targets.cmake)
# Report SuiteSparse header search locations.
set(SuiteSparse_INCLUDE_DIRS ${_SuiteSparse_PREFIX}/include)
@@ -31,6 +27,10 @@ set(SuiteSparse_LIBRARIES
SuiteSparse::spqr
@SuiteSparse_EXPORTED_METIS_LIBS@
)
+set(SUITESPARSE_LIBRARIES ${SuiteSparse_LIBRARIES})
unset(_SuiteSparse_PREFIX)
unset(_SuiteSparse_SELF_DIR)
+
+set(SUITESPARSE_FOUND TRUE)
+set(SuiteSparse_FOUND TRUE)