aboutsummaryrefslogtreecommitdiff
path: root/ports/suitesparse/build_fixes.patch
blob: 2734bb02cef03ff39e7b329f280ddf328228238c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9602cce..dafb434 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,14 +5,6 @@
 # Updated by jesnault (jerome.esnault@inria.fr) 2014-01-21
 # -----------------------------------------------------------------
 
-option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
-include(cmake/HunterGate.cmake)
-
-HunterGate(
-  URL "https://github.com/ruslo/hunter/archive/v0.23.214.tar.gz"
-  SHA1 "e14bc153a7f16d6a5eeec845fb0283c8fad8c358"
-)
-
 PROJECT(SuiteSparseProject)
 
 cmake_minimum_required(VERSION 3.1)
@@ -47,29 +39,9 @@ else()
     message(STATUS "Using user defined CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
 endif()
 
-# Fix GKlib path:
-IF(NOT WIN32)
-  SET(GKLIB_PATH "${${PROJECT_NAME}_SOURCE_DIR}/SuiteSparse/metis-5.1.0/GKlib" CACHE INTERNAL "Path to GKlib (for METIS)" FORCE)
-ENDIF()
-
-# allow creating DLLs in Windows without touching the source code:
-IF(NOT ${CMAKE_VERSION} VERSION_LESS "3.4.0" AND WIN32)
-	set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
-ENDIF()
-
 ## get CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_LIBDIR
 include(GNUInstallDirs)
 
-if(CMAKE_SIZEOF_VOID_P MATCHES "8")
-  set(SUITESPARSE_LIB_POSTFIX "64")
-else()
-  set(SUITESPARSE_LIB_POSTFIX "")
-endif()
-
-## get POSTFIX for lib install dir
-set(LIB_POSTFIX "${SUITESPARSE_LIB_POSTFIX}" CACHE STRING "suffix for 32/64 inst dir placement")
-mark_as_advanced(LIB_POSTFIX)
-
 # We want libraries to be named "libXXX" and "libXXXd" in all compilers:
 # ------------------------------------------------------------------------
 set(CMAKE_DEBUG_POSTFIX  "d")
@@ -77,59 +49,6 @@ IF(MSVC)
 	set(SP_LIB_PREFIX "lib")  # Libs are: "libXXX"
 ENDIF(MSVC)
 
-## check if we can build metis
-SET(BUILD_METIS_DEFAULT ON)
-if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/SuiteSparse/metis-5.1.0/CMakeLists.txt")
-	SET(BUILD_METIS_DEFAULT OFF)
-endif()
-
-SET(WITH_CUDA OFF CACHE BOOL "Build with CUDA support")
-
-SET(BUILD_METIS ${BUILD_METIS_DEFAULT} CACHE BOOL "Build METIS for partitioning?")
-SET(METIS_DIR ${${PROJECT_NAME}_SOURCE_DIR}/SuiteSparse/metis-5.1.0 CACHE PATH "Source directory of METIS")
-
-if(BUILD_METIS)
-	## prepare the installation :
-	## using metis target here is not possible because this target is added in another branch of the CMake structure
-	## TRICK: need to dynamically modify the metis CMakeLists.txt file before it going to parsed...
-	## (very ugly/poor for a metis project get from SCM (git/svn/cvs) but it's works ;) and it doesn't matter if metis was get from .zip)
-	if(EXISTS "${METIS_DIR}/libmetis/CMakeLists.txt")
-		file(READ "${METIS_DIR}/libmetis/CMakeLists.txt" contentFile)
-		string(REGEX MATCH "EXPORT 	SuiteSparseTargets" alreadyModified ${contentFile}) ## use a string pattern to check if we have to do the modif
-		if(NOT alreadyModified)
-			file(APPEND "${METIS_DIR}/libmetis/CMakeLists.txt"
-			"
-				set_target_properties(metis PROPERTIES PUBLIC_HEADER \"../include/metis.h\")
-				install(TARGETS metis ## this line is also the string pattern to check if the modification had already done
-						EXPORT 	SuiteSparseTargets
-						RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-						LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-						ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-						PUBLIC_HEADER DESTINATION include
-				)
-			"
-			)
-		endif()
-	endif()
-    add_subdirectory(SuiteSparse/metis-5.1.0) ## important part for building metis from its src files
-endif(BUILD_METIS)
-
-
-## For EXPORT only :
-## Previous version of cmake (>2.8.12) doesn't auto take into account external lib (here I mean blas and lapack) we need to link to for our current target we want to export.
-## Or at least we need to investigate how to do with previous version.
-## This may cause some trouble in case you want to build in static mode and then use it into another custom project.
-## You will need to manually link your target into your custom project to the correct dependencies link interfaces.
-if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" GREATER 2.8.11) ## (policies introduced both in 2.8.12)
-	set(EXPORT_USE_INTERFACE_LINK_LIBRARIES ON CACHE BOOL "")
-	mark_as_advanced(EXPORT_USE_INTERFACE_LINK_LIBRARIES)
-	if(EXPORT_USE_INTERFACE_LINK_LIBRARIES)
-		cmake_policy(SET CMP0023 NEW) ## just for respecting the new target_link_libraries(...) signature procedure
-		cmake_policy(SET CMP0022 NEW) ## use INTERFACE_LINK_LIBRARIES property for in-build targets and ignore old properties (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?
-		## Here, next version of cmake 2.8.12 auto take into account the link interface dependencies (see generated cmake/SuiteSparse-config*.cmake into your install dir)
-	endif()
-endif()
-
 ## install_suitesparse_project(targetName headersList)
 ## factorise the way we will install all projects (part of the suitesparse project)
 ## <targetName> is the target of the current project you build
@@ -176,16 +95,16 @@ macro(declare_suitesparse_library targetName srcsList headersList)
 		set(dsl_TARGET_PUBLIC_LINK "")
 	endif()
 	if(WITH_CUDA)
-		find_package(CUDA)
+		find_package(CUDA REQUIRED)
 	endif()
-	IF(${CUDA_FOUND})
+	IF(CUDA_FOUND)
 		INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})
 		INCLUDE_DIRECTORIES(${SuiteSparse_GPUQREngine_INCLUDE})
 		INCLUDE_DIRECTORIES(${SuiteSparse_GPURuntime_INCLUDE})
 		CUDA_ADD_LIBRARY(${targetName} ${srcsList} ${headersList})
-	ELSE(${CUDA_FOUND})
+	ELSE()
 		ADD_LIBRARY(${targetName} ${srcsList} ${headersList})
-	ENDIF(${CUDA_FOUND})
+	ENDIF()
 	SET_TARGET_PROPERTIES(${targetName} PROPERTIES
 		OUTPUT_NAME ${SP_LIB_PREFIX}${targetName}
 	)
@@ -211,44 +130,30 @@ MACRO(REMOVE_MATCHING_FILES_FROM_LIST match_expr lst_files)
 ENDMACRO(REMOVE_MATCHING_FILES_FROM_LIST)
 
 if(WITH_CUDA)
-	FIND_PACKAGE(cuda)
-	IF(${CUDA_FOUND})
+	FIND_PACKAGE(CUDA REQUIRED)
+	IF(CUDA_FOUND)
 		ADD_DEFINITIONS(-DGPU_BLAS)
-	ENDIF(${CUDA_FOUND})
+	ENDIF()
 endif()
 
-hunter_add_package(LAPACK) # only in effect if HUNTER_ENABLED is set
-# prefer LAPACK config file
-find_package(LAPACK CONFIG)
-if (LAPACK_FOUND AND TARGET blas AND TARGET lapack)
-  message(STATUS "found lapack and blas config file. Linking targets lapack and blas")
-  message(STATUS "- LAPACK_CONFIG: ${LAPACK_CONFIG}")
-  set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS lapack blas)
-  # for suitesparse-config file set method used to find LAPACK (and BLAS)
-  set(SuiteSparse_LAPACK_used_CONFIG YES)
-else()
-  # missing config file or targets, try BLAS and LAPACK
-  find_package(BLAS)
-  find_package(LAPACK)
-  if (BLAS_FOUND AND LAPACK_FOUND)
+  find_package(BLAS REQUIRED)
+  find_package(LAPACK REQUIRED)
     message(STATUS "found lapack and blas config file. Linking targets lapack and blas")
     message(STATUS "- LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}")
     message(STATUS "- BLAS_LIBRARIES:   ${BLAS_LIBRARIES}")
     set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
     # for suitesparse-config file set method used to find LAPACK (and BLAS)
     set(SuiteSparse_LAPACK_used_CONFIG NO)
-  else () # LAPACK is not found
-    message(FATAL_ERROR "lapack not found")
-  endif()
-endif()
 
-IF(BUILD_METIS)
+IF(USE_VCPKG_METIS)
+	find_package(metis REQUIRED)
 	set(SuiteSparse_LINKER_METIS_LIBS "metis")
-	## namespaced library target for config
-	set(SuiteSparse_EXPORTED_METIS_LIBS "SuiteSparse::metis")
+	set(SuiteSparse_EXPORTED_METIS_LIBS "metis")
+	set(SuiteSparse_FIND_DEPENDENCY_METIS "find_dependency(metis REQUIRED)")
 else()
 	set(SuiteSparse_LINKER_METIS_LIBS "")
 	set(SuiteSparse_EXPORTED_METIS_LIBS "")
+	set(SuiteSparse_FIND_PACKAGE_METIS "")
 ENDIF()
 
 add_subdirectory(SuiteSparse)
@@ -287,7 +192,7 @@ endmacro()
 # get SuiteSparse version
 get_SuiteSparse_Version()
 
-set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/suitesparse-${SuiteSparse_VERSION})
+set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/suitesparse)
 ## create targets file
 export(EXPORT SuiteSparseTargets
 	FILE "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-targets.cmake"
@@ -301,7 +206,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/CMakeLists.txt b/SuiteSparse/CMakeLists.txt
index c6e2834..6fdfb01 100644
--- a/SuiteSparse/CMakeLists.txt
+++ b/SuiteSparse/CMakeLists.txt
@@ -1,23 +1,5 @@
 PROJECT(SuiteSparse)
 
-# Set optimized building:
-IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
-	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
-	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
-	# only optimize for native processer when NOT cross compiling
-	if(NOT CMAKE_CROSSCOMPILING)
-		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=native")
-		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=native")
-	endif(NOT CMAKE_CROSSCOMPILING)
-ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
-
-# Global flags:
-IF (BUILD_METIS)
-	INCLUDE_DIRECTORIES("${METIS_SOURCE_DIR}/include")
-ELSE (BUILD_METIS)
-	ADD_DEFINITIONS(-DNPARTITION)
-ENDIF ( BUILD_METIS)
-
 # 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)")
 IF (NOT HAVE_COMPLEX)
@@ -38,12 +20,12 @@ if(WITH_CUDA)
 	set(SUBPROJECTS_TO_ADD
 		${SUBPROJECTS_TO_ADD}
 		SuiteSparse_GPURuntime
-		GPUQREngine	
+		GPUQREngine
 		)
 endif()
 
 set(SUBPROJECTS_TO_ADD
-    ${SUBPROJECTS_TO_ADD} 
+    ${SUBPROJECTS_TO_ADD}
 	SuiteSparse_config
 	AMD
 	BTF
diff --git a/cmake/SuiteSparse-config-install.cmake.in b/cmake/SuiteSparse-config-install.cmake.in
index 1e587d1..fd8f3a7 100644
--- a/cmake/SuiteSparse-config-install.cmake.in
+++ b/cmake/SuiteSparse-config-install.cmake.in
@@ -2,20 +2,14 @@
 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)
 
 include(CMakeFindDependencyMacro)
-if (@SuiteSparse_LAPACK_used_CONFIG@) # SuiteSparse_LAPACK_used_CONFIG
-  # use config file which provides LAPACK (and BLAS) for us
-  find_dependency(LAPACK CONFIG)
-else()
-  # try to find BLAS and LAPACK with modules
   find_dependency(BLAS)
   find_dependency(LAPACK)
-endif ()
+  @SuiteSparse_FIND_DEPENDENCY_METIS@
 
 # 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)
@@ -39,3 +33,7 @@ set(SuiteSparse_LIBRARIES
 
 unset(_SuiteSparse_PREFIX)
 unset(_SuiteSparse_SELF_DIR)
+set(SUITESPARSE_FOUND TRUE)
+set(SuiteSparse_FOUND TRUE)
+set(SUITESPARSE_LIBRARIES ${SuiteSparse_LIBRARIES})
+set(SUITESPARSE_INCLUDE_DIRS ${SuiteSparse_INCLUDE_DIRS})