-
Notifications
You must be signed in to change notification settings - Fork 41
/
CMakeLists.txt
141 lines (117 loc) · 4.64 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# If no backend is selected, choose OpenCL as default.
IF(NOT AURA_BASE)
SET(AURA_BASE OPENCL)
ENDIF()
# Set unit test device id.
IF(NOT AURA_UNIT_TEST_DEVICE)
SET(AURA_UNIT_TEST_DEVICE 0)
ENDIF()
ADD_DEFINITIONS(-DAURA_UNIT_TEST_DEVICE=${AURA_UNIT_TEST_DEVICE})
# Make additional modules available and source custom functions.
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/buildprocess/")
# Find Boost libraries.
OPTION(BOOST_TEST_DYN_LINK
"Link tests against dynamic version of boost unittest library" ON)
IF (WIN32)
SET(Boost_USE_STATIC_LIBS ON)
ELSE ()
IF (BOOST_TEST_DYN_LINK)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
ELSE ()
set(Boost_USE_STATIC_LIBS ON)
ENDIF ()
ENDIF()
FIND_PACKAGE(Boost COMPONENTS system thread filesystem unit_test_framework regex python)
# Find GPU libraries.
FIND_PACKAGE(CUDA)
FIND_PACKAGE(OpenCL)
# Find apple specific libraries.
IF (APPLE)
FIND_LIBRARY(FOUNDATION_LIB Foundation)
IF (NOT FOUNDATION_LIB)
MESSAGE(FATAL_ERROR "Foundation not found.")
ENDIF()
ENDIF()
# Set correct defines for GPU libraries.
IF (${AURA_BASE} STREQUAL CUDA)
FIND_CUDA_HELPER_LIBS(nvrtc)
SET(AURA_BASE_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_nvrtc_LIBRARY})
SET(AURA_BASE_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
IF (APPLE)
SET(AURA_BASE_LINK_DIRS "/usr/local/cuda/lib")
SET(AURA_BASE_LIBRARIES ${AURA_BASE_LIBRARIES}
"cuda")
ENDIF()
SET(AURA_BASE_DEFINE "-DAURA_BASE_CUDA")
ELSEIF (${AURA_BASE} STREQUAL METAL)
IF(NOT APPLE)
MESSAGE(FATAL_ERROR "Metal only supported on Apple platform.")
ENDIF()
SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}
"-framework Metal -w")
SET(AURA_BASE_INCLUDE_DIRS ".")
SET(AURA_BASE_DEFINE "-DAURA_BASE_METAL")
ELSEIF (${AURA_BASE} STREQUAL OPENCL)
SET(AURA_BASE_LIBRARIES ${OPENCL_LIBRARIES})
SET(AURA_BASE_INCLUDE_DIRS ${OPENCL_INCLUDE_DIRS})
SET(AURA_BASE_DEFINE "-DAURA_BASE_OPENCL")
ELSE()
MESSAGE(FATAL_ERROR "${AURA_BASE} is not a supported Aura base.")
ENDIF()
ADD_DEFINITIONS(${AURA_BASE_DEFINE})
# Compiler and linker flags
ADD_COMPILE_OPTIONS(-std=c++0x -g -O3)
IF (WIN32)
ADD_COMPILE_OPTIONS(/EHsc)
ADD_COMPILE_OPTIONS(/WX)
ELSE()
# Prevent VS from spewing lots of warnings.
ADD_COMPILE_OPTIONS(-Wall)
ADD_COMPILE_OPTIONS(-Werror)
ENDIF()
# Set global include directories for project.
INCLUDE_DIRECTORIES("${AURA_BASE_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/include/")
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}/")
# Set global link directories for project.
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${AURA_BASE_LINK_DIRS})
# Enable testing.
ENABLE_TESTING()
ADD_DEFINITIONS(-DAURA_TEST_SOURCE_DIR="${CMAKE_SOURCE_DIR}/test")
# Add subdirectories.
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/test/)
# WIP
IF (${BUILD_PYTHON})
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/python/)
ENDIF()
# Documentation
IF (${BUILD_DOCUMENTATION})
FIND_PACKAGE(Doxygen)
IF (DOXYGEN_FOUND)
# Build doxygen XML.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
ADD_CUSTOM_TARGET(doxygen
${DOXYGEN_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
# Run sphinx (with breathe).
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/source/conf.py.in
${CMAKE_CURRENT_BINARY_DIR}/conf.py
@ONLY)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/html
COMMAND sphinx-build -b html -c .
${CMAKE_CURRENT_SOURCE_DIR}/doc/source
${CMAKE_CURRENT_BINARY_DIR}/doc/html
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
# Make a target that builds all of the above.
ADD_CUSTOM_TARGET(sphinx
ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/html)
ADD_CUSTOM_TARGET(doc)
ADD_DEPENDENCIES(doc doxygen sphinx)
ENDIF(DOXYGEN_FOUND)
ENDIF()