-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
182 lines (172 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
cmake_minimum_required(VERSION 3.17)
project(
SorghumFactory
VERSION 0.1
DESCRIPTION "An implementation of MLVQ library in CUDA with OptiX ray tracer, and a procedural 3D model of sorghum. The project is based on UniEngine."
)
option(BUILD_RAY_TRACER_FACILITY "Build Ray Tracer Facility" ON)
set(BUILD_RAY_TRACER_FACILITY ON)
include(GenerateExportHeader)
# Set a default build type if none was specified
set(default_build_type "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release")
endif ()
# ------------------------------------------------------------------
# 3rd Party libraries
# ------------------------------------------------------------------
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_STANDARD 17)
if (WIN32)
# Compiler settings for Windows platform
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
elseif (UNIX AND NOT APPLE)
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
elseif (${CMAKE_BUILD_TYPE} STREQUAL Debug)
set(CMAKE_CXX_FLAGS_DEBUG "-g")
endif ()
elseif (APPLE)
endif ()
# ------------------------------------------------------------------
# Sorghum Factory - Provides models for ray tracer.
# ------------------------------------------------------------------
file(GLOB SORGHUM_FACTORY_SOURCES_LOCAL "src/SorghumFactory/*.cpp")
add_library(SorghumFactory
SHARED
${SORGHUM_FACTORY_SOURCES_LOCAL}
)
set(SORGHUM_FACTORY_PCH_LOCAL
${UNIENGINE_PCH}
${RAY_TRACER_FACILITY_PCH}
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory/SorghumFactory-pch.hpp
)
generate_export_header(SorghumFactory
BASE_NAME SORGHUM_FACTORY
EXPORT_MACRO_NAME SORGHUM_FACTORY_API
)
target_precompile_headers(SorghumFactory
PRIVATE
${SORGHUM_FACTORY_PCH_LOCAL}
)
if (BUILD_RAY_TRACER_FACILITY)
target_compile_definitions(SorghumFactory
PRIVATE
GLAD_GLAPI_EXPORT
NOMINMAX
RAYTRACERFACILITY
)
set(SORGHUM_FACTORY_INCLUDES_LOCAL
${RAY_TRACER_FACILITY_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory/quickhull
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory/rapidxml
)
else ()
target_compile_definitions(SorghumFactory
PRIVATE
GLAD_GLAPI_EXPORT
NOMINMAX
)
set(SORGHUM_FACTORY_INCLUDES_LOCAL
${UNIENGINE_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory/quickhull
${CMAKE_CURRENT_SOURCE_DIR}/include/SorghumFactory/rapidxml
)
endif ()
target_include_directories(SorghumFactory
PUBLIC
${SORGHUM_FACTORY_INCLUDES_LOCAL}
)
if (BUILD_RAY_TRACER_FACILITY)
target_link_libraries(SorghumFactory
RayTracerFacility
)
else ()
target_link_libraries(SorghumFactory
uniengine
)
endif ()
# ------------------------------------------------------------------
# Scripts
# ------------------------------------------------------------------
file(GLOB SCRIPTS_SOURCES_LOCAL "src/Scripts/*.cpp")
add_library(Scripts
${SCRIPTS_SOURCES_LOCAL}
)
target_precompile_headers(Scripts
PRIVATE
${SORGHUM_FACTORY_PCH_LOCAL}
)
set(SCRIPTS_INCLUDES_LOCAL
${SORGHUM_FACTORY_INCLUDES_LOCAL}
${CMAKE_CURRENT_SOURCE_DIR}/include/Scripts
)
target_include_directories(Scripts
PUBLIC
${SCRIPTS_INCLUDES_LOCAL}
)
if (BUILD_RAY_TRACER_FACILITY)
target_link_libraries(Scripts
RayTracerFacility
SorghumFactory
)
target_compile_definitions(Scripts
PRIVATE
RAYTRACERFACILITY
)
else ()
target_link_libraries(Scripts
uniengine
SorghumFactory
)
endif ()
# ------------------------------------------------------------------
# Executables
# ------------------------------------------------------------------
add_executable(SorghumFramework
"src/app/Application.cpp"
src/Scripts/GeneralAutomatedPipeline.cpp include/Scripts/GeneralAutomatedPipeline.hpp)
target_include_directories(SorghumFramework
PUBLIC
${SCRIPTS_INCLUDES_LOCAL}
)
target_precompile_headers(SorghumFramework
PRIVATE
${SORGHUM_FACTORY_PCH_LOCAL}
)
if (BUILD_RAY_TRACER_FACILITY)
target_link_libraries(SorghumFramework
RayTracerFacility
SorghumFactory
Scripts
)
target_compile_definitions(SorghumFramework
PRIVATE
RAYTRACERFACILITY
)
else ()
target_link_libraries(SorghumFramework
uniengine
SorghumFactory
Scripts
)
endif ()
# ------------------------------------------------------------------
# Copy Internal resources
# ------------------------------------------------------------------
add_custom_command(TARGET SorghumFactory POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/src/Internals
${CMAKE_BINARY_DIR})
file(COPY src/app/imgui.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR})