-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (59 loc) · 1.98 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
cmake_minimum_required(VERSION 3.18)
# Project name and version
project(GeodesicSim LANGUAGES CXX)
# Option to enable CUDA support
option(USE_CUDA "Enable CUDA support" OFF)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Include directories
include_directories(${CMAKE_SOURCE_DIR}/include)
# Common source files
set(SOURCES_COMMON
src/file_io.cpp
src/run_timestep_sim.cpp
src/run_realtime_sim.cpp
src/cpu_sim.cpp
)
# Handle CUDA support
if (USE_CUDA)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
list(APPEND SOURCES_COMMON src/cuda_sim.cu)
endif()
# Timestep executable
if (USE_CUDA)
add_executable(timestep_sim_gpu main/timestep_main.cpp ${SOURCES_COMMON})
target_compile_definitions(timestep_sim_gpu PRIVATE USE_CUDA=1)
target_link_libraries(timestep_sim_gpu CUDA::cudart)
set_target_properties(timestep_sim_gpu PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
else()
add_executable(timestep_sim main/timestep_main.cpp ${SOURCES_COMMON})
target_compile_definitions(timestep_sim PRIVATE USE_CUDA=0)
set_target_properties(timestep_sim PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endif()
# Runtime executable
if (USE_CUDA)
add_executable(runtime_sim_gpu main/runtime_main.cpp ${SOURCES_COMMON})
target_compile_definitions(runtime_sim_gpu PRIVATE USE_CUDA=1)
target_link_libraries(runtime_sim_gpu CUDA::cudart)
set_target_properties(runtime_sim_gpu PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
else()
add_executable(runtime_sim main/runtime_main.cpp ${SOURCES_COMMON})
target_compile_definitions(runtime_sim PRIVATE USE_CUDA=0)
set_target_properties(runtime_sim PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endif()
# Print a summary
if (USE_CUDA)
message(STATUS "Building with CUDA support: ON")
else()
message(STATUS "Building with CUDA support: OFF")
endif()