updated gemv kernel for armv6
[platform/upstream/openblas.git] / lapack-netlib / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.10)
2 project(LAPACK Fortran)
3
4 set(LAPACK_MAJOR_VERSION 3)
5 set(LAPACK_MINOR_VERSION 6)
6 set(LAPACK_PATCH_VERSION 0)
7 set(
8   LAPACK_VERSION
9   ${LAPACK_MAJOR_VERSION}.${LAPACK_MINOR_VERSION}.${LAPACK_PATCH_VERSION}
10   )
11
12 # Updated OSX RPATH settings
13 # In response to CMake 3.0 generating warnings regarding policy CMP0042,
14 # the OSX RPATH settings have been updated per recommendations found
15 # in the CMake Wiki:
16 #  http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
17     set(CMAKE_MACOSX_RPATH ON)
18     set(CMAKE_SKIP_BUILD_RPATH FALSE)
19     set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
20     set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
21     set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
22     list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
23     if("${isSystemDir}" STREQUAL "-1")
24         set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
25     endif()
26
27
28 # Configure the warning and code coverage suppression file
29 configure_file(
30   "${LAPACK_SOURCE_DIR}/CTestCustom.cmake.in"
31   "${LAPACK_BINARY_DIR}/CTestCustom.cmake"
32   COPYONLY
33 )
34
35 # Add the CMake directory for custon CMake modules
36 set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
37
38 if (UNIX)
39    if ( "${CMAKE_Fortran_COMPILER}" MATCHES "ifort" )
40   set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
41    endif ()
42    if ( "${CMAKE_Fortran_COMPILER}" MATCHES "xlf" )
43   set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave -qstrict=none" )
44    endif ()
45 # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
46 # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
47    STRING(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
48 endif ()
49
50 # Get Python
51 find_package(PythonInterp)
52 message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
53 if (PYTHONINTERP_FOUND)
54    message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
55 endif()
56 # --------------------------------------------------
57
58 set(LAPACK_INSTALL_EXPORT_NAME lapack-targets)
59
60 if (UNIX)
61   include(GNUInstallDirs)
62   set(ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR})
63   set(LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
64   set(RUNTIME_DIR ${CMAKE_INSTALL_BINDIR})
65 else()
66   set(ARCHIVE_DIR lib${LIB_SUFFIX})
67   set(LIBRARY_DIR lib${LIB_SUFFIX})
68   set(RUNTIME_DIR bin)
69 endif()
70
71 macro(lapack_install_library lib)
72   install(TARGETS ${lib}
73     EXPORT ${LAPACK_INSTALL_EXPORT_NAME}
74     ARCHIVE DESTINATION ${ARCHIVE_DIR}
75     LIBRARY DESTINATION ${LIBRARY_DIR}
76     RUNTIME DESTINATION ${RUNTIME_DIR}
77   )
78 endmacro()
79
80 # --------------------------------------------------
81 # Testing
82
83 enable_testing()
84 include(CTest)
85 enable_testing()
86 # --------------------------------------------------
87
88 # Organize output files.  On Windows this also keeps .dll files next
89 # to the .exe files that need them, making tests easy to run.
90 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/bin)
91 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib)
92 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib)
93
94 # --------------------------------------------------
95 # Check for any necessary platform specific compiler flags
96 include( CheckLAPACKCompilerFlags )
97 CheckLAPACKCompilerFlags()
98
99 # --------------------------------------------------
100 # Check second function
101
102 include(CheckTimeFunction)
103 set(TIME_FUNC NONE ${TIME_FUNC})
104 CHECK_TIME_FUNCTION(NONE TIME_FUNC)
105 CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
106 CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
107 CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
108 CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
109 message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.")
110
111 set(SECOND_SRC  ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
112 set(DSECOND_SRC  ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
113 set(PKG_CONFIG_DIR ${LIBRARY_DIR}/pkgconfig)
114
115 # --------------------------------------------------
116 # Precision to build
117 # By default all precisions are generated
118
119
120 # --------------------------------------------------
121 # Subdirectories that need to be processed
122
123 option(USE_OPTIMIZED_BLAS "Whether or not to use an optimized BLAS library instead of included netlib BLAS" OFF)
124
125
126 # Check the usage of the user provided BLAS libraries
127 if(BLAS_LIBRARIES)
128   include(CheckFortranFunctionExists)
129   set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
130   CHECK_FORTRAN_FUNCTION_EXISTS("dgemm" BLAS_FOUND)
131   unset( CMAKE_REQUIRED_LIBRARIES )
132   if(BLAS_FOUND)
133     message(STATUS "--> BLAS supplied by user is WORKING, will use ${BLAS_LIBRARIES}.")
134   else(BLAS_FOUND)
135     message(ERROR "--> BLAS supplied by user is not WORKING, CANNOT USE ${BLAS_LIBRARIES}.")
136     message(ERROR "-->     Will use REFERENCE BLAS (by default)")
137     message(ERROR "-->     Or Correct your BLAS_LIBRARIES entry ")
138     message(ERROR "-->     Or Consider checking USE_OPTIMIZED_BLAS")
139   endif(BLAS_FOUND)
140
141 # User did not provide a BLAS Library but specified to search for one
142 elseif( USE_OPTIMIZED_BLAS )
143   find_package( BLAS )
144 endif (BLAS_LIBRARIES)
145
146 # Neither user specified or optimized BLAS libraries can be used
147 if(NOT BLAS_FOUND)
148   message(STATUS "Using supplied NETLIB BLAS implementation")
149   add_subdirectory(BLAS)
150   set( BLAS_LIBRARIES blas )
151 else()
152   set( CMAKE_EXE_LINKER_FLAGS 
153     "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" 
154     CACHE STRING "Linker flags for executables" FORCE)
155   set( CMAKE_MODULE_LINKER_FLAGS 
156     "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" 
157     CACHE STRING "Linker flags for modules" FORCE)
158   set( CMAKE_SHARED_LINKER_FLAGS 
159     "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" 
160     CACHE STRING "Linker flags for shared libs" FORCE)
161 endif( NOT BLAS_FOUND )
162
163
164 # --------------------------------------------------
165 # CBLAS
166 option(CBLAS "Build CBLAS" OFF)
167
168 if(CBLAS)
169   add_subdirectory(CBLAS)
170 endif(CBLAS)
171
172 # --------------------------------------------------
173 # XBLAS
174
175 option(USE_XBLAS "Build extended precision (needs XBLAS)" OFF)
176 if (USE_XBLAS)
177   find_library(XBLAS_LIBRARY NAMES xblas)
178 endif(USE_XBLAS)
179    
180 option(USE_OPTIMIZED_LAPACK "Whether or not to use an optimized LAPACK library instead of included netlib LAPACK" OFF)
181
182 # --------------------------------------------------
183 # LAPACK
184 # User did not provide a LAPACK Library but specified to search for one
185 if( USE_OPTIMIZED_LAPACK )
186   find_package( LAPACK )
187 endif (USE_OPTIMIZED_LAPACK)
188
189 # Check the usage of the user provided or automatically found LAPACK libraries
190 if(LAPACK_LIBRARIES)
191   include(CheckFortranFunctionExists)
192   set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
193   # Check if new routine of 3.4.0 is in LAPACK_LIBRARIES
194   CHECK_FORTRAN_FUNCTION_EXISTS("dgeqrt" LATESTLAPACK_FOUND)
195   unset( CMAKE_REQUIRED_LIBRARIES )
196   if(LATESTLAPACK_FOUND)
197     message(STATUS "--> LAPACK supplied by user is WORKING, will use ${LAPACK_LIBRARIES}.")
198   else(LAPACK_FOUND)
199     message(ERROR "--> LAPACK supplied by user is not WORKING or is older than LAPACK 3.4.0,    CANNOT USE ${LAPACK_LIBRARIES}.")
200     message(ERROR "-->     Will use REFERENCE LAPACK (by default)")
201     message(ERROR "-->     Or Correct your LAPACK_LIBRARIES entry ")
202     message(ERROR "-->     Or Consider checking USE_OPTIMIZED_LAPACK")
203   endif(LATESTLAPACK_FOUND)
204 endif (LAPACK_LIBRARIES)
205
206 # Neither user specified or optimized LAPACK libraries can be used
207 if(NOT LATESTLAPACK_FOUND)
208   message(STATUS "Using supplied NETLIB LAPACK implementation")
209   set( LAPACK_LIBRARIES lapack )
210   option(BUILD_SINGLE "Build LAPACK Single Precision" ON)
211   option(BUILD_DOUBLE "Build LAPACK Double Precision" ON)
212   option(BUILD_COMPLEX "Build LAPACK Complex Precision" ON)
213   option(BUILD_COMPLEX16 "Build LAPACK Double Complex Precision" ON)
214   add_subdirectory(SRC)
215 else()
216   set( CMAKE_EXE_LINKER_FLAGS 
217     "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" 
218     CACHE STRING "Linker flags for executables" FORCE)
219   set( CMAKE_MODULE_LINKER_FLAGS 
220     "${CMAKE_MODULE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" 
221     CACHE STRING "Linker flags for modules" FORCE)
222   set( CMAKE_SHARED_LINKER_FLAGS 
223     "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" 
224     CACHE STRING "Linker flags for shared libs" FORCE)
225 endif( NOT LATESTLAPACK_FOUND )
226
227 message(STATUS "BUILD TESTING : ${BUILD_TESTING}" )
228 if(BUILD_TESTING)
229   add_subdirectory(TESTING)
230 endif(BUILD_TESTING)
231
232 # deprecated LAPACK routines
233 option(BUILD_DEPRECATED "Build deprecated routines" OFF)
234
235 # --------------------------------------------------
236 # LAPACKE
237 option(LAPACKE "Build LAPACKE" OFF)
238
239 # LAPACKE has also the interface to some routines from tmglib,
240 # if LAPACKE_WITH_TMG is selected, we need to add those routines to LAPACKE
241 option(LAPACKE_WITH_TMG "Build LAPACKE with tmglib routines" OFF)
242 if (LAPACKE_WITH_TMG)
243   set(LAPACKE ON)
244   if(NOT BUILD_TESTING)
245      add_subdirectory(TESTING/MATGEN)
246    endif(NOT BUILD_TESTING)
247 endif(LAPACKE_WITH_TMG)
248
249 if(LAPACKE)
250   add_subdirectory(LAPACKE)
251 endif(LAPACKE)
252
253 # --------------------------------------------------
254 # CPACK Packaging 
255
256 SET(CPACK_PACKAGE_NAME "LAPACK")
257 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
258 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
259 set(CPACK_PACKAGE_VERSION_MAJOR 3)
260 set(CPACK_PACKAGE_VERSION_MINOR 5)
261 set(CPACK_PACKAGE_VERSION_PATCH 0)
262 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
263 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
264 IF(WIN32 AND NOT UNIX)
265   # There is a bug in NSI that does not handle full unix paths properly. Make
266   # sure there is at least one set of four (4) backlasshes.
267   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
268   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
269   SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
270   SET(CPACK_NSIS_MODIFY_PATH ON)
271   SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
272   set(CPACK_PACKAGE_RELOCATABLE "true")
273 ELSE(WIN32 AND NOT UNIX)
274   SET(CPACK_GENERATOR "TGZ")
275   SET(CPACK_SOURCE_GENERATOR TGZ)
276   SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
277   SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
278 ENDIF(WIN32 AND NOT UNIX)
279 INCLUDE(CPack)
280
281
282 # --------------------------------------------------
283 # By default static library
284 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
285 OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
286 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
287
288 if(NOT BLAS_FOUND)
289   set(ALL_TARGETS ${ALL_TARGETS} blas)
290 endif(NOT BLAS_FOUND)
291
292 if(NOT LATESTLAPACK_FOUND)
293   set(ALL_TARGETS ${ALL_TARGETS} lapack)
294 endif(NOT LATESTLAPACK_FOUND)
295
296 if(BUILD_TESTING OR LAPACKE_WITH_TMG)
297   set(ALL_TARGETS ${ALL_TARGETS} tmglib)
298 endif(BUILD_TESTING OR LAPACKE_WITH_TMG)
299
300 # Export lapack targets, not including lapacke, from the
301 # install tree, if any.
302 set(_lapack_config_install_guard_target "")
303 if(ALL_TARGETS)
304   install(EXPORT lapack-targets
305     DESTINATION ${LIBRARY_DIR}/cmake/lapack-${LAPACK_VERSION})
306
307   # Choose one of the lapack targets to use as a guard for
308   # lapack-config.cmake to load targets from the install tree.
309   list(GET ALL_TARGETS 0 _lapack_config_install_guard_target)
310 endif()
311
312 # Include cblas in targets exported from the build tree.
313 if(CBLAS)
314   set(ALL_TARGETS ${ALL_TARGETS} cblas)
315 endif(CBLAS)
316
317 # Include lapacke in targets exported from the build tree.
318 if(LAPACKE)
319   set(ALL_TARGETS ${ALL_TARGETS} lapacke)
320 endif(LAPACKE)
321
322 # Export lapack and lapacke targets from the build tree, if any.
323 set(_lapack_config_build_guard_target "")
324 if(ALL_TARGETS)
325   export(TARGETS ${ALL_TARGETS} FILE lapack-targets.cmake)
326
327   # Choose one of the lapack or lapacke targets to use as a guard
328   # for lapack-config.cmake to load targets from the build tree.
329   list(GET ALL_TARGETS 0 _lapack_config_build_guard_target)
330 endif()
331
332 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-build.cmake.in
333   ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
334
335
336 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc)
337   install(FILES
338   ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
339   DESTINATION ${PKG_CONFIG_DIR}
340    )
341
342 configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-install.cmake.in
343   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
344
345 include(CMakePackageConfigHelpers)
346 write_basic_package_version_file(
347   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
348   VERSION ${LAPACK_VERSION}
349   COMPATIBILITY SameMajorVersion
350   )
351
352 install(FILES
353   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
354   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
355   DESTINATION ${LIBRARY_DIR}/cmake/lapack-${LAPACK_VERSION}
356   )