1 cmake_minimum_required(VERSION 2.8.7)
2 set(CMAKE_GNUtoMS ON CACHE INTERNAL "")
3 project(LAPACK Fortran)
5 # Configure the warning and code coverage suppression file
7 "${LAPACK_SOURCE_DIR}/CTestCustom.cmake.in"
8 "${LAPACK_BINARY_DIR}/CTestCustom.cmake"
12 # Add the CMake directory for custon CMake modules
13 set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
16 if ( "${CMAKE_Fortran_COMPILER}" MATCHES "ifort" )
17 set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
19 if ( "${CMAKE_Fortran_COMPILER}" MATCHES "xlf" )
20 set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave -qstrict=none" )
22 # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
23 # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
24 STRING(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
28 find_package(PythonInterp)
29 message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
30 if (PYTHONINTERP_FOUND)
31 message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
33 # --------------------------------------------------
35 macro(lapack_install_library lib)
36 install(TARGETS ${lib} EXPORT lapack-targets
37 ARCHIVE DESTINATION lib${LIB_SUFFIX}
38 LIBRARY DESTINATION lib${LIB_SUFFIX}
39 RUNTIME DESTINATION bin
43 # --------------------------------------------------
49 # --------------------------------------------------
51 # Organize output files. On Windows this also keeps .dll files next
52 # to the .exe files that need them, making tests easy to run.
53 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/bin)
54 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib)
55 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib)
57 # --------------------------------------------------
58 # Check for any necessary platform specific compiler flags
59 include( CheckLAPACKCompilerFlags )
60 CheckLAPACKCompilerFlags()
62 # --------------------------------------------------
63 # Check second function
65 include(CheckTimeFunction)
66 set(TIME_FUNC NONE ${TIME_FUNC})
67 CHECK_TIME_FUNCTION(NONE TIME_FUNC)
68 CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
69 CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
70 CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
71 CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
72 message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.")
74 set(SECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
75 set(DSECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
76 set(prefix ${CMAKE_INSTALL_PREFIX})
77 set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
78 set(PKG_CONFIG_DIR ${libdir}/pkgconfig)
80 # --------------------------------------------------
82 # By default all precisions are generated
85 # --------------------------------------------------
86 # Subdirectories that need to be processed
88 option(USE_OPTIMIZED_BLAS "Whether or not to use an optimized BLAS library instead of included netlib BLAS" OFF)
91 # Check the usage of the user provided BLAS libraries
93 include(CheckFortranFunctionExists)
94 set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
95 CHECK_FORTRAN_FUNCTION_EXISTS("dgemm" BLAS_FOUND)
96 unset( CMAKE_REQUIRED_LIBRARIES )
98 message(STATUS "--> BLAS supplied by user is WORKING, will use ${BLAS_LIBRARIES}.")
100 message(ERROR "--> BLAS supplied by user is not WORKING, CANNOT USE ${BLAS_LIBRARIES}.")
101 message(ERROR "--> Will use REFERENCE BLAS (by default)")
102 message(ERROR "--> Or Correct your BLAS_LIBRARIES entry ")
103 message(ERROR "--> Or Consider checking USE_OPTIMIZED_BLAS")
106 # User did not provide a BLAS Library but specified to search for one
107 elseif( USE_OPTIMIZED_BLAS )
109 endif (BLAS_LIBRARIES)
111 # Neither user specified or optimized BLAS libraries can be used
113 message(STATUS "Using supplied NETLIB BLAS implementation")
114 add_subdirectory(BLAS)
115 set( BLAS_LIBRARIES blas )
117 set( CMAKE_EXE_LINKER_FLAGS
118 "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
119 CACHE STRING "Linker flags for executables" FORCE)
120 set( CMAKE_MODULE_LINKER_FLAGS
121 "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
122 CACHE STRING "Linker flags for modules" FORCE)
123 set( CMAKE_SHARED_LINKER_FLAGS
124 "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
125 CACHE STRING "Linker flags for shared libs" FORCE)
126 endif( NOT BLAS_FOUND )
128 option(USE_XBLAS "Build extended precision (needs XBLAS)" OFF)
130 find_library(XBLAS_LIBRARY NAMES xblas)
133 option(USE_OPTIMIZED_LAPACK "Whether or not to use an optimized LAPACK library instead of included netlib LAPACK" OFF)
135 # User did not provide a LAPACK Library but specified to search for one
136 if( USE_OPTIMIZED_LAPACK )
137 find_package( LAPACK )
138 endif (USE_OPTIMIZED_LAPACK)
140 # Check the usage of the user provided or automatically found LAPACK libraries
142 include(CheckFortranFunctionExists)
143 set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
144 # Check if new routine of 3.4.0 is in LAPACK_LIBRARIES
145 CHECK_FORTRAN_FUNCTION_EXISTS("dgeqrt" LATESTLAPACK_FOUND)
146 unset( CMAKE_REQUIRED_LIBRARIES )
147 if(LATESTLAPACK_FOUND)
148 message(STATUS "--> LAPACK supplied by user is WORKING, will use ${LAPACK_LIBRARIES}.")
150 message(ERROR "--> LAPACK supplied by user is not WORKING or is older than LAPACK 3.4.0, CANNOT USE ${LAPACK_LIBRARIES}.")
151 message(ERROR "--> Will use REFERENCE LAPACK (by default)")
152 message(ERROR "--> Or Correct your LAPACK_LIBRARIES entry ")
153 message(ERROR "--> Or Consider checking USE_OPTIMIZED_LAPACK")
154 endif(LATESTLAPACK_FOUND)
155 endif (LAPACK_LIBRARIES)
157 # Neither user specified or optimized LAPACK libraries can be used
158 if(NOT LATESTLAPACK_FOUND)
159 message(STATUS "Using supplied NETLIB LAPACK implementation")
160 set( LAPACK_LIBRARIES lapack )
161 option(BUILD_SINGLE "Build LAPACK Single Precision" ON)
162 option(BUILD_DOUBLE "Build LAPACK Double Precision" ON)
163 option(BUILD_COMPLEX "Build LAPACK Complex Precision" ON)
164 option(BUILD_COMPLEX16 "Build LAPACK Double Complex Precision" ON)
165 add_subdirectory(SRC)
167 set( CMAKE_EXE_LINKER_FLAGS
168 "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}"
169 CACHE STRING "Linker flags for executables" FORCE)
170 set( CMAKE_MODULE_LINKER_FLAGS
171 "${CMAKE_MODULE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}"
172 CACHE STRING "Linker flags for modules" FORCE)
173 set( CMAKE_SHARED_LINKER_FLAGS
174 "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}"
175 CACHE STRING "Linker flags for shared libs" FORCE)
176 endif( NOT LATESTLAPACK_FOUND )
178 message(STATUS "BUILD TESTING : ${BUILD_TESTING}" )
180 add_subdirectory(TESTING)
183 # --------------------------------------------------
185 option(LAPACKE "Build LAPACKE" OFF)
187 # LAPACKE has also the interface to some routines from tmglib,
188 # if LAPACKE_WITH_TMG is selected, we need to add those routines to LAPACKE
189 option(LAPACKE_WITH_TMG "Build LAPACKE with tmglib routines" OFF)
190 if (LAPACKE_WITH_TMG)
192 if(NOT BUILD_TESTING)
193 add_subdirectory(TESTING/MATGEN)
194 endif(NOT BUILD_TESTING)
195 endif(LAPACKE_WITH_TMG)
198 add_subdirectory(lapacke)
201 # --------------------------------------------------
204 SET(CPACK_PACKAGE_NAME "LAPACK")
205 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
206 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
207 set(LAPACK_VERSION 3.4.2)
208 set(CPACK_PACKAGE_VERSION_MAJOR 3)
209 set(CPACK_PACKAGE_VERSION_MINOR 4)
210 set(CPACK_PACKAGE_VERSION_PATCH 2)
211 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
212 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
213 IF(WIN32 AND NOT UNIX)
214 # There is a bug in NSI that does not handle full unix paths properly. Make
215 # sure there is at least one set of four (4) backlasshes.
216 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
217 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
218 SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
219 SET(CPACK_NSIS_MODIFY_PATH ON)
220 SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
221 set(CPACK_PACKAGE_RELOCATABLE "true")
222 ELSE(WIN32 AND NOT UNIX)
223 SET(CPACK_GENERATOR "TGZ")
224 SET(CPACK_SOURCE_GENERATOR TGZ)
225 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
226 SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
227 ENDIF(WIN32 AND NOT UNIX)
231 # --------------------------------------------------
232 # By default static library
233 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
234 OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
235 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
238 set(ALL_TARGETS ${ALL_TARGETS} blas)
239 endif(NOT BLAS_FOUND)
241 if(NOT LATESTLAPACK_FOUND)
242 set(ALL_TARGETS ${ALL_TARGETS} lapack)
243 endif(NOT LATESTLAPACK_FOUND)
245 if(BUILD_TESTING OR LAPACKE_WITH_TMG)
246 set(ALL_TARGETS ${ALL_TARGETS} tmglib)
247 endif(BUILD_TESTING OR LAPACKE_WITH_TMG)
250 set(ALL_TARGETS ${ALL_TARGETS} lapacke)
253 export(TARGETS ${ALL_TARGETS} FILE lapack-targets.cmake)
255 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-version.cmake.in
256 ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
257 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-build.cmake.in
258 ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
261 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc)
263 ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
264 DESTINATION ${PKG_CONFIG_DIR}
267 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-install.cmake.in
268 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
270 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
271 ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
272 DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
275 install(EXPORT lapack-targets
276 DESTINATION lib/cmake/lapack-${LAPACK_VERSION})