-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathCMakeLists.txt
210 lines (169 loc) · 6.94 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
# Copyright (c) 2014 Martin Stumpf
# Copyright (c) 2015 Patrick Diehl
# Copyright (c) 2017 Madhavan Seshadri
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Require a minimum version of CMake
cmake_minimum_required(VERSION 3.3.2 FATAL_ERROR)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Configuration type (one of Debug, RelWithDebInfo, Release, MinSizeRel)")
endif()
# This project is C++ based.
project(hpxcl CXX)
# add our cmake path
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
if(HPX_ROOT)
set(HPX_DIR "${HPX_ROOT}/lib/cmake/HPX")
endif()
#add -std=gnu++11 to the debug flags
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -D_DEBUG -O0 -std=gnu++11" CACHE STRING)
endif()
endif()
#Set mixed target_libraries allowed
cmake_policy(SET CMP0023 OLD)
########################################################################
# Include hpx
# Instruct cmake to find the HPX settings
find_package(HPX REQUIRED)
if(NOT (HPX_BUILD_TYPE STREQUAL CMAKE_BUILD_TYPE))
message("HPX_BUILD_TYPE: " ${HPX_BUILD_TYPE} "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
message(FATAL_ERROR "Build types used for HPX and this library have to match")
endif()
# inherit varios setting from HPXConfig
set(CMAKE_DEBUG_POSTFIX ${HPX_DEBUG_POSTFIX})
# Adjust auxiliary build settings for HPX to work properly
if(NOT MSVC)
set(HPX_RPATH
"${PROJECT_BINARY_DIR}/lib/hpx:${HPX_RPATH}:${CMAKE_INSTALL_PREFIX}/lib/hpx")
else()
# enable solution folders for MSVC
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(HPX_NO_INSTALL)
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/$(Configuration)" CACHE PATH
"Prefix prepended to install directories." FORCE)
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${HPX_PREFIX}/../cmake/")
include_directories(${HPX_INCLUDE_DIR})
link_directories(${HPX_LIBRARY_DIR})
########################################################################
# enable resource precompiler
#
include(EmbedResources)
########################################################################
# configurations
hpx_option(HPXCL_BUILD_EXAMPLES BOOL "Build HPX examples (default: ON)" ON ADVANCED)
hpx_option(HPXCL_BUILD_TESTS BOOL "Build HPX tests (default: ON)" ON ADVANCED)
hpx_option(HPXCL_WITH_DOCUMENTATION BOOL "The HPX documentation toolchain is available (default OFF)." OFF)
hpx_option(HPXCL_WITH_OPENCL BOOL "Builds the OPENCL part of HPXCL (default ON)." OFF)
hpx_option(HPXCL_WITH_CUDA BOOL "Builds the CUDA part of HPXCL (default OFF)." OFF)
hpx_option(HPXCL_WITH_BENCHMARK BOOL "Builds the benchmark (default OFF)." OFF)
hpx_option(HPXCL_WITH_NAIVE_CUDA_BENCHMARK BOOL "Builds the naive CUDA benchmark (default OFF)." OFF)
hpx_option(HPXCL_CUDA_WITH_STREAM BOOL "Builds multiple stream version (default ON)." ON)
hpx_option(HPXCL_WITH_NAIVE_OPENCL_BENCHMARK BOOL "Builds the naive OPENCL benchmark (default OFF)." OFF)
hpx_option(HPXCL_BUILD_EXAMPLE_MANDELBROT BOOL "Build themandel brot example (defualt OFF)." OFF)
if(NOT HPXCL_WITH_OPENCL AND NOT HPXCL_WITH_CUDA)
message(FATAL_ERROR "At least one of HPXCL_WITH_OPENCL or HPXCL_WITH_CUDA has to be set to ON")
endif()
########################################################################
# further includes, depending on config
#
if(HPXCL_CUDA_WITH_STREAM)
add_definitions(-DHPXCL_CUDA_WITH_STREAMS=1)
endif()
if(HPXCL_WITH_OPENCL OR HPXCL_WITH_NAIVE_OPENCL_BENCHMARK)
find_package(OpenCL REQUIRED)
include_directories(${OPENCL_INCLUDE_DIRS})
#get_filename_component(PARENT_DIR ${OPENCL_LIBRARIES} OPENCL_LIBRARY_DIR)
link_directories(${OPENCL_LIBRARY_DIR})
endif()
if(HPXCL_WITH_CUDA)
find_package(CUDA 7.0 REQUIRED)
find_package(NVRTC 7.0 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
endif()
# Only search for PNG lib, if HPXCL_BUILD_EXAMPLES is build
if(HPXCL_BUILD_EXAMPLE_MANDELBROT)
find_package(PNG)
if(PNG_FOUND)
include_directories(${PNG_INCLUDE_DIRS})
endif()
endif()
if(MSVC)
hpx_add_compile_flag(-Ox CONFIGURATIONS Release LANGUAGES CXX C)
hpx_add_compile_flag(-RTC1 CONFIGURATIONS Debug LANGUAGES CXX C)
# VS2012 and above has a special flag for improving the debug experience by
# adding more symbol information to the build (-d2Zi)
hpx_add_compile_flag(-d2Zi+ CONFIGURATIONS RelWithDebInfo)
# VS2013 and above know how to do link time constant data segment folding
# VS2013 update 2 and above know how to remove debug information for
# non-referenced functions and data (-Zc:inline)
if(MSVC12 OR MSVC14)
hpx_add_compile_flag(-Zc:inline)
hpx_add_compile_flag(-Gw CONFIGURATIONS Release RelWithDebInfo MinSizeRelease)
hpx_add_compile_flag(-Zo CONFIGURATIONS RelWithDebInfo)
endif()
if(MSVC14)
# assume conforming (throwing) operator new implementations
hpx_add_target_compile_option(-Zc:throwingNew)
# enable faster linking (requires VS2015 Update1)
# disabled for now as this flag crashes debugger
# hpx_remove_link_flag(/debug CONFIGURATIONS Debug)
# hpx_add_link_flag(/debug:fastlink CONFIGURATIONS Debug)
endif()
hpx_add_compile_flag(-EHsc) # Exceptions
hpx_add_compile_flag(-GR) # Runtime type information
hpx_add_compile_flag(-MP) # Multiprocessor build
hpx_add_compile_flag(-bigobj) # Increase the maximum size of object file sections
endif()
#########################
# Builds
#
# build opencl
if(HPXCL_WITH_OPENCL)
add_subdirectory(opencl)
endif()
# build cuda
if(HPXCL_WITH_CUDA)
add_subdirectory(cuda)
endif()
include_directories(${PROJECT_SOURCE_DIR})
if(HPXCL_BUILD_EXAMPLES)
add_hpx_pseudo_target(examples)
include_directories(examples)
add_subdirectory(examples)
endif()
if(HPXCL_WITH_DOCUMENTATION)
include(HPX_Documentation)
hpx_option(HPX_BUILD_DOCUMENTATION_SINGLEPAGE BOOL
"The HPX documentation should be build as a single page HTML (default OFF)." OFF)
add_subdirectory(docs)
endif()
if(HPXCL_WITH_BENCHMARK)
add_hpx_pseudo_target(benchmark)
include_directories(benchmark)
add_subdirectory(benchmark)
endif()
###############################################################################
if(HPXCL_BUILD_TESTS)
hpx_option(HPXCL_BUILD_TESTS_BENCHMARKS BOOL "Build HPX benchmark tests (default: ON)" ON ADVANCED)
hpx_option(HPXCL_BUILD_TESTS_REGRESSIONS BOOL "Build HPX regression tests (default: ON)" ON ADVANCED)
hpx_option(HPXCL_BUILD_TESTS_UNIT BOOL "Build HPX unit tests (default: ON)" ON ADVANCED)
add_hpx_pseudo_target(tests)
enable_testing()
include(CTest)
if(HPX_WITH_PSEUDO_DEPENDENCIES)
add_custom_command(TARGET tests POST_BUILD
COMMAND ctest --output-on-failure)
endif()
include_directories(tests)
add_subdirectory(tests)
else()
unset(HPXCL_BUILD_TESTS_BENCHMARKS CACHE)
unset(HPXCL_BUILD_TESTS_REGRESSIONS CACHE)
unset(HPXCL_BUILD_TESTS_UNIT CACHE)
endif()