-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
82 lines (70 loc) · 2.05 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
cmake_minimum_required(VERSION 3.14 FATAL_ERROR) # Set the minimum required version of CMake
project(kiwicpp VERSION 1.0.0 LANGUAGES CXX)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Check for CUDA
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
set(CMAKE_CUDA_STANDARD 14)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_CUDA)
set(CUDA_FOUND TRUE)
message(STATUS "CUDA found. Building with CUDA support.")
else()
set(CUDA_FOUND FALSE)
message(STATUS "CUDA not found. Checking for Apple Metal support.")
endif()
# Check for Apple Metal (only if CUDA is not found)
if(NOT CUDA_FOUND AND APPLE)
# Set the SDK path
# find_library(METAL_LIBRARY Metal)
# find_library(FOUNDATION_LIBRARY Foundation)
# if(METAL_LIBRARY AND FOUNDATION_LIBRARY)
# set(METAL_FOUND TRUE)
# target_compile_definitions(${PROJECT_NAME} PRIVATE USE_METAL)
# message(STATUS "Apple Metal found. Building with Metal support.")
# else()
# message(WARNING "Neither CUDA nor Apple Metal found. Building without GPU acceleration.")
# endif()
endif()
# Library target
add_library(
${PROJECT_NAME}
INTERFACE
)
target_include_directories(
${PROJECT_NAME}
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
# Optional builds
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_TESTS "Build tests" ON)
option(BENCHMARK "Build with benchmark mode" OFF)
# Benchmark mode
if(BENCHMARK)
target_compile_definitions(${PROJECT_NAME} PRIVATE BENCHMARK_MODE)
endif()
# Examples
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Tests
if(BUILD_TESTS)
# Fetch GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG "v1.15.2"
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(tests)
endif()