forked from vpa1977/viennacl-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
executable file
·254 lines (190 loc) · 8.93 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
# Project setup
###############
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
project(ViennaCL)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 7)
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")
# Add visibility of headers
# Necessary for Qt-Creator usage.
################
file( GLOB_RECURSE MAKE_HEADERS_VISIBLE_SRC
*.hpp *.h)
add_custom_target( MAKE_HEADERS_VISIBLE SOURCES ${MAKE_HEADERS_VISIBLE_SRC} )
# 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)
cmake_dependent_option(ENABLE_DIST "Enable the the distribution tarball target" ON "BUILD_DOXYGEN_DOCS" OFF)
mark_as_advanced(BUILD_DOXYGEN_DOCS ENABLE_DIST)
# Find prerequisites
####################
if(BUILD_DOXYGEN_DOCS)
find_package(Doxygen REQUIRED)
endif()
# Compile options
#################
include_directories(BEFORE "${PROJECT_SOURCE_DIR}")
# Subdirectories
################
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_TESTING)
INCLUDE(CTest)
add_subdirectory(tests)
endif()
add_subdirectory(doc)
add_subdirectory(libviennacl)
# 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}/cmake/README.txt" "${DISTDIR}/build/README.txt"
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/AddCCompilerFlagIfSupported.cmake" "${DISTDIR}/cmake/AddCCompilerFlagIfSupported.cmake"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${PROJECT_SOURCE_DIR}/cmake/AddCLinkerFlagIfSupported.cmake" "${DISTDIR}/cmake/AddCLinkerFlagIfSupported.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/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_directory
"${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen/html"
"${DISTDIR}/doc/html"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/doc/manual/figures"
"${DISTDIR}/doc/html"
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}/libviennacl" "${DISTDIR}/libviennacl"
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)
#
# Sources only (no generated files):
#
foreach(f LICENSE
README
changelog
cmake/AddCCompilerFlagIfSupported.cmake
cmake/AddCLinkerFlagIfSupported.cmake
cmake/copymanual.cmake
cmake/FindMTL.cmake
cmake/FindOpenCL.cmake
cmake/ViennaCLCommon.cmake
cmake/ViennaCLConfig.cmake.in
cmake/ViennaCLConfigVersion.cmake.in
cmake/README.txt)
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}/CL" "${DIST_SOURCES_DIR}/CL"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/examples" "${DIST_SOURCES_DIR}/examples"
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/libviennacl" "${DIST_SOURCES_DIR}/libviennacl"
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/doxyfilter.py" "${DIST_SOURCES_DIR}/doc/doxyfilter.py"
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"
# 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()