-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
127 lines (102 loc) · 3.39 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
cmake_minimum_required(VERSION 3.8)
project("RealTimeParticleBasedSnowSimulation")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
OPTION(USE_D2D_WSI "Build the project using Direct to Display swapchain" OFF)
find_package(Vulkan REQUIRED)
IF(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_WIN32_KHR")
ELSE(WIN32)
find_package(Threads REQUIRED)
IF(USE_D2D_WSI)
MESSAGE("Using direct to display extension...")
add_definitions(-D_DIRECT2DISPLAY)
ELSE(USE_D2D_WSI)
find_package(XCB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_XCB_KHR")
ENDIF(USE_D2D_WSI)
# Todo : android?
ENDIF(WIN32)
########################################
# CUDA Setup
########################################
find_package(CUDA 10 REQUIRED)
include(${CMAKE_MODULE_PATH}/CUDAComputesList.cmake)
list(APPEND CUDA_NVCC_FLAGS ${CUDA_GENERATE_CODE})
list(APPEND CUDA_NVCC_FLAGS_DEBUG "-g -G")
set(CUDA_VERBOSE_BUILD ON)
if(WIN32)
# Set up include and lib paths
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE FILEPATH "Host side compiler used by NVCC" FORCE)
endif(WIN32)
########################################
# Set preprocessor defines
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX -D_USE_MATH_DEFINES")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# add_definitions(-std=c++11)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Enable the creation of folders for Visual Studio projects
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
function(ExternalTarget folder target)
set_property(TARGET ${target} PROPERTY FOLDER ${folder})
endfunction(ExternalTarget)
function(InternalTarget folder target)
ExternalTarget("${folder}" ${target})
if (MSVC)
get_target_property(targetSources ${target} SOURCES)
foreach(sourceFile IN ITEMS ${targetSources})
if (IS_ABSOLUTE "${sourceFile}")
file(RELATIVE_PATH sourceFile "${CMAKE_CURRENT_SOURCE_DIR}" "${sourceFile}")
endif()
get_filename_component(sourceDir "${sourceFile}" PATH)
string(REPLACE "/" "\\" sourceDir "${sourceDir}")
source_group("${sourceDir}" FILES "${sourceFile}")
endforeach()
endif()
endfunction(InternalTarget)
# Compiler specific stuff
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
ENDIF(MSVC)
IF(WIN32)
# Nothing here (yet)
ELSE(WIN32)
link_libraries(${XCB_LIBRARIES} ${VULKAN_LIB})
ENDIF(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
set(GLM_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/external/glm")
include_directories(${GLM_INCLUDE_DIR})
set(headers
src/pointsgenerator.h
src/cudaMat4.hpp
src/kernel.h
src/utilityCore.hpp
src/particle.h
src/vertex.h
src/vulkanpointsrenderer.h
src/vulkanspheresrenderer.h
src/utils.h
external/tiny_obj_loader.h
external/stb_image.h
)
set(sources
src/kernel.cu
src/main.cpp
src/utilityCore.cpp
)
list(SORT headers)
list(SORT sources)
source_group(Headers FILES ${headers})
source_group(Sources FILES ${sources})
cuda_add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers})
# add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers})
target_link_libraries(
${CMAKE_PROJECT_NAME}
${LIBRARIES}
Vulkan::Vulkan
glfw
)
add_subdirectory(external)