-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
169 lines (147 loc) · 3.68 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
cmake_minimum_required(VERSION 2.8)
project (Ushuaia)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0045 NEW)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
if (WIN32)
set(EXT_DIR D:/3rdParty)
elseif (APPLE)
set(EXT_DIR ~/Programs/3rdParty)
endif ()
set(BOOST_VER "1_75")
set(BX_INCLUDE_DIR ${EXT_DIR}/bx/include)
set(BIMG_INCLUDE_DIR ${EXT_DIR}/bimg/include)
set(BGFX_INCLUDE_DIR ${EXT_DIR}/bgfx/include)
set(BOOST_INCLUDE_DIR ${EXT_DIR}/boost_${BOOST_VER})
set(XML_INCLUDE_DIR ${EXT_DIR}/pugixml/src)
set(JSON_INCLUDE_DIR ${EXT_DIR}/rapidjson/include)
set(BOOST_LIB_DIR ${BOOST_INCLUDE_DIR}/stage/lib)
set(ENTT_INCLUDE_DIR ${EXT_DIR}/entt/src/entt)
if (WIN32)
set(BX_COMPAT_DIR ${BX_INCLUDE_DIR}/compat/msvc)
set(BGFX_LIB_DIR ${BGFX_INCLUDE_DIR}/../.build/win64_vs2017)
elseif (APPLE)
set(BX_COMPAT_DIR ${BX_INCLUDE_DIR}/compat/osx)
set(BGFX_LIB_DIR ${BGFX_INCLUDE_DIR}/../.build/osx-x64)
endif ()
include_directories(
${BX_INCLUDE_DIR}
${BX_COMPAT_DIR}
${BIMG_INCLUDE_DIR}
${BGFX_INCLUDE_DIR}
${BGFX_INCLUDE_DIR}/../3rdparty
${BOOST_INCLUDE_DIR}
${XML_INCLUDE_DIR}
${JSON_INCLUDE_DIR}
${ENTT_INCLUDE_DIR}
)
link_directories(
${BGFX_LIB_DIR}/bin
${BOOST_LIB_DIR}
)
add_definitions(
-D__STDC_LIMIT_MACROS
-D__STDC_FORMAT_MACROS
-D__STDC_CONSTANT_MACROS
-DENTRY_CONFIG_IMPLEMENT_MAIN=1
)
if (WIN32)
add_definitions(-D_WIN32)
elseif (APPLE)
add_definitions(-D_APPLE)
#add_compile_options(-Wmissing-braces)
endif ()
#if (CMAKE_BUILD_TYPE MATCHES "")
# set(CMAKE_BUILD_TYPE "Debug")
#endif ()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
MESSAGE(STATUS "CMAKE_BUILD_TYPE is Debug")
add_definitions(-D_DEBUG)
elseif (CMAKE_BUILD_TYPE MATCHES "Release")
MESSAGE(STATUS "CMAKE_BUILD_TYPE is Release")
else ()
MESSAGE(STATUS "unknown CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE})
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
if (APPLE)
link_libraries(-m64
"-framework Cocoa"
"-framework QuartzCore"
"-framework OpenGL"
"-weak_framework Metal"
)
endif ()
add_executable(executable
src/AppEntry.cpp
src/Blur.cpp
src/Camera.cpp
src/ConfDef.cpp
src/DrawItem.cpp
src/Entity.cpp
src/ForwardRendering.cpp
src/FrameBuffer.cpp
src/HDR.cpp
src/Light.cpp
src/Material.cpp
src/Mesh.cpp
src/Model.cpp
src/PostProcess.cpp
src/RenderHelper.cpp
src/RenderUtil.cpp
src/Script.cpp
src/Scene.cpp
src/Serialize.cpp
src/Shader.cpp
src/Shading.cpp
src/Texture.cpp
src/VtxDecl.cpp
src/Workflow.cpp
)
if (WIN32) # MSVC
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
target_compile_features(executable PUBLIC cxx_std_20)
set_target_properties(executable PROPERTIES VS_USER_PROPS "predef.props")
set(VC_VER "vc142")
target_link_libraries(executable
bx$(Configuration).lib
bimg$(Configuration).lib
bimg_decode$(Configuration).lib
bgfx$(Configuration).lib
example-glue$(Configuration).lib
example-common$(Configuration).lib
)
elseif (APPLE)
set(CFG ${CMAKE_BUILD_TYPE})
target_link_libraries(executable
libbx${CFG}.a
libbimg${CFG}.a
libbimg_decode${CFG}.a
libbgfx${CFG}.a
#libbimg_encode${CFG}.a
#libfcpp${CFG}.a
#libglsl-optimizer${CFG}.a
#libglslang${CFG}.a
#libspirv-opt${CFG}.a
libexample-glue${CFG}.a
libexample-common${CFG}.a
libboost_system.a
libboost_filesystem.a
)
endif ()