This repository has been archived by the owner on Mar 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
157 lines (126 loc) · 4.91 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#
# Portions Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
#
# Please see distribution for license.
#
cmake_minimum_required (VERSION 2.8.6)
if(CMAKE_MAJOR_VERSION MATCHES 2 AND
CMAKE_MINOR_VERSION MATCHES 8 AND
CMAKE_PATCH_VERSION MATCHES 12)
cmake_policy(SET CMP0022 OLD)
endif()
include(CMakeForceCompiler)
if(APPLE OR WIN32)
# On Apple, we don't want to use Clang.
# On Windows, we don't want to end up building with Visual Studio.
CMAKE_FORCE_C_COMPILER(gcc GNU)
endif(APPLE OR WIN32)
project (LAPACK)
set(LAPACK_VERSION_MAJOR 3)
set(LAPACK_VERSION_MINOR 4)
set(LAPACK_VERSION_PATCH 2)
set(LAPACK_VERSION ${LAPACK_VERSION_MAJOR}.${LAPACK_VERSION_MINOR}.${LAPACK_VERSION_PATCH})
# Append local module folder to module path
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMAKE ${CMAKE_MODULE_PATH})
# fix for fortran support to get version correct
if(APPLE)
set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ")
endif(APPLE)
# languages
enable_language(Fortran)
enable_language(C)
# use flat namespace
if(APPLE)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wl,-flat_namespace")
endif(APPLE)
# Get Python
find_package(PythonInterp)
message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
if (PYTHONINTERP_FOUND)
message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
endif()
if(WIN32)
set(CMAKE_THREAD_LIBS_INIT -mthreads)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -pipe")
else()
# we force -pthread in preference to -lpthread because it sets -D_REENTRANT
set(THREADS_HAVE_PTHREAD_ARG "THREADS_HAVE_PTHREAD_ARG")
find_package(Threads)
endif()
# Add thread libs
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
# Use the native assembler on Apple in order to be able to generate AVX instructions.
if(APPLE)
set(CMAKE_C_FLAGS "-Wa,-q ${CMAKE_C_FLAGS}")
set(CMAKE_Fortran_FLAGS "${CMAKE_C_FLAGS}")
endif()
# fix rpath
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--rpath -Wl,\$ORIGIN")
endif()
# Place executables and libraries in bin on Windows so that its linker can find them.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/bin)
enable_testing()
# Check for any necessary platform specific compiler flags
# this is from the original LAPACK cmake build, in our case makes sure
# FPE traps aren't on by accident or intent!
include( CheckLAPACKCompilerFlags )
CheckLAPACKCompilerFlags()
# Multi-targets need to be built
include(MultiInstructionTarget)
set(TARGET_TYPES dbg std)
if(BITS64)
set(TARGET_TYPES ${TARGET_TYPES} sse41 avx1)
endif()
if(WIN32 AND BITS32)
set(PLATFORM_FLAGS "-ffloat-store")
endif()
set(OPT_FLAGS_dbg "${PLATFORM_FLAGS} -DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
set(OPT_FLAGS_std "${PLATFORM_FLAGS} -O2 -funroll-loops -DNDEBUG")
set(OPT_FLAGS_sse41 "${OPT_FLAGS_std} -march=core2 -msse4.1")
set(OPT_FLAGS_avx1 "${OPT_FLAGS_std} -march=corei7-avx -mavx256-split-unaligned-load -mavx256-split-unaligned-store")
# make calls to existing cmake to pickup BLAS
message(STATUS "Using NETLIB BLAS implementation")
add_subdirectory(BLAS)
set( BLAS_LIBRARIES ogblas )
# make calls to existing cmake to pick build support config
message(STATUS "Using NETLIB LAPACK implementation")
set( LAPACK_LIBRARIES oglapack )
set(BUILD_SINGLE TRUE)
set(BUILD_DOUBLE TRUE)
set(BUILD_COMPLEX TRUE)
set(BUILD_COMPLEX16 TRUE)
add_subdirectory(SRC)
# Check second function
include(CheckTimeFunction)
set(TIME_FUNC NONE ${TIME_FUNC})
CHECK_TIME_FUNCTION(NONE TIME_FUNC)
CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.")
set(SECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f)
set(DSECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f)
add_subdirectory(TESTING)
# Add version info file
if(NOT DEFINED BUILDNUMBER)
set(BUILDNUMBER local)
endif()
add_custom_target(verinfo ALL
${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/CMAKE/verinfo.py ${CMAKE_BINARY_DIR}/verinfo.yaml ${JAR_VERSION} ${BUILDNUMBER}
COMMENT "Generating version info")
# done
message("
Package " ${CMAKE_PROJECT_NAME} " version " ${LAPACK_VERSION} "
Prefix.....................: " ${CMAKE_INSTALL_PREFIX} "
C Compiler.................: " ${CMAKE_C_COMPILER} "
C Flags....................: " ${CMAKE_C_FLAGS} "
Fortran Compiler...........: " ${CMAKE_Fortran_COMPILER} "
Fortran Compiler...........: " ${CMAKE_Fortran_FLAGS} "
Threads flag..............:: " ${CMAKE_THREAD_LIBS_INIT} "
Python executable..........: " ${PYTHON_EXECUTABLE} "
")