-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
239 lines (204 loc) · 9.31 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
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_MACOSX_RPATH 1) # suppress warning about MACOSX_RPATH
# We need this before 'project(BOHRIUM)' since cmake defines CMAKE_BUILD_TYPE at project()
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are:
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used), Debug, Release, RelWithDebInfo, and MinSizeRel.")
else()
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are:
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used), Debug, Release, RelWithDebInfo, and MinSizeRel.")
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# Everyting else should come after 'project(BOHRIUM)' since 'project()' defines many of the CMAKE_BUILD_* vars
project(BOHRIUM C CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") # Shared modules
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)
include(FeatureSummary)
include(LibVsLib64) # Sets LIBDIR
# Write all compile commands to 'compile_commands.json', which can be used by YouCompleteMe
# and other auto-completion software
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
# For the Clion IDE
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # .local is default
set (CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "The install prefix (default path is ~/.local)" FORCE)
endif()
####################################
# Default compile-flags for Bohrium
check_c_compiler_flag(-pedantic HAS_C_PEDANTIC) # C Flags
if (HAS_C_PEDANTIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic ")
endif()
check_c_compiler_flag(-Wall HAS_C_WALL)
if (HAS_C_WALL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall ")
endif()
########################################
# C99 for restrict, for(var name=0;...)
# gnu99 for MAP_ANONYMOUS
check_c_compiler_flag(-std=gnu99 HAS_GCC_GNU99)
if (HAS_GCC_GNU99)
set(C99_FLAG "${C99_FLAG} -std=gnu99 ")
else()
check_c_compiler_flag(-std=c99 HAS_GCC_C99)
if (HAS_GCC_C99)
set(C99_FLAG "${C99_FLAG} -std=c99 ")
else()
check_c_compiler_flag(-c99 HAS_PGI_C99)
if (HAS_PGI_C99)
set(C99_FLAG "${C99_FLAG} -c99 ")
endif()
endif()
endif()
if (HAS_GCC_GNU99 OR HAS_GCC_C99 OR HAS_PGI_C99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C99_FLAG}")
endif()
check_cxx_compiler_flag(-Wall HAS_CXX_PEDANTIC) # C++ Flags
if (HAS_CXX_PEDANTIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic ")
endif()
check_cxx_compiler_flag(-Wall HAS_CXX_WALL)
if (HAS_CXX_WALL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ")
endif()
check_cxx_compiler_flag(-std=gnu++0x HAS_CXX_GNU0X) # Sigh...
if (HAS_CXX_GNU0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x ")
else()
check_cxx_compiler_flag(-std=c++11 HAS_CXX_CXX11)
if(HAS_CXX_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
endif()
endif()
###################
# Warning as error
set(USE_WERROR OFF CACHE BOOL "Use the -Werror flag if supported")
if (USE_WERROR)
check_c_compiler_flag(-Werror HAS_C_WERROR)
if (HAS_C_WERROR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
check_cxx_compiler_flag(-Werror HAS_CXX_WERROR)
if (HAS_CXX_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif()
# Let's get the BH_VERSION_MAJOR, _MINOR, and _PATCH variables
include(GetVersion)
########################
# External dependencies
find_package(PythonInterp) # Used for autogen
set_package_properties(PythonInterp PROPERTIES DESCRIPTION "Python Programming Language" URL "www.python.org")
set_package_properties(PythonInterp PROPERTIES TYPE REQUIRED PURPOSE "Python is required to build Bohrium")
message(STATUS "Python found: ${PYTHON_EXECUTABLE}")
find_package(Boost REQUIRED COMPONENTS serialization filesystem system regex) # Everything
set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ source libraries" URL "www.boost.org")
set_package_properties(Boost PROPERTIES TYPE REQUIRED PURPOSE "Boost is required to build Bohrium")
include_directories(${Boost_INCLUDE_DIRS})
# For older versions of Boost, we need this macro defined:
add_definitions(-DBOOST_NO_CXX11_SCOPED_ENUMS)
find_package(LibSigSegv REQUIRED) # Everything
set_package_properties(LibSigSegv PROPERTIES DESCRIPTION "GNU libsigsegv" URL "www.gnu.org/software/libsigsegv/")
set_package_properties(LibSigSegv PROPERTIES TYPE REQUIRED PURPOSE "libsigsegv is required to build Bohrium")
include_directories(${LIBSIGSEGV_INCLUDE_DIR})
find_package(OpenCV 3)
set_package_properties(OpenCV PROPERTIES DESCRIPTION "Open Source Computer Vision" URL "opencv.org")
set_package_properties(OpenCV PROPERTIES TYPE RECOMMENDED PURPOSE "Enables the OpenCV extended method")
# We do not want MacOSX to set "@path" when installing because of the MacOSX wheel tool `delocate`.
# Instead, we set the installation path manually.
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIBDIR})
#####################
# Bohrium components
set(BH_OPENMP_LIBS "")
set(BH_OPENCL_LIBS "")
add_subdirectory(core)
add_subdirectory(vem/node)
add_subdirectory(vem/proxy)
add_subdirectory(ve/openmp)
add_subdirectory(ve/opencl)
add_subdirectory(ve/cuda)
add_subdirectory(filter/pprint)
add_subdirectory(filter/bccon)
add_subdirectory(filter/bcexp)
add_subdirectory(filter/noneremover)
add_subdirectory(extmethods/blas)
add_subdirectory(extmethods/clblas)
add_subdirectory(extmethods/visualizer)
add_subdirectory(extmethods/lapack)
add_subdirectory(extmethods/opencv)
add_subdirectory(bridge/cxx)
add_subdirectory(bridge/c)
add_subdirectory(bridge/py_api)
add_subdirectory(bridge/npbackend)
add_subdirectory(bridge/bh107)
add_subdirectory(test)
string(REPLACE ";" ", " BH_OPENMP_LIBS "${BH_OPENMP_LIBS}")
string(REPLACE ";" ", " BH_OPENCL_LIBS "${BH_OPENCL_LIBS}")
#############################
# Install thirdparty headers
install(DIRECTORY thirdparty/Random123-1.09/include/Random123
DESTINATION share/bohrium/include COMPONENT bohrium)
#########################################
# Install JIT-kernels dependency headers
install(DIRECTORY include/bohrium/jitk/kernel_dependencies
DESTINATION share/bohrium/include COMPONENT bohrium)
###############
# Bohrium Cache
set(BIN_KERNEL_CACHE_DIR ${CMAKE_INSTALL_PREFIX}/var/bohrium/cache CACHE PATH
"Path to the directory of the persistent JIT kernel cache")
# When using the default cache location, we will install the cache dir and set permissions to 777.
if ("${BIN_KERNEL_CACHE_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/var/bohrium/cache")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cache)
install(DIRECTORY ${CMAKE_BINARY_DIR}/cache DESTINATION var/bohrium DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_WRITE WORLD_READ WORLD_EXECUTE
COMPONENT bohrium)
endif()
#############################
# Bohrium configuration file
configure_file(${CMAKE_SOURCE_DIR}/config.ini.in ${CMAKE_BINARY_DIR}/config.ini) # Fill out the config-template
set(FORCE_CONFIG_PATH "OFF" CACHE STRING "Manually setting the install path of the config (ini) file")
string(REGEX MATCH "^$ENV{HOME}" ROOT_INSTALL ${CMAKE_INSTALL_PREFIX})
if ("${FORCE_CONFIG_PATH}" STREQUAL "OFF")
if ("${ROOT_INSTALL}" STREQUAL "")
install(FILES ${CMAKE_BINARY_DIR}/config.ini DESTINATION etc/bohrium COMPONENT bohrium)
else()
install(CODE "
if(NOT EXISTS \"\$ENV{HOME}/.bohrium/config.ini\")
configure_file(${CMAKE_BINARY_DIR}/config.ini \"\$ENV{HOME}/.bohrium/config.ini\" COPYONLY)
endif()
" COMPONENT bohrium)
endif()
else()
install(FILES ${CMAKE_BINARY_DIR}/config.ini DESTINATION ${FORCE_CONFIG_PATH} COMPONENT bohrium)
endif()
find_package(Jupyter)
if(JUPYTER_FOUND)
if ("${ROOT_INSTALL}" STREQUAL "")
message(STATUS "Can't install IPython magic commands globally.")
else()
install(CODE "
if(NOT EXISTS \"\$ENV{HOME}/.ipython/profile_default/startup/50-bohrium.py\")
configure_file(${CMAKE_SOURCE_DIR}/ipython-magic.py \"\$ENV{HOME}/.ipython/profile_default/startup/50-bohrium.py\" COPYONLY)
endif()
" COMPONENT bohrium)
endif()
endif()
MESSAGE(STATUS "")
MESSAGE(STATUS "+---------------------------------------------------------+")
MESSAGE(STATUS "| SUMMARY |")
MESSAGE(STATUS "+---------------------------------------------------------+")
MESSAGE(STATUS "C compiler:" ${CMAKE_C_COMPILER})
MESSAGE(STATUS "C compile flags:" ${CMAKE_C_COMPILE_FLAGS})
MESSAGE(STATUS "C debug flags:" ${CMAKE_C_FLAGS_DEBUG})
MESSAGE(STATUS "C release flags:" ${CMAKE_C_FLAGS_RELEASE})
MESSAGE(STATUS "C min size flags:" ${CMAKE_C_FLAGS_MINSIZEREL})
MESSAGE(STATUS "CXX compiler:" ${CMAKE_CXX_COMPILER})
MESSAGE(STATUS "CXX compile flags:" ${CMAKE_CXX_COMPILE_FLAGS})
MESSAGE(STATUS "CXX debug flags:" ${CMAKE_CXX_FLAGS_DEBUG})
MESSAGE(STATUS "CXX release flags:" ${CMAKE_CXX_FLAGS_RELEASE})
MESSAGE(STATUS "CXX min size flags:" ${CMAKE_CXX_FLAGS_MINSIZEREL})
MESSAGE(STATUS "CXX flags:" ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS "+---------------------------------------------------------+")
MESSAGE(STATUS "")
feature_summary(WHAT ALL)