minor modif on find BLAS
[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 endif( NOT BLAS_FOUND )
57
58
59 add_subdirectory(SRC)
60 add_subdirectory(TESTING)
61
62 # --------------------------------------------------
63 # CPACK Packaging 
64
65 SET(CPACK_PACKAGE_NAME "LAPACK")
66 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
67 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
68 set(LAPACK_VERSION 3.2.2)
69 set(CPACK_PACKAGE_VERSION_MAJOR 3)
70 set(CPACK_PACKAGE_VERSION_MINOR 2)
71 set(CPACK_PACKAGE_VERSION_PATCH 2)
72 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
73 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
74 IF(WIN32 AND NOT UNIX)
75   # There is a bug in NSI that does not handle full unix paths properly. Make
76   # sure there is at least one set of four (4) backlasshes.
77   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
78   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
79   SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
80   SET(CPACK_NSIS_MODIFY_PATH ON)
81   SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
82   set(CPACK_PACKAGE_RELOCATABLE "true")
83 ELSE(WIN32 AND NOT UNIX)
84   SET(CPACK_GENERATOR "TGZ")
85   SET(CPACK_SOURCE_GENERATOR TGZ)
86   SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
87   SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
88 ENDIF(WIN32 AND NOT UNIX)
89 INCLUDE(CPack)
90
91
92 # --------------------------------------------------
93 # By default static library
94 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
95 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
96
97 if( NOT BLAS_FOUND )
98   export(TARGETS blas lapack FILE lapack-targets.cmake)
99 else( NOT BLAS_FOUND )
100   export(TARGETS lapack FILE lapack-targets.cmake)
101 endif( NOT BLAS_FOUND )
102 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-version.cmake.in
103   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
104 configure_file(${LAPACK_SOURCE_DIR}/lapack-config.cmake.in
105   ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
106
107 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
108   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
109 install(FILES
110   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
111   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
112   DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
113   )
114 install(EXPORT lapack-targets
115   DESTINATION lib/cmake/lapack-${LAPACK_VERSION})