forked from ddemidov/vexcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
160 lines (133 loc) · 5.73 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
cmake_minimum_required(VERSION 2.8)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to RelWithDebInfo")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type")
endif()
project(VexCL)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (CMAKE_VERSION VERSION_LESS "3.1.0")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/opencl)
endif()
include_directories( "${PROJECT_SOURCE_DIR}" )
#----------------------------------------------------------------------------
# Compile-time options
#----------------------------------------------------------------------------
option(VEXCL_SHOW_KERNELS "Show generated kernels in tests and examples")
if (VEXCL_SHOW_KERNELS)
add_definitions(-DVEXCL_SHOW_KERNELS)
endif ()
option(VEXCL_CACHE_KERNELS "Cache compiled kernels offline" ON)
if (VEXCL_CACHE_KERNELS)
add_definitions(-DVEXCL_CACHE_KERNELS)
endif ()
option(VEXCL_SHOW_COPIES "Log vector copies to stdout for debugging purposes")
if (VEXCL_SHOW_COPIES)
add_definitions(-DVEXCL_SHOW_COPIES)
endif ()
set(VEXCL_CHECK_SIZES 2 CACHE STRING "Check that expressions have correct sizes")
add_definitions(-DVEXCL_CHECK_SIZES=${VEXCL_CHECK_SIZES})
option(BOOST_TEST_DYN_LINK "Link tests against dynamic version of boost unittest library" ON)
#----------------------------------------------------------------------------
# Interoperation with Boost.compute
#----------------------------------------------------------------------------
option(BOOST_COMPUTE "Use Boost.Compute algorithms" OFF)
function(find_boost_compute)
find_path(BOOST_COMPUTE_INCLUDE boost/compute.hpp)
include_directories(${BOOST_COMPUTE_INCLUDE})
endfunction()
if (BOOST_COMPUTE)
find_boost_compute()
add_definitions(-DHAVE_BOOST_COMPUTE)
endif ()
#----------------------------------------------------------------------------
# Interoperation with clogs
#----------------------------------------------------------------------------
option(CLOGS "Use clogs algorithms" OFF)
if (CLOGS)
find_path(CLOGS_INCLUDE clogs/clogs.h)
find_library(CLOGS_LIB clogs)
include_directories(${CLOGS_INCLUDE})
add_definitions(-DHAVE_CLOGS)
endif ()
#----------------------------------------------------------------------------
# Find Boost
#----------------------------------------------------------------------------
if (WIN32)
set(Boost_USE_STATIC_LIBS ON)
else ()
if (BOOST_TEST_DYN_LINK)
add_definitions(-DBOOST_TEST_DYN_LINK)
endif ()
endif ()
set(VEXCL_BOOST_COMPONENTS
date_time
filesystem
system
thread
unit_test_framework
program_options
CACHE STRING "Boost components required by VexCL.")
if (MSVC)
set(VEXCL_BOOST_COMPONENTS ${VEXCL_BOOST_COMPONENTS} chrono)
endif ()
find_package(Boost REQUIRED COMPONENTS ${VEXCL_BOOST_COMPONENTS})
include_directories( ${Boost_INCLUDE_DIRS} )
#----------------------------------------------------------------------------
# Protect Visual Studio from itself
#----------------------------------------------------------------------------
if (WIN32)
add_definitions(-DNOMINMAX)
add_definitions(-D_VARIADIC_MAX=10)
add_definitions(/bigobj)
add_definitions(/wd4996) # Deprecated declarations in CL/cl.hpp
add_definitions(/wd4003) # Not enough actual parameters for a BOOST_PP macro
endif ()
set(VEXCL_BACKEND "OpenCL" CACHE STRING "Select VexCL backend (OpenCL/CUDA)")
set_property(CACHE VEXCL_BACKEND PROPERTY STRINGS "OpenCL" "CUDA" "Compute")
#----------------------------------------------------------------------------
# Find Backend
#----------------------------------------------------------------------------
if ("${VEXCL_BACKEND}" STREQUAL "OpenCL")
find_package(OpenCL REQUIRED)
include_directories( ${OpenCL_INCLUDE_DIRS} )
set(BACKEND_LIBS ${OpenCL_LIBRARIES})
add_definitions(-DVEXCL_BACKEND_OPENCL)
elseif ("${VEXCL_BACKEND}" STREQUAL "Compute")
find_boost_compute()
find_package(OpenCL REQUIRED)
include_directories( ${OpenCL_INCLUDE_DIRS} )
set(BACKEND_LIBS ${OpenCL_LIBRARIES})
add_definitions(-DVEXCL_BACKEND_COMPUTE)
elseif ("${VEXCL_BACKEND}" STREQUAL "CUDA")
find_package(CUDA REQUIRED)
include_directories( ${CUDA_INCLUDE_DIRS} )
set(BACKEND_LIBS ${CUDA_CUDA_LIBRARY})
add_definitions(-DVEXCL_BACKEND_CUDA)
endif()
#----------------------------------------------------------------------------
# Find OpenMP
#----------------------------------------------------------------------------
find_package(OpenMP)
if (OpenMP_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()
#----------------------------------------------------------------------------
# Enable C++11 support, set compilation flags
#----------------------------------------------------------------------------
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wclobbered -Wempty-body -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wno-comment -Wno-type-limits -Wno-strict-aliasing -Wno-missing-braces -Wno-deprecated-declarations")
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wempty-body -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wno-comment -Wno-tautological-compare -Wno-missing-braces -Wno-deprecated-declarations")
option(USE_LIBCPP "Use libc++ with Clang" OFF)
if (USE_LIBCPP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
endif ()
#----------------------------------------------------------------------------
enable_testing()
add_subdirectory(tests)
add_subdirectory(examples)
add_subdirectory(doc)
add_subdirectory(cmake)
install(DIRECTORY vexcl DESTINATION include)