Added a CTestCustom.cmake file to filter unwanted files from code coverage and suppre...
[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 endif ()
19
20 macro(lapack_install_library lib)
21   install(TARGETS ${lib} EXPORT lapack-targets
22     ARCHIVE DESTINATION lib${LIB_SUFFIX}
23     LIBRARY DESTINATION lib${LIB_SUFFIX}
24     RUNTIME DESTINATION bin
25   )
26 endmacro()
27
28 # --------------------------------------------------
29 # Testing
30
31 enable_testing()
32 include(CTest)
33 enable_testing()
34 # --------------------------------------------------
35
36 set(CMAKE_MODULE_PATH ${LAPACK_SOURCE_DIR} ${CMAKE_MODULE_PATH})
37
38 # --------------------------------------------------
39 # Check second function
40
41 include(CheckTimeFunction)
42 set(TIME_FUNC NONE ${TIME_FUNC})
43 CHECK_TIME_FUNCTION(NONE TIME_FUNC)
44 CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
45 CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
46 CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
47 CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
48 message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.")
49
50 set(SECOND_SRC  ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
51 set(DSECOND_SRC  ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
52 set(prefix ${CMAKE_INSTALL_PREFIX})
53 set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
54 set(PKG_CONFIG_DIR ${libdir}/pkgconfig)
55
56 # --------------------------------------------------
57 # Subdirectories that need to be processed
58
59 option(USE_OPTIMIZED_BLAS "Whether or not to use an optimized BLAS library instead of included netlib BLAS" OFF)
60
61 # Check the usage of the user provided BLAS libraries
62 if(BLAS_LIBRAIRIES)
63   include(CheckFortranFunctionExists)
64   set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRAIRIES})
65   CHECK_FORTRAN_FUNCTION_EXISTS("dgemm" BLAS_FOUND)
66   unset( CMAKE_REQUIRED_LIBRARIES )
67   if(BLAS_FOUND)
68     message(STATUS "--> BLAS supplied by user is WORKING, will use ${BLAS_LIBRAIRIES}.")
69   else(BLAS_FOUND)
70     message(ERROR "--> BLAS supplied by user is not WORKING, CANNOT USE ${BLAS_LIBRAIRIES}.")
71     message(ERROR "-->     Will use REFERENCE BLAS (by default)")
72     message(ERROR "-->     Or Correct your BLAS_LIBRAIRIES entry ")
73     message(ERROR "-->     Or Consider checking USE_OPTIMIZED_BLAS")
74   endif(BLAS_FOUND)
75
76 # User did not provide a BLAS Library but specified to search for one
77 elseif( USE_OPTIMIZED_BLAS )
78   find_package( BLAS )
79 endif (BLAS_LIBRAIRIES)
80
81 # Neither user specified or optimized BLAS libraries can be used
82 if(NOT BLAS_FOUND)
83   add_subdirectory(BLAS)
84   set( BLAS_LIBRARIES blas )
85 else()
86   set( CMAKE_EXE_LINKER_FLAGS 
87     "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" 
88     CACHE STRING "Linker flags for executables" FORCE)
89   set( CMAKE_MODULE_LINKER_FLAGS 
90     "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" 
91     CACHE STRING "Linker flags for modules" FORCE)
92   set( CMAKE_SHARED_LINKER_FLAGS 
93     "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" 
94     CACHE STRING "Linker flags for shared libs" FORCE)
95 endif( NOT BLAS_FOUND )
96    
97 add_subdirectory(SRC)
98 if(BUILD_TESTING)
99   add_subdirectory(TESTING)
100 endif(BUILD_TESTING)
101
102 # --------------------------------------------------
103 # CPACK Packaging 
104
105 SET(CPACK_PACKAGE_NAME "LAPACK")
106 SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
107 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
108 set(LAPACK_VERSION 3.2.2)
109 set(CPACK_PACKAGE_VERSION_MAJOR 3)
110 set(CPACK_PACKAGE_VERSION_MINOR 2)
111 set(CPACK_PACKAGE_VERSION_PATCH 2)
112 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
113 SET(CPACK_PACKAGE_INSTALL_DIRECTORY "LAPACK")
114 IF(WIN32 AND NOT UNIX)
115   # There is a bug in NSI that does not handle full unix paths properly. Make
116   # sure there is at least one set of four (4) backlasshes.
117   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\http://icl.cs.utk.edu/lapack-forum")
118   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.netlib.org/lapack")
119   SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu")
120   SET(CPACK_NSIS_MODIFY_PATH ON)
121   SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}")
122   set(CPACK_PACKAGE_RELOCATABLE "true")
123 ELSE(WIN32 AND NOT UNIX)
124   SET(CPACK_GENERATOR "TGZ")
125   SET(CPACK_SOURCE_GENERATOR TGZ)
126   SET(CPACK_SOURCE_PACKAGE_FILE_NAME "lapack-${LAPACK_VERSION}" )
127   SET(CPACK_SOURCE_IGNORE_FILES ~$ .svn ${CPACK_SOURCE_IGNORE_FILES} )
128 ENDIF(WIN32 AND NOT UNIX)
129 INCLUDE(CPack)
130
131
132 # --------------------------------------------------
133 # By default static library
134 OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF )
135 OPTION(BUILD_STATIC_LIBS "Build static libraries" ON )
136 #OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
137
138 if( NOT BLAS_FOUND )
139   export(TARGETS blas lapack FILE lapack-targets.cmake)
140 else( NOT BLAS_FOUND )
141   export(TARGETS lapack FILE lapack-targets.cmake)
142 endif( NOT BLAS_FOUND )
143 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-version.cmake.in
144   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
145
146 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc)
147  install(FILES
148   ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
149   DESTINATION ${PKG_CONFIG_DIR}
150    )
151
152 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
153   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
154 install(FILES
155   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
156   ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
157   DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
158   )
159
160 configure_file(${LAPACK_SOURCE_DIR}/lapack-config-install.cmake.in
161   ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)