-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (135 loc) · 4.23 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
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
project(subface LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_definitions(-DNOMINMAX)
# For GLEW shared library.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4281")
else()
set(CXX_WARNINGS "-Wall -Wextra -Wpointer-arith -Wcast-align -Wno-comment")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNINGS} -fvisibility-inlines-hidden -fstrict-aliasing")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
endif()
include_directories(
src/core
src/utility
src/thirdparty
src/thirdparty/glew-2.2.0/include
src/thirdparty/glfw/include
src/thirdparty/glm
src/thirdparty/spdlog/include
src/thirdparty/argparse/include
${OPENGL_INCLUDE_DIR}
)
# Simplygon
if(WIN32)
set(SIMPLYGON_10_PATH $ENV{SIMPLYGON_10_PATH} CACHE PATH "Path to Simplygon 10 SDK")
if("${SIMPLYGON_10_PATH}" STREQUAL "")
message(WARNING "SIMPLYGON_10_PATH is not set. Disabling decimation with Simplygon.")
else()
set(SIMPLYGON_10_LOADER "${SIMPLYGON_10_PATH}/SimplygonLoader.cpp")
include_directories("${SIMPLYGON_10_PATH}")
add_compile_definitions(USE_SIMPLYGON)
endif()
else()
message(WARNING "Simplygon only supports Windows. Disabling decimation with Simplygon.")
endif()
add_library(meshoptimizer
src/thirdparty/meshoptimizer/simplifier.cpp
src/thirdparty/meshoptimizer/vfetchoptimizer.cpp
)
add_library(core
src/core/Subface.cpp
src/utility/Timer.cpp
${SIMPLYGON_10_LOADER}
)
target_link_libraries(core PRIVATE
spdlog::spdlog
meshoptimizer
)
add_library(stb_image_write
src/thirdparty/stb_image_write.cpp
)
target_compile_definitions(stb_image_write PRIVATE STB_IMAGE_WRITE_IMPLEMENTATION)
if(MSVC)
target_compile_options(stb_image_write PRIVATE "/W0")
else()
target_compile_options(stb_image_write PRIVATE "-w")
endif()
add_library(utility
src/utility/Camera.cpp
src/utility/FPS.cpp
src/utility/Model.cpp
src/utility/OGL.cpp
src/utility/Timer.cpp
src/utility/Toggle.cpp
)
target_link_libraries(utility PRIVATE
stb_image_write
spdlog::spdlog
glew_s
glfw
)
add_executable(subface
src/subface/subface.cpp
)
target_link_libraries(subface
spdlog::spdlog
core
utility
)
if(MSVC)
add_custom_target(copy_shader_files ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/src/shader
${PROJECT_BINARY_DIR}/$<CONFIG>/shader
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/src/shader
${PROJECT_BINARY_DIR}/shader
COMMENT "Copying shader files"
)
else()
add_custom_target(copy_shader_files ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/src/shader
${PROJECT_BINARY_DIR}/shader
COMMENT "Copying shader files"
)
endif()
add_dependencies(subface copy_shader_files)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/glew-2.2.0)
file(DOWNLOAD
https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.zip
${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/glew-2.2.0.zip
STATUS glew_download_status
)
list(GET glew_download_status 0 error_code)
list(GET glew_download_status 1 error_reason)
if(${error_code} EQUAL 0)
file(ARCHIVE_EXTRACT
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/glew-2.2.0.zip"
DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty"
)
else()
message(FATAL_ERROR
"Downloading glew-2.2.0.zip failed because of ${error_reason}!\n"
"You may try configuring for another time.\n"
"Or you can download it by yourself from \"https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.zip\" and extract to \"src/thirdparty\" so that \"src/thirdparty/glew-2.2.0/build/cmake\" exists."
)
endif()
endif()
option(BUILD_UTILS "utilities" OFF)
add_subdirectory(src/thirdparty/glew-2.2.0/build/cmake)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/glfw)
message(FATAL_ERROR
"\"src/thirdparty/glfw\" doesn't exist!\n"
"Did you use \"--recursive\" when cloning?\n"
)
endif()
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
option(GLFW_INSTALL "Generate installation target" OFF)
add_subdirectory(src/thirdparty/glfw)
add_subdirectory(src/thirdparty/spdlog)