-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
62 lines (46 loc) · 1.66 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
cmake_minimum_required(VERSION 3.20)
project(Fractal)
set(EXECUTABLE "fractal")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
find_package(SFML 2.5 COMPONENTS system window graphics REQUIRED)
include_directories(include)
file(GLOB_RECURSE CPP_SOURCES "src/*.cpp")
file(GLOB_RECURSE CUDA_SOURCES "src/*.cu")
include(CheckLanguage)
check_language(CUDA)
# set(CMAKE_CUDA_COMPILER OFF)
# Check if CUDA is available on the current platform
if(CMAKE_CUDA_COMPILER AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
enable_language(CUDA)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED True)
endif()
add_executable(${EXECUTABLE} ${CPP_SOURCES} ${CUDA_SOURCES})
set_target_properties(${EXECUTABLE}
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_ARCHITECTURES native
)
add_definitions(-DCUDA_AVAILABLE)
else()
if (CMAKE_CUDA_COMPILER)
message(STATUS "Cmake minimum version required for CUDA support is 3.24.")
message(STATUS "CMake version: ${CMAKE_VERSION}")
message(STATUS "Compiling without CUDA support.")
else()
message(STATUS "CUDA not found. Compiling without CUDA support.")
endif()
add_executable(${EXECUTABLE} ${CPP_SOURCES})
endif()
target_link_libraries(${EXECUTABLE} PRIVATE sfml-system sfml-window sfml-graphics)
target_compile_options(${EXECUTABLE} PRIVATE
$<$<CONFIG:Release>:-O3>
$<$<CONFIG:Debug>:-g3>
)
set_target_properties(${EXECUTABLE}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../release
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../debug
)