Added compiler flags from FindBLAS.
[platform/upstream/lapack.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 project(LAPACK Fortran)
3
4 # Add the CMake directory for custon CMake modules
5 set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
6
7 if (UNIX)
8    if ( "${CMAKE_Fortran_COMPILER}" MATCHES "ifort" )
9   set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
10    endif ()
11 endif ()
12
13 macro(lapack_install_library lib)
14   install(TARGETS ${lib} EXPORT lapack-targets
15     ARCHIVE DESTINATION lib
16     LIBRARY DESTINATION lib
17     RUNTIME DESTINATION bin
18     )
19 endmacro()
20
21 # --------------------------------------------------
22 # Testing
23
24 enable_testing()
25 include(CTest)
26 enable_testing()
27 # --------------------------------------------------
28
29 set(CMAKE_MODULE_PATH ${LAPACK_SOURCE_DIR} ${CMAKE_MODULE_PATH})
30
31 # --------------------------------------------------
32 # Check second function
33
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.")
42
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
46 # --------------------------------------------------
47 # Subdirectories that need to be processed
48
49 option(LOOK_FOR_OPTIMZED_BLAS "Whether or not to use an optimized BLAS library or the included netlib BLAS" OFF)
50 if( LOOK_FOR_OPTIMZED_BLAS )
51   find_package( BLAS )
52 endif(LOOK_FOR_OPTIMZED_BLAS)
53 if(NOT BLAS_FOUND)
54   add_subdirectory(BLAS)
55   set( BLAS_LIBRARIES blas )
56 else()
57   set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${BLAS_LINKER_FLAGS}" 
58     CACHE STRING "Flags for Fortran compiler" FORCE
59   )
60 endif( NOT BLAS_FOUND )
61
62
63 add_subdirectory(SRC)
64 add_subdirectory(TESTING)
65
66 # --------------------------------------------------
67 # CPACK Packaging 
68
69 SET(CPACK_PACKAGE_NAME "LAPACK")
70 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
71 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
72 set(LAPACK_VERSION 3.2.2)
73 set(CPACK_PACKAGE_VERSION_MAJOR 3)
74 set(CPACK_PACKAGE_VERSION_MINOR 2)
75 set(CPACK_PACKAGE_VERSION_PATCH 2)
76 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
77 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
78 IF(WIN32 AND NOT UNIX)
79   # There is a bug in NSI that does not handle full unix paths properly. Make
80   # sure there is at least one set of four (4) backlasshes.
81   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
82   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
83   SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
84   SET(CPACK_NSIS_MODIFY_PATH ON)
85   SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
86   set(CPACK_PACKAGE_RELOCATABLE "true")
87 ELSE(WIN32 AND NOT UNIX)
88   SET(CPACK_GENERATOR "TGZ")
89   SET(CPACK_SOURCE_GENERATOR TGZ)
90   SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
91   SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
92 ENDIF(WIN32 AND NOT UNIX)
93 INCLUDE(CPack)
94
95
96 # --------------------------------------------------
97 # By default static library
98 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
99 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
100
101 if( NOT BLAS_FOUND )
102   export(TARGETS blas lapack FILE lapack-targets.cmake)
103 else( NOT BLAS_FOUND )
104   export(TARGETS lapack FILE lapack-targets.cmake)
105 endif( NOT BLAS_FOUND )
106 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-version.cmake.in
107   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
108 configure_file(${LAPACK_SOURCE_DIR}/lapack-config.cmake.in
109   ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
110
111 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
112   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
113 install(FILES
114   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
115   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
116   DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
117   )
118 install(EXPORT lapack-targets
119   DESTINATION lib/cmake/lapack-${LAPACK_VERSION})