forked from PhDP/cuda-cmake-gtest-gbench-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (58 loc) · 2.23 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
cmake_minimum_required(VERSION 3.18)
project(deepgreen
DESCRIPTION "Simple template for C++/CUDA projects."
HOMEPAGE_URL "https://github.com/PhDP/cuda-cmake-gtest-gbench-starter"
LANGUAGES C CXX CUDA
)
# Set build type to RELEASE by default:
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type provided, default to RELEASE.")
set(CMAKE_BUILD_TYPE "RELEASE")
endif ()
option(DG_TEST "Enables testing with Google Test." ON)
option(DG_BENCH "Enables benchmarking with Google Benchmark." ON)
option(DG_STATIC "Builds a static library instead of a shared one." OFF)
option(DG_SANITIZE "Adds sanitize flags." OFF)
if (DG_STATIC)
set(DG_LIB_NAME deepgreen_static)
set(DG_LIB_TYPE STATIC)
else ()
set(DG_LIB_NAME deepgreen)
set(DG_LIB_TYPE SHARED)
endif ()
include(FetchContent)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(CUDAToolkit REQUIRED)
find_package(Threads REQUIRED)
find_package(Boost)
find_package(MATH)
include_directories(. include ${Boost_INCLUDE_DIRS} ${CUDAToolkit_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (DG_SANITIZE)
set(CMAKE_CXX_FLAGS "-fsanitize=address -fsanitize=undefined ${CMAKE_CXX_FLAGS}")
endif ()
add_subdirectory(src)
if (DG_TEST)
enable_testing()
add_subdirectory(test)
endif ()
if (DG_BENCH)
add_subdirectory(bench)
endif ()
message(STATUS "")
message(STATUS "BUILD SUMMARY")
message(STATUS " CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
message(STATUS " Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Library name : ${DG_LIB_NAME}")
message(STATUS " Library type : ${DG_LIB_TYPE}")
message(STATUS " CUDA : ${CUDAToolkit_VERSION}")
message(STATUS " CUDA include dirs : ${CUDAToolkit_INCLUDE_DIRS}")
message(STATUS " CUDA library dir : ${CUDAToolkit_LIBRARY_DIR}")
message(STATUS " Boost include dirs : ${Boost_INCLUDE_DIRS}")
message(STATUS " Boost version : ${Boost_VERSION}")
message(STATUS " Build tests : ${DG_TEST}")
message(STATUS " Build benchmarks : ${DG_BENCH}")
message(STATUS " Add sanitize flags : ${DG_SANITIZE}")
message(STATUS "")