-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
52 lines (42 loc) · 1.38 KB
/
CMakeLists.txt
File metadata and controls
52 lines (42 loc) · 1.38 KB
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
cmake_minimum_required(VERSION 3.24)
project(cuda_image_filter LANGUAGES CXX CUDA)
# Require CUDA 12.0+
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
# Target GPU architectures
# RTX 4070 SUPER is compute capability 8.9 (Ada). You can add others if needed.
set(CMAKE_CUDA_ARCHITECTURES 89)
# Warnings & optimization
if (MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wno-unknown-pragmas)
endif()
set(SRC src/image_filter.cu)
add_executable(image_filter ${SRC})
# Enable separable compilation for larger projects
set_target_properties(image_filter PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON
)
# Optimize
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# ---- CTest setup ----
include(CTest) # safe even if BUILD_TESTING is off; defines BUILD_TESTING
if (BUILD_TESTING)
enable_testing()
# Run the program; test passes if exit code == 0
add_test(NAME image_filter_run COMMAND image_filter)
# (Optional) Fail if output doesn't contain "OK"
set_tests_properties(image_filter_run
PROPERTIES
PASS_REGULAR_EXPRESSION "OK|Success|Passed" # adjust to your program's output
TIMEOUT 10
)
# (Optional) pick a GPU if you have multiple
# set_tests_properties(image_filter_run PROPERTIES ENVIRONMENT "CUDA_VISIBLE_DEVICES=0")
endif()