forked from nvpro-samples/gl_vk_supersampled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
126 lines (118 loc) · 5.82 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
cmake_minimum_required(VERSION 2.8)
set(PROJNAME gl_vk_supersampled)
Project(${PROJNAME})
Message(STATUS "-------------------------------")
Message(STATUS "Processing Project ${PROJNAME}:")
SET(MODELS_DOWNLOAD_FORCE OFF CACHE BOOL "Forces the download operation of 3D models needed for this demo" )
SET(MODELS_DOWNLOAD_DISABLED ON CACHE BOOL "UNCHECK IT to download heavy 3D models needed for this demo" )
#####################################################################################
# offer the choice of having shared_sources as a sub-folder... good for packaging a sample
#
if(NOT BASE_DIRECTORY) # if not defined, it means this cmake file was called as the first entry point and not included
# check if the external repository is outside or inside the project (as a sub-module)
# testing the file CMakeLists_include.txt because when sub-modules are not cloned, the folders are still there...
# we also assume here that if shared_sources is there, shared_external is, too...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/shared_sources/CMakeLists_include.txt)
Message(STATUS "found sub-folder shared_sources")
SET(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/shared_sources/CMakeLists_include.txt)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/shared_sources ${CMAKE_BINARY_DIR}/shared_sources)
# if the resource of downloaded meshes is local, keep this one. Otherwise, use the common one
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/downloaded_resources)
SET(DOWNLOAD_TARGET_DIR "${BASE_DIRECTORY}/downloaded_resources")
else()
SET(DOWNLOAD_TARGET_DIR "${BASE_DIRECTORY}/../downloaded_resources")
endif()
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../shared_sources)
SET(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../shared_sources/CMakeLists_include.txt)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../shared_sources ${CMAKE_BINARY_DIR}/shared_sources)
SET(DOWNLOAD_TARGET_DIR "${BASE_DIRECTORY}/downloaded_resources")
else()
SET(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../shared_sources/CMakeLists_include.txt)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../shared_sources ${CMAKE_BINARY_DIR}/shared_sources)
SET(DOWNLOAD_TARGET_DIR "${BASE_DIRECTORY}/downloaded_resources")
endif()
else(NOT BASE_DIRECTORY)
SET(DOWNLOAD_TARGET_DIR "${BASE_DIRECTORY}/downloaded_resources")
endif(NOT BASE_DIRECTORY)
_add_project_definitions(${PROJNAME})
#####################################################################################
# additions from packages needed for this sample
# add refs in LIBRARIES_OPTIMIZED
# add refs in LIBRARIES_DEBUG
# add files in PACKAGE_SOURCE_FILES
#
_add_package_VulkanSDK()
_add_package_NSight()
_add_package_MFCUI()
#_add_package_AntTweakBar()
_add_package_OpenGLText()
_add_package_ZLIB()
#_add_package_nvFx()
#####################################################################################
# Source files for this project
#
file(GLOB SOURCE_FILES *.cpp *.hpp *.inl *.h *.c mt/*.cpp mt/*.h VK_nvidia/*.c VK_nvidia/*.h)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/VK_nvidia)
#####################################################################################
# GLSL to SPIR-V custom build
#
#more than one file can be given: _compile_GLSL("GLSL_mesh.vert;GLSL_mesh.frag" "GLSL_mesh.spv" GLSL_SOURCES)
# the SpirV validator is fine as long as files are for different pipeline stages (entry points still need to be main())
#_compile_GLSL(<source(s)> <target spv> <LIST where files are appended>)
UNSET(GLSL_SOURCES)
_compile_GLSL("GLSL/GLSL_fur.vert" "GLSL/GLSL_fur_vert.spv" GLSL_SOURCES)
_compile_GLSL("GLSL/GLSL_fur.frag" "GLSL/GLSL_fur_frag.spv" GLSL_SOURCES)
source_group(GLSL_Files FILES ${GLSL_SOURCES})
#####################################################################################
# additional files from helpers
#
#LIST(APPEND COMMON_SOURCE_FILES
# ${BASE_DIRECTORY}/shared_sources/nv_helpers_gl/WindowInertiaCamera.h
# ${BASE_DIRECTORY}/shared_sources/nv_helpers/TimeSampler.h
# ${BASE_DIRECTORY}/shared_sources/nv_helpers/InertiaCamera.h
# ${BASE_DIRECTORY}/shared_sources/nv_math/nv_math.inl
# ${BASE_DIRECTORY}/shared_sources/nv_math/nv_math.h
# ${BASE_DIRECTORY}/shared_sources/nv_math/nv_math_types.h
# ${BASE_DIRECTORY}/shared_sources/nv_helpers/profiler.hpp
# ${BASE_DIRECTORY}/shared_sources/nv_helpers/profiler.cpp
#)
#####################################################################################
# Executable
#
if(WIN32 AND NOT GLUT_FOUND)
add_definitions(/wd4267) #remove size_t to int warning
add_definitions(/wd4996) #remove printf warning
add_definitions(/wd4244) #remove double to float conversion warning
add_definitions(/wd4305) #remove double to float truncation warning
add_executable(${PROJNAME} WIN32 ${SOURCE_FILES} ${COMMON_SOURCE_FILES} ${PACKAGE_SOURCE_FILES} ${GLSL_SOURCES})
else()
# allow gcc to be tolerant on some issues. TODO:should remove this option
add_definitions(-fpermissive)
add_executable(${PROJNAME} ${SOURCE_FILES} ${COMMON_SOURCE_FILES} ${PACKAGE_SOURCE_FILES} ${GLSL_SOURCES})
endif()
#####################################################################################
# common source code needed for this sample
#
source_group(common FILES
${COMMON_SOURCE_FILES}
)
#####################################################################################
# Linkage
#
target_link_libraries(${PROJNAME} optimized
${LIBRARIES_OPTIMIZED}
${PLATFORM_LIBRARIES}
shared_sources
)
target_link_libraries(${PROJNAME} debug
${LIBRARIES_DEBUG}
${PLATFORM_LIBRARIES}
shared_sources
)
#####################################################################################
# copies binaries that need to be put next to the exe files (ZLib, etc.)
#
_copy_binaries_to_target( ${PROJNAME} )