-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
132 lines (110 loc) · 4.19 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
128
129
130
131
132
cmake_minimum_required(VERSION 3.5)
get_filename_component(PROJNAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
Project(${PROJNAME} VERSION 1.4)
Message(STATUS "-------------------------------")
Message(STATUS "Processing Project ${PROJNAME}:")
# ####################################################################################
# look for nvpro_core 1) as a sub-folder 2) at some other locations
# this cannot be put anywhere else since we still didn't find setup.cmake yet
#
if(NOT BASE_DIRECTORY)
find_path(BASE_DIRECTORY
NAMES nvpro_core/cmake/setup.cmake
PATHS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../..
REQUIRED
DOC "Directory containing nvpro_core"
)
endif()
if(EXISTS ${BASE_DIRECTORY}/nvpro_core/cmake/setup.cmake)
include(${BASE_DIRECTORY}/nvpro_core/cmake/setup.cmake)
else()
message(FATAL_ERROR "could not find base directory, please set BASE_DIRECTORY to folder containing nvpro_core")
endif()
_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
set(EXENAME ${PROJNAME})
_add_package_DirectX12()
_add_package_ImGUI()
_add_package_NVAPI()
# ####################################################################################
# process the rest of some cmake code that needs to be done *after* the packages add
_add_nvpro_core_lib()
# ####################################################################################
# Source files for this project
#
file(GLOB SOURCE_FILES *.cpp *.hpp *.inl *.h *.c)
file(GLOB HLSL_PIXEL_SHADER_FILES shaders/ps.hlsl shaders/gui_ps.hlsl)
file(GLOB HLSL_VERTEX_SHADER_FILES shaders/indicator_vs.hlsl shaders/line_vs.hlsl shaders/gui_vs.hlsl)
# ####################################################################################
# Executable
#
set_property(SOURCE ${HLSL_PIXEL_SHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
set_property(SOURCE ${HLSL_PIXEL_SHADER_FILES} PROPERTY VS_SHADER_MODEL 5.0)
set_property(SOURCE ${HLSL_VERTEX_SHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex)
set_property(SOURCE ${HLSL_VERTEX_SHADER_FILES} PROPERTY VS_SHADER_MODEL 5.0)
add_executable(${EXENAME} ${SOURCE_FILES} ${COMMON_SOURCE_FILES} ${PACKAGE_SOURCE_FILES} ${HLSL_PIXEL_SHADER_FILES} ${HLSL_VERTEX_SHADER_FILES})
find_package(Git)
set(GIT_HASH custom)
set(GIT_UNCOMMITTED_CHANGES 0)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --is-inside-work-tree
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE IS_GIT_REPO
OUTPUT_QUIET
ERROR_QUIET
)
if(IS_GIT_REPO EQUAL 0)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${GIT_EXECUTABLE} diff --quiet
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_UNCOMMITTED_CHANGES
)
endif()
endif()
target_include_directories(${EXENAME} PRIVATE ${CMAKE_BINARY_DIR})
configure_file(version.h.in version.h)
# _set_subsystem_console(${EXENAME})
# ####################################################################################
# common source code needed for this sample
#
source_group("" FILES
${SOURCE_FILES}
)
source_group(shaders FILES
${HLSL_PIXEL_SHADER_FILES}
${HLSL_VERTEX_SHADER_FILES}
)
source_group(resources FILES
${COMMON_SOURCE_FILES}
${PACKAGE_SOURCE_FILES}
)
if(UNIX)
set(UNIXLINKLIBS dl pthread)
else()
set(UNIXLINKLIBS)
endif()
# ####################################################################################
# Linkage
#
target_link_libraries(${EXENAME} ${PLATFORM_LIBRARIES} nvpro_core)
foreach(DEBUGLIB ${LIBRARIES_DEBUG})
target_link_libraries(${EXENAME} debug ${DEBUGLIB})
endforeach(DEBUGLIB)
foreach(RELEASELIB ${LIBRARIES_OPTIMIZED})
target_link_libraries(${EXENAME} optimized ${RELEASELIB})
endforeach(RELEASELIB)
# ####################################################################################
# copies binaries that need to be put next to the exe files (ZLib, etc.)
#
_finalize_target(${EXENAME})