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