1 cmake_minimum_required(VERSION 2.8)
2 project(LAPACK Fortran)
4 # Configure the warning and code coverage suppression file
6 "${LAPACK_SOURCE_DIR}/CTestCustom.cmake.in"
7 "${LAPACK_BINARY_DIR}/CTestCustom.cmake"
11 # Add the CMake directory for custon CMake modules
12 set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
15 if ( "${CMAKE_Fortran_COMPILER}" MATCHES "ifort" )
16 set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
18 if ( "${CMAKE_Fortran_COMPILER}" MATCHES "xlf" )
19 set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave -qstrict=none" )
21 # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
22 # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
23 STRING(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
27 find_package(PythonInterp)
28 message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
29 if (PYTHONINTERP_FOUND)
30 message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
32 # --------------------------------------------------
34 # On Windows-GNU builds try to provide MS import libraries too.
40 set(LAPACK_GNUtoMS_IMPORT ${LAPACK_SOURCE_DIR}/CMAKE/lapack-GNUtoMS.cmake)
41 set(LAPACK_GNUtoMS_INSTALL "include(\${_SELF_DIR}/lapack-GNUtoMS.cmake)")
42 set(LAPACK_GNUtoMS_BUILD "include(\"${LAPACK_GNUtoMS_IMPORT}\")")
45 macro(lapack_install_library lib)
46 install(TARGETS ${lib} EXPORT lapack-targets
47 ARCHIVE DESTINATION lib${LIB_SUFFIX}
48 LIBRARY DESTINATION lib${LIB_SUFFIX}
49 RUNTIME DESTINATION bin
52 install(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${lib}.lib DESTINATION lib)
56 # --------------------------------------------------
62 # --------------------------------------------------
64 # Organize output files. On Windows this also keeps .dll files next
65 # to the .exe files that need them, making tests easy to run.
66 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/bin)
67 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib)
68 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib)
70 # --------------------------------------------------
71 # Check for any necessary platform specific compiler flags
72 include( CheckLAPACKCompilerFlags )
73 CheckLAPACKCompilerFlags()
75 # --------------------------------------------------
76 # Check second function
78 include(CheckTimeFunction)
79 set(TIME_FUNC NONE ${TIME_FUNC})
80 CHECK_TIME_FUNCTION(NONE TIME_FUNC)
81 CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
82 CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
83 CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
84 CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
85 message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.")
87 set(SECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
88 set(DSECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
89 set(prefix ${CMAKE_INSTALL_PREFIX})
90 set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
91 set(PKG_CONFIG_DIR ${libdir}/pkgconfig)
93 # --------------------------------------------------
95 # By default all precisions are generated
97 option(BUILD_SINGLE "Build LAPACK Single Precision" ON)
98 option(BUILD_DOUBLE "Build LAPACK Double Precision" ON)
99 option(BUILD_COMPLEX "Build LAPACK Complex Precision" ON)
100 option(BUILD_COMPLEX16 "Build LAPACK Double Complex Precision" ON)
102 # --------------------------------------------------
103 # Subdirectories that need to be processed
105 option(USE_OPTIMIZED_BLAS "Whether or not to use an optimized BLAS library instead of included netlib BLAS" OFF)
108 # Check the usage of the user provided BLAS libraries
110 include(CheckFortranFunctionExists)
111 set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
112 CHECK_FORTRAN_FUNCTION_EXISTS("dgemm" BLAS_FOUND)
113 unset( CMAKE_REQUIRED_LIBRARIES )
115 message(STATUS "--> BLAS supplied by user is WORKING, will use ${BLAS_LIBRARIES}.")
117 message(ERROR "--> BLAS supplied by user is not WORKING, CANNOT USE ${BLAS_LIBRARIES}.")
118 message(ERROR "--> Will use REFERENCE BLAS (by default)")
119 message(ERROR "--> Or Correct your BLAS_LIBRARIES entry ")
120 message(ERROR "--> Or Consider checking USE_OPTIMIZED_BLAS")
123 # User did not provide a BLAS Library but specified to search for one
124 elseif( USE_OPTIMIZED_BLAS )
126 endif (BLAS_LIBRARIES)
128 # Neither user specified or optimized BLAS libraries can be used
130 message(STATUS "Using supplied NETLIB BLAS implementation")
131 add_subdirectory(BLAS)
132 set( BLAS_LIBRARIES blas )
134 set( CMAKE_EXE_LINKER_FLAGS
135 "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
136 CACHE STRING "Linker flags for executables" FORCE)
137 set( CMAKE_MODULE_LINKER_FLAGS
138 "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
139 CACHE STRING "Linker flags for modules" FORCE)
140 set( CMAKE_SHARED_LINKER_FLAGS
141 "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
142 CACHE STRING "Linker flags for shared libs" FORCE)
143 endif( NOT BLAS_FOUND )
145 option(USE_XBLAS "Build extended precision (needs XBLAS)" OFF)
147 find_library(XBLAS_LIBRARY NAMES xblas)
150 add_subdirectory(SRC)
152 add_subdirectory(TESTING)
155 # --------------------------------------------------
157 option(LAPACKE "Build LAPACKE" OFF)
158 # LAPACKE has also the interface to some routines from tmglib,
159 # if LAPACKE_WITH_TMG is selected, we need to add those routines to LAPACKE
160 option(LAPACKE_WITH_TMG "Build LAPACKE with tmglib routines" OFF)
161 if (LAPACKE_WITH_TMG)
162 option(LAPACKE "Build LAPACKE" ON)
163 endif(LAPACKE_WITH_TMG)
166 add_subdirectory(lapacke)
169 # --------------------------------------------------
172 SET(CPACK_PACKAGE_NAME "LAPACK")
173 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
174 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
175 set(LAPACK_VERSION 3.4.1)
176 set(CPACK_PACKAGE_VERSION_MAJOR 3)
177 set(CPACK_PACKAGE_VERSION_MINOR 4)
178 set(CPACK_PACKAGE_VERSION_PATCH 1)
179 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
180 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
181 IF(WIN32 AND NOT UNIX)
182 # There is a bug in NSI that does not handle full unix paths properly. Make
183 # sure there is at least one set of four (4) backlasshes.
184 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
185 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
186 SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
187 SET(CPACK_NSIS_MODIFY_PATH ON)
188 SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
189 set(CPACK_PACKAGE_RELOCATABLE "true")
190 ELSE(WIN32 AND NOT UNIX)
191 SET(CPACK_GENERATOR "TGZ")
192 SET(CPACK_SOURCE_GENERATOR TGZ)
193 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
194 SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
195 ENDIF(WIN32 AND NOT UNIX)
199 # --------------------------------------------------
200 # By default static library
201 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
202 OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
203 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
207 export(TARGETS blas lapack tmglib lapacke FILE lapack-targets.cmake)
209 export(TARGETS blas lapack tmglib FILE lapack-targets.cmake)
211 else( NOT BLAS_FOUND )
213 export(TARGETS lapack tmglib lapacke FILE lapack-targets.cmake)
215 export(TARGETS lapack tmglib FILE lapack-targets.cmake)
217 endif( NOT BLAS_FOUND )
219 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-version.cmake.in
220 ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
221 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-build.cmake.in
222 ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
225 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc)
227 ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
228 DESTINATION ${PKG_CONFIG_DIR}
231 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-install.cmake.in
232 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
234 ${LAPACK_GNUtoMS_IMPORT}
235 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
236 ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
237 DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
240 install(EXPORT lapack-targets
241 DESTINATION lib/cmake/lapack-${LAPACK_VERSION})