1 cmake_minimum_required(VERSION 2.6)
2 project(LAPACK Fortran)
4 # Add the CMake directory for custon CMake modules
5 set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
8 if ( "${CMAKE_Fortran_COMPILER}" MATCHES "ifort" )
9 set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
13 macro(lapack_install_library lib)
14 install(TARGETS ${lib} EXPORT lapack-targets
15 ARCHIVE DESTINATION lib${LIB_SUFFIX}
16 LIBRARY DESTINATION lib${LIB_SUFFIX}
17 RUNTIME DESTINATION bin
21 # --------------------------------------------------
27 # --------------------------------------------------
29 set(CMAKE_MODULE_PATH ${LAPACK_SOURCE_DIR} ${CMAKE_MODULE_PATH})
31 # --------------------------------------------------
32 # Check second function
34 include(CheckTimeFunction)
35 set(TIME_FUNC NONE ${TIME_FUNC})
36 CHECK_TIME_FUNCTION(NONE TIME_FUNC)
37 CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
38 CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
39 CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
40 CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
41 message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.")
43 set(SECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
44 set(DSECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
45 set(prefix ${CMAKE_INSTALL_PREFIX})
46 set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
47 set(PKG_CONFIG_DIR ${libdir}/pkgconfig)
49 # --------------------------------------------------
50 # Subdirectories that need to be processed
52 option(USE_OPTIMIZED_BLAS "Whether or not to use an optimized BLAS library instead of included netlib BLAS" OFF)
54 # Check the usage of the user provided BLAS libraries
56 include(CheckFortranFunctionExists)
57 set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRAIRIES})
58 CHECK_FORTRAN_FUNCTION_EXISTS("dgemm" BLAS_FOUND)
59 unset( CMAKE_REQUIRED_LIBRARIES )
61 message(STATUS "--> BLAS supplied by user is WORKING, will use ${BLAS_LIBRAIRIES}.")
63 message(ERROR "--> BLAS supplied by user is not WORKING, CANNOT USE ${BLAS_LIBRAIRIES}.")
64 message(ERROR "--> Will use REFERENCE BLAS (by default)")
65 message(ERROR "--> Or Correct your BLAS_LIBRAIRIES entry ")
66 message(ERROR "--> Or Consider checking USE_OPTIMIZED_BLAS")
69 # User did not provide a BLAS Library but specified to search for one
70 elseif( USE_OPTIMIZED_BLAS )
72 endif (BLAS_LIBRAIRIES)
74 # Neither user specified or optimized BLAS libraries can be used
76 add_subdirectory(BLAS)
77 set( BLAS_LIBRARIES blas )
79 set( CMAKE_EXE_LINKER_FLAGS
80 "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
81 CACHE STRING "Linker flags for executables" FORCE)
82 set( CMAKE_MODULE_LINKER_FLAGS
83 "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
84 CACHE STRING "Linker flags for modules" FORCE)
85 set( CMAKE_SHARED_LINKER_FLAGS
86 "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}"
87 CACHE STRING "Linker flags for shared libs" FORCE)
88 endif( NOT BLAS_FOUND )
92 add_subdirectory(TESTING)
95 # --------------------------------------------------
98 SET(CPACK_PACKAGE_NAME "LAPACK")
99 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
100 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
101 set(LAPACK_VERSION 3.2.2)
102 set(CPACK_PACKAGE_VERSION_MAJOR 3)
103 set(CPACK_PACKAGE_VERSION_MINOR 2)
104 set(CPACK_PACKAGE_VERSION_PATCH 2)
105 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
106 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
107 IF(WIN32 AND NOT UNIX)
108 # There is a bug in NSI that does not handle full unix paths properly. Make
109 # sure there is at least one set of four (4) backlasshes.
110 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
111 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
112 SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
113 SET(CPACK_NSIS_MODIFY_PATH ON)
114 SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
115 set(CPACK_PACKAGE_RELOCATABLE "true")
116 ELSE(WIN32 AND NOT UNIX)
117 SET(CPACK_GENERATOR "TGZ")
118 SET(CPACK_SOURCE_GENERATOR TGZ)
119 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
120 SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
121 ENDIF(WIN32 AND NOT UNIX)
125 # --------------------------------------------------
126 # By default static library
127 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
128 OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
129 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
132 export(TARGETS blas lapack FILE lapack-targets.cmake)
133 else( NOT BLAS_FOUND )
134 export(TARGETS lapack FILE lapack-targets.cmake)
135 endif( NOT BLAS_FOUND )
136 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-version.cmake.in
137 ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
139 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc)
141 ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
142 DESTINATION ${PKG_CONFIG_DIR}
145 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
146 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
148 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
149 ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
150 DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
153 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
154 ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)