1- cmake_minimum_required (VERSION 3.13 )
1+ cmake_minimum_required (VERSION 3.13 )
22
33# Project Version
44project (SuperLU_MT C )
@@ -12,8 +12,8 @@ set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BugFix})
1212set (USE_XSDK_DEFAULTS TRUE )
1313
1414# The XSDK standard does not allow using internally built BLAS
15- if (NOT "${enable_internal_blaslib} " STREQUAL "" )
16- if (USE_XSDK_DEFAULTS)
15+ if (NOT "${enable_internal_blaslib} " STREQUAL "" )
16+ if (USE_XSDK_DEFAULTS)
1717 set (enable_blaslib_xSDK OFF )
1818 else ()
1919 set (enable_blaslib_xSDK ON )
2222 set (enable_blaslib_xSDK ${enable_internal_blaslib} )
2323endif ()
2424
25- if (NOT "${enable_fortran} " STREQUAL "" )
26- if (XSDK_ENABLE_Fortran)
25+ if (NOT "${enable_fortran} " STREQUAL "" )
26+ if (XSDK_ENABLE_Fortran)
2727 set (enable_fortran_xSDK ON )
2828 else ()
2929 set (enable_fortran_xSDK OFF )
@@ -32,42 +32,43 @@ else()
3232 set (enable_fortran_xSDK ${enable_fortran} )
3333endif ()
3434
35- set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
35+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
3636
3737# set up options
38- option (enable_internal_blaslib "Build the CBLAS library" ${enable_blaslib_xSDK} )
39- option (enable_single "Enable single precision library" ON )
40- option (enable_double "Enable double precision library" ON )
41- option (enable_complex "Enable complex precision library" ON )
38+ option (enable_internal_blaslib "Build the CBLAS library" ${enable_blaslib_xSDK} )
39+ option (enable_single "Enable single precision library" ON )
40+ option (enable_double "Enable double precision library" ON )
41+ option (enable_complex "Enable complex precision library" ON )
4242option (enable_complex16 "Enable complex16 precision library" ON )
4343option (enable_matlabmex "Build the Matlab mex library" OFF )
44- option (enable_doc "Add target 'doc' to build Doxygen documentation" OFF )
45- option (enable_examples "Build examples" ON )
46- option (enable_fortran "Build Fortran interface" ${enable_fortran_xSDK} )
47- option (enable_tests "Build tests" ON )
48- option (BUILD_SHARED_LIBS "shared/static" OFF )
49-
50- include (GNUInstallDirs )
51- include (CheckLibraryExists )
44+ option (enable_doc "Add target 'doc' to build Doxygen documentation" OFF )
45+ option (enable_examples "Build examples" ON )
46+ option (enable_fortran "Build Fortran interface" ${enable_fortran_xSDK} )
47+ option (enable_tests "Build tests" ON )
48+ option (BUILD_SHARED_LIBS "shared/static" OFF )
49+
50+ include (GNUInstallDirs )
51+ include (CheckLibraryExists )
5252check_library_exists (m sin "" HAVE_LIB_M )
5353
54- ######################################################################
54+ # #####################################################################
5555#
5656# Find packages
5757#
58- ######################################################################
58+ # #####################################################################
5959#
60- ###find_package (BLAS REQUIRED)
61- #-- BLAS
62- option (TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_internal_blaslib} )
60+ # ##find_package (BLAS REQUIRED)
61+ # -- BLAS
62+ option (TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_internal_blaslib} )
6363option (TPL_BLAS_LIBRARIES "List of absolute paths to blas libraries []." )
6464
6565if (NOT enable_internal_blaslib)
66- if (TPL_BLAS_LIBRARIES)
66+ if (TPL_BLAS_LIBRARIES)
6767 set (BLAS_FOUND TRUE )
6868 else ()
6969 find_package (BLAS )
70- if (BLAS_FOUND)
70+
71+ if (BLAS_FOUND)
7172 set (TPL_BLAS_LIBRARIES "${BLAS_LIBRARIES} " CACHE FILEPATH
7273 "Set from FindBLAS.cmake BLAS_LIBRARIES." FORCE )
7374 endif ()
@@ -78,49 +79,96 @@ if(BLAS_FOUND)
7879 message ("-- Using TPL_BLAS_LIBRARIES='${TPL_BLAS_LIBRARIES} '" )
7980 set (CMAKE_C_FLAGS "-DUSE_VENDOR_BLAS ${CMAKE_C_FLAGS} " )
8081 set (BLAS_LIB ${TPL_BLAS_LIBRARIES} )
82+
8183 # fix up BLAS library name
82- string (REPLACE ";" " " BLAS_LIB_STR "${BLAS_LIB} " )
84+ string (REPLACE ";" " " BLAS_LIB_STR "${BLAS_LIB} " )
8385 set (BLAS_LIB_EXPORT ${BLAS_LIB_STR} )
8486else ()
8587 message ("-- Did not find or specify BLAS so configure to build internal CBLAS ..." )
8688 add_subdirectory (CBLAS )
8789 set (BLAS_LIB blas)
88- if (BUILD_SHARED_LIBS ) # export to be referenced by downstream makefile
89- set (BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX} /CBLAS/libblas.so)
90+
91+ if (BUILD_SHARED_LIBS ) # export to be referenced by downstream makefile
92+ set (BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX} /CBLAS/libblas.so)
9093 else ()
91- set (BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX} /CBLAS/libblas.a)
94+ set (BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX} /CBLAS/libblas.a)
95+ endif ()
96+ endif ()
97+
98+ # -- METIS
99+ option (TPL_ENABLE_METISLIB "Build the METIS library" OFF )
100+ option (TPL_METIS_LIBRARIES "List of absolute paths to METIS link libraries []." )
101+ option (TPL_METIS_INCLUDE_DIRS "List of absolute paths to METIS include directories []." )
102+
103+ # --------------------- METIS ---------------------
104+ if (TPL_ENABLE_METISLIB) # # want to use metis
105+ if (NOT TPL_METIS_LIBRARIES)
106+ message (FATAL_ERROR "TPL_METIS_LIBRARIES option should be set for METIS support to be enabled." )
107+ endif ()
108+
109+ if (NOT TPL_METIS_INCLUDE_DIRS)
110+ message (FATAL_ERROR "TPL_METIS_INCLUDE_DIRS option be set for METIS support to be enabled." )
111+ endif ()
112+
113+ foreach (dir ${TPL_METIS_INCLUDE_DIRS} )
114+ if (NOT MINGW AND NOT EXISTS ${dir} )
115+ message (FATAL_ERROR "METIS include directory not found: ${dir} " )
116+ endif ()
117+
118+ set (CMAKE_C_FLAGS "-I${dir} ${CMAKE_C_FLAGS} " )
119+ endforeach ()
120+
121+ message ("-- Enabled support for METIS." )
122+ set (METIS_FOUND TRUE )
123+
124+ set (METIS_LIB ${TPL_METIS_LIBRARIES} )
125+
126+ # fix up METIS library names
127+ string (REPLACE ";" " " METIS_LIB_STR "${METIS_LIB} " )
128+ set (METIS_LIB_EXPORT ${METIS_LIB_STR} )
129+ else ()
130+ message ("-- Will not link with METIS." )
131+ endif ()
132+
133+ if (METIS_FOUND)
134+ set (HAVE_METIS TRUE )
135+
136+ if (TPL_METIS_INCLUDE_DIRS)
137+ include_directories (${TPL_METIS_INCLUDE_DIRS} )
92138 endif ()
93139endif ()
94140
141+ set (PLAT "_OPENMP" CACHE STRING "threading flavor _PTHREAD/_OPENMP" )
95142
96- set (PLAT "_OPENMP" CACHE STRING "threading flavor _PTHREAD/_OPENMP" )
97- if (PLAT STREQUAL "_PTHREAD" )
98- find_package (Threads REQUIRED )
99- elseif (PLAT STREQUAL "_OPENMP" )
100- find_package (OpenMP REQUIRED )
101- else ()
102- message (SEND_ERROR "invalid PLAT setting" )
103- endif ()
143+ if (PLAT STREQUAL "_PTHREAD" )
144+ find_package (Threads REQUIRED )
145+ elseif (PLAT STREQUAL "_OPENMP" )
146+ find_package (OpenMP REQUIRED )
147+ else ()
148+ message (SEND_ERROR "invalid PLAT setting" )
149+ endif ()
104150
105- option (LONGINT "use 64-bit integers for indexing sparse matrices (default is 32-bit)" OFF )
151+ option (LONGINT "use 64-bit integers for indexing sparse matrices (default is 32-bit)" OFF )
106152
107153enable_language (C )
108- if (enable_fortran)
154+
155+ if (enable_fortran)
109156 enable_language (Fortran )
110157endif ()
111- set (SUPERLU_MT_VERSION "${PROJECT_VERSION} " )
112158
159+ set (SUPERLU_MT_VERSION "${PROJECT_VERSION} " )
113160
114- set (SUPERLUMT_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} /superlu_mt CACHE STRING "include dir" )
161+ set (SUPERLUMT_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} /superlu_mt CACHE STRING "include dir" )
115162
116163add_subdirectory (SRC )
164+
117165# add_subdirectory(EXAMPLE)
118166
119167# if(enable_tests)
120- # enable_testing()
121- # add_subdirectory(TESTING)
168+ # enable_testing()
169+ # add_subdirectory(TESTING)
122170# endif()
123171
124172# if (enable_doc)
125- # add_subdirectory(DOC)
173+ # add_subdirectory(DOC)
126174# endif()
0 commit comments