-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
63 lines (53 loc) · 2.2 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
cmake_minimum_required(VERSION 3.1)
project(Chlorine)
# Set Compiler Flags
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -std=c++1y")
endif()
# Enable Coverage on Travis Tests
if(DEFINED ENV{TRAVIS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
find_package(Doxygen)
find_package(OpenCL REQUIRED)
include_directories(chlorine/include ${OpenCL_INCLUDE_DIR})
file(GLOB PROJECT_HEADERS chlorine/include/*.hpp)
file(GLOB PROJECT_SOURCES chlorine/src/*.cpp)
file(GLOB PROJECT_CONFIGS readme.md
.gitattributes
.gitignore
.gitmodules)
source_group("Headers" FILES ${PROJECT_HEADERS})
source_group("Sources" FILES ${PROJECT_SOURCES})
# Build the Chlorine CLI
add_executable(chlorine ${PROJECT_HEADERS} ${PROJECT_SOURCES} ${PROJECT_CONFIGS})
target_link_libraries(chlorine ${OpenCL_LIBRARY})
# Build the clinfo Helper
add_executable(clinfo chlorine/include/cl.hpp chlorine/clinfo/clinfo.cpp)
target_link_libraries(clinfo ${OpenCL_LIBRARY})
# Build the Test Suite
include_directories(tests tests/catch/include)
file(GLOB TEST_KERNELS tests/**/*.cl)
source_group("Kernels" FILES ${TEST_KERNELS})
add_executable(tests EXCLUDE_FROM_ALL tests/test_suite.hpp tests/test_main.cpp ${TEST_KERNELS})
target_link_libraries(tests ${OpenCL_LIBRARY})
add_custom_command(TARGET tests PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/tests/kernels/
$<TARGET_FILE_DIR:tests>/kernels/)
# Workaround for Reserved CMAKE Keyword: test
add_custom_target(check COMMAND tests --reporter compact DEPENDS tests)
# Build the Examples
add_subdirectory(examples/swap EXCLUDE_FROM_ALL)
add_subdirectory(examples/mandelbrot EXCLUDE_FROM_ALL)
# Build the Documentation
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/.doxyfile
${CMAKE_CURRENT_BINARY_DIR}/.doxyfile @ONLY)
add_custom_target(doc ${DOXYGEN_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/.doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif(DOXYGEN_FOUND)