-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·286 lines (223 loc) · 11.3 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# Project setup
###############
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
project(ViennaCL)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 4)
set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
SET(CMAKE_VERBOSE_MAKEFILE ON) #uncomment this line to increase CMake verbosity
#SET(BOOSTPATH "C:/Program\ Files\ (x86)/boost/boost_1_42") #Boost path for other systems - customize as needed
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Common options
################
set(VIENNACL_SRC_DIST TRUE)
include(ViennaCLCommon)
# Set release build:
IF(DEFINED CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
ELSE()
SET (CMAKE_BUILD_TYPE Release)
ENDIF()
# User options
##############
option(BUILD_DOXYGEN_DOCS "Build the Doxygen-generated API docs" OFF)
option(BUILD_MANUAL "Build the PDF manual" OFF)
cmake_dependent_option(ENABLE_DIST "Enable the the distribution tarball target" ON "BUILD_DOXYGEN_DOCS;BUILD_MANUAL" OFF)
mark_as_advanced(BUILD_DOXYGEN_DOCS BUILD_MANUAL ENABLE_DIST)
# Find prerequisites
####################
if(BUILD_DOXYGEN_DOCS)
find_package(Doxygen REQUIRED)
endif()
if(BUILD_MANUAL)
find_package(LATEX REQUIRED)
endif()
# Compile options
#################
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
INCLUDE_DIRECTORIES("/opt/local/include")
set(CMAKE_EXE_LINKER_FLAGS "-framework OpenCL")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Subdirectories
################
add_subdirectory(auxiliary)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_TESTING)
INCLUDE(CTest)
add_subdirectory(tests)
endif()
add_subdirectory(doc)
# Install
#########
install(DIRECTORY viennacl ${CMAKE_CURRENT_BINARY_DIR}/viennacl
DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT dev
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
# Dist target
#############
if(ENABLE_DIST)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/dist")
set(DISTDIR "${PROJECT_BINARY_DIR}/dist/ViennaCL-${VERSION}-all-arch")
configure_file(cmake/CMakeLists.txt.in "${DISTDIR}/CMakeLists.txt" @ONLY)
set(DIST_SOURCES_DIR "${PROJECT_BINARY_DIR}/dist/ViennaCL-${VERSION}-src")
configure_file(cmake/CMakeLists.txt.in.src "${DIST_SOURCES_DIR}/CMakeLists.txt" @ONLY)
#
# Full package:
#
add_custom_target(dist
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DISTDIR}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/LICENSE" "${DISTDIR}/LICENSE"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/changelog" "${DISTDIR}/changelog"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/README" "${DISTDIR}/README"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DISTDIR}/build"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/build/README" "${DISTDIR}/build/README"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/CL" "${DISTDIR}/CL"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DISTDIR}/cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/copymanual.cmake" "${DISTDIR}/cmake/copymanual.cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/FindMTL.cmake" "${DISTDIR}/cmake/FindMTL.cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/FindOpenCL.cmake" "${DISTDIR}/cmake/FindOpenCL.cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/FindViennaProfiler.cmake" "${DISTDIR}/cmake/FindViennaProfiler.cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/ViennaCLCommon.cmake" "${DISTDIR}/cmake/ViennaCLCommon.cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/ViennaCLConfig.cmake.in" "${DISTDIR}/cmake/ViennaCLConfig.cmake.in"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/ViennaCLConfigVersion.cmake.in" "${DISTDIR}/cmake/ViennaCLConfigVersion.cmake.in"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DISTDIR}/doc"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/doc/viennacl.pdf" "${DISTDIR}/doc/viennacl.pdf"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen"
"${DISTDIR}/doc/doxygen"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/doc/viennacl.pdf" "${DISTDIR}/doc/viennacl.pdf"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/doc/Doxyfile.in" "${DISTDIR}/doc/Doxyfile.in"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/examples" "${DISTDIR}/examples"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/external" "${DISTDIR}/external"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DISTDIR}/tests"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DISTDIR}/tests/src"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/tests/src" "${DISTDIR}/tests/src"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/tests/CMakeLists.txt" "${DISTDIR}/tests/CMakeLists.txt"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/viennacl" "${DISTDIR}/viennacl"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/viennacl/linalg/kernels"
"${DISTDIR}/viennacl/linalg/kernels"
COMMAND "${CMAKE_COMMAND}" -E tar czf ViennaCL-${VERSION}-all-arch.tar.gz
ViennaCL-${VERSION}-all-arch
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/dist"
COMMENT "Generating dist/ViennaCL-${VERSION}-all-arch.tar.gz"
VERBATIM)
add_dependencies(dist kernels apidoc manual)
#
# Sources only (no generated files):
#
foreach(f LICENSE
README
changelog
cmake/copymanual.cmake
cmake/FindMTL.cmake
cmake/FindOpenCL.cmake
cmake/FindViennaProfiler.cmake
cmake/ViennaCLCommon.cmake
cmake/ViennaCLConfig.cmake.in
cmake/ViennaCLConfigVersion.cmake.in
auxiliary/README
build/README)
configure_file(${f} "${DIST_SOURCES_DIR}/${f}" COPYONLY)
endforeach()
add_custom_target(copymanual-src ALL
"${CMAKE_COMMAND}"
-DSRC="${PROJECT_SOURCE_DIR}/doc/manual/"
-DDST="${DIST_SOURCES_DIR}/doc/manual/"
-P ${CMAKE_SOURCE_DIR}/cmake/copymanual.cmake
)
add_custom_target(dist-src
# Set up directory layout:
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DIST_SOURCES_DIR}"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/compressed_matrix" "${DIST_SOURCES_DIR}/auxiliary/compressed_matrix"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/coordinate_matrix" "${DIST_SOURCES_DIR}/auxiliary/coordinate_matrix"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/ell_matrix" "${DIST_SOURCES_DIR}/auxiliary/ell_matrix"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/hyb_matrix" "${DIST_SOURCES_DIR}/auxiliary/hyb_matrix"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/matrix_col" "${DIST_SOURCES_DIR}/auxiliary/matrix_col"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/matrix_row" "${DIST_SOURCES_DIR}/auxiliary/matrix_row"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/scalar" "${DIST_SOURCES_DIR}/auxiliary/scalar"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/vector" "${DIST_SOURCES_DIR}/auxiliary/vector"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/fft" "${DIST_SOURCES_DIR}/auxiliary/fft"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/svd" "${DIST_SOURCES_DIR}/auxiliary/svd"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/spai" "${DIST_SOURCES_DIR}/auxiliary/spai"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/nmf" "${DIST_SOURCES_DIR}/auxiliary/nmf"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/auxiliary/ilu" "${DIST_SOURCES_DIR}/auxiliary/ilu"
COMMAND "${CMAKE_COMMAND}" -E copy
"${PROJECT_SOURCE_DIR}/auxiliary/CMakeLists.txt" "${DIST_SOURCES_DIR}/auxiliary/CMakeLists.txt"
COMMAND "${CMAKE_COMMAND}" -E copy
"${PROJECT_SOURCE_DIR}/auxiliary/converter.cpp" "${DIST_SOURCES_DIR}/auxiliary/converter.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy
"${PROJECT_SOURCE_DIR}/auxiliary/generate-blas3-prod-align1.cpp" "${DIST_SOURCES_DIR}/auxiliary/generate-blas3-prod-align1.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy
"${PROJECT_SOURCE_DIR}/auxiliary/generate-blas3-prod16-align1.cpp" "${DIST_SOURCES_DIR}/auxiliary/generate-blas3-prod16-align1.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy
"${PROJECT_SOURCE_DIR}/auxiliary/generate-blas3-solve-align1.cpp" "${DIST_SOURCES_DIR}/auxiliary/generate-blas3-solve-align1.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/CL" "${DIST_SOURCES_DIR}/CL"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/examples" "${DIST_SOURCES_DIR}/examples"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DIST_SOURCES_DIR}/tests"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DIST_SOURCES_DIR}/tests/src"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/tests/src" "${DIST_SOURCES_DIR}/tests/src"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/tests/CMakeLists.txt" "${DIST_SOURCES_DIR}/tests/CMakeLists.txt"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/external" "${DIST_SOURCES_DIR}/external"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/doc/manual/figures" "${DIST_SOURCES_DIR}/doc/manual/figures"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/doc/Doxyfile.in" "${DIST_SOURCES_DIR}/doc/Doxyfile.in"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/doc/CMakeLists.txt" "${DIST_SOURCES_DIR}/doc/CMakeLists.txt"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/viennacl" "${DIST_SOURCES_DIR}/viennacl"
COMMAND "${CMAKE_COMMAND}" -E remove_directory
"${DIST_SOURCES_DIR}/viennacl/linalg/kernels"
# Create archive:
COMMAND "${CMAKE_COMMAND}" -E tar czf ViennaCL-${VERSION}-src.tar.gz
ViennaCL-${VERSION}-src
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/dist"
COMMENT "Generating dist/ViennaCL-${VERSION}-src.tar.gz"
VERBATIM)
add_dependencies(dist-src copymanual-src)
endif()