-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (40 loc) · 1.85 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
cmake_minimum_required(VERSION 3.1)
project(cl_rul LANGUAGES CXX)
enable_testing()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR})
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /MP /W3")
endif()
# OpenCL
find_package(OpenCL REQUIRED)
include_directories(${OpenCL_INCLUDE_DIRS})
link_directories(${OpenCL_LIBRARY})
# Library
add_library(cl_rect_update_lib INTERFACE)
target_include_directories(cl_rect_update_lib INTERFACE cl_rect_update_lib/)
target_link_libraries(cl_rect_update_lib INTERFACE ${OpenCL_LIBRARY})
if(MSVC) # Generate a project for editing the header-only interface library in the IDE
file(GLOB LIB_HEADER_FILES cl_rect_update_lib/*.h)
add_custom_target(cl_rect_update_lib.headers SOURCES ${LIB_HEADER_FILES})
endif()
# Unit tests
file(GLOB TEST_SRC_FILES cl_rect_update_test/*.cpp cl_rect_update_test/*.h)
add_executable(cl_rect_update_test cl_rect_update_test/cl_rect_update_test.cc ${TEST_SRC_FILES})
target_link_libraries(cl_rect_update_test cl_rect_update_lib)
add_test(cl_rect_update_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cl_rect_update_test)
# Benchmark
file(GLOB BENCH_SRC_FILES cl_rect_update_benchmark/*.cpp cl_rect_update_benchmark/*.h)
add_executable(cl_rect_update_benchmark ${BENCH_SRC_FILES})
target_link_libraries(cl_rect_update_benchmark cl_rect_update_lib)
add_custom_command(TARGET cl_rect_update_benchmark
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_SOURCE_DIR}/cl_rect_update_benchmark/cl_rect_update_benchmark.cl
${CMAKE_RUNTIME_OUTPUT_DIRECTORY})