/
CMakeLists.txt
153 lines (136 loc) · 4.64 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
# Copyright 2020-2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5)
project(monstermash LANGUAGES CXX C)
set(SOURCES
main.cpp
defengarapl.cpp
cpanim.cpp
loadsave.cpp
reconstruction.cpp
mainwindow.cpp
mypainter.cpp
mywindow.cpp
def3dsdl.cpp
../third_party/ir3d-utils/regionToMesh.cpp
../third_party/ir3d-utils/MeshBuilder.cpp
../third_party/image/imageReadWrite.cpp
../third_party/image/imageScale.cpp
../third_party/image/imageUtils.cpp
../third_party/miscutils/def3d.cpp
../third_party/miscutils/mesh3d.cpp
../third_party/miscutils/fsutils.cpp
../third_party/miscutils/opengltools.cpp
../third_party/miscutils/camera.cpp
../third_party/triangle/triangle.c
../third_party/zip-mod/zip.c
../third_party/SDL2_gfx-mod/SDL2_gfxPrimitives-mod.c
../third_party/SDL2_gfx/SDL2_rotozoom.c
)
set(HEADERS
commonStructs.h
defengarapl.h
cpanim.h
loadsave.h
reconstruction.h
mainwindow.h
mypainter.h
mywindow.h
def3dsdl.h
macros.h
../third_party/ir3d-utils/regionToMesh.h
../third_party/image/image.h
../third_party/image/imageReadWrite.hpp
../third_party/image/imageUtils.h
../third_party/miscutils/fsutils.h
../third_party/miscutils/macros.h
../third_party/miscutils/camera.h
../third_party/miscutils/def3d.h
../third_party/miscutils/mesh3d.h
../third_party/miscutils/opengltools.h
)
if (CMAKE_CXX_COMPILER MATCHES "em\\+\\+$")
message("Compiling for WebAssembly/Emscripten")
set(COMPILER_FLAGS -sWASM=1 -sUSE_SDL=2 -sUSE_SDL_TTF=2)
set(COMPILER_FLAGS ${COMPILER_FLAGS} -sALLOW_MEMORY_GROWTH=1)
set(COMPILER_FLAGS ${COMPILER_FLAGS} -sMINIFY_HTML=0)
set(COMPILER_FLAGS ${COMPILER_FLAGS} -sENVIRONMENT=web)
set(COMPILER_FLAGS_OPENGL -sFULL_ES2=1)
set(LINKER_FLAGS_OPENGL ${COMPILER_FLAGS_OPENGL})
# set(LINKER_FLAGS ${LINKER_FLAGS} ${COMPILER_FLAGS} "--preload-file ${CMAKE_SOURCE_DIR}/../data/examples@/tmp/examples")
set(LINKER_FLAGS ${LINKER_FLAGS} ${COMPILER_FLAGS} "--preload-file ${CMAKE_SOURCE_DIR}/../data/shaders@../../data/shaders")
set(LINKER_FLAGS ${LINKER_FLAGS} "--shell-file ${CMAKE_SOURCE_DIR}/ui/myshell.html")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
else()
message("Compiling for Linux")
# SDL2
find_package(SDL2 REQUIRED)
set(LINKER_FLAGS ${LINKER_FLAGS} -lpthread)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(DEFINES
# ENABLE_DEBUG_CMD_IMG
# ENABLE_DEBUG_CMD_IR
ENABLE_DEBUG_CMD_MM
)
find_package(OpenGL REQUIRED)
endif()
set(COMPILER_FLAGS ${COMPILER_FLAGS}
-Wno-sign-compare -Werror=return-type -Wno-narrowing
)
set(LINKER_FLAGS ${LINKER_FLAGS}
${SDL2_LIBRARIES}
)
execute_process(COMMAND date +%y%m%d
OUTPUT_VARIABLE APP_VERSION_VAR
OUTPUT_STRIP_TRAILING_WHITESPACE)
message("MM version: ${APP_VERSION_VAR}")
set(DEFINES ${DEFINES}
IMAGE_READ_WRITE
IMAGE_MINIZ_EXTERNAL
IMAGE_SCALE
TRILIBRARY
NO_TIMER
IGL_PARALLEL_FOR_FORCE_SERIAL
EIGEN_MPL2_ONLY
EIGEN_SPARSESOLVERBASE_H
_SDL2_gfxPrimitives_h
APP_VERSION=${APP_VERSION_VAR}
)
set(DEFINES_OPENGL
USE_SDL_GLES2
USE_OPENGL_FOR_DRAWING_INSTEAD_OF_SDL
)
set(INCLUDEPATH
../third_party
../third_party/eigen3-mod
../third_party/eigen3
../third_party/libigl/include
../third_party/stb
../third_party/triangle
../third_party/zip-mod
../third_party/SDL2_gfx
../third_party/SDL2_gfx-mod
${SDL2_INCLUDE_DIRS}
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_executable(monstermash ${SOURCES} ${HEADERS})
target_compile_definitions(monstermash PRIVATE ${DEFINES} ${DEFINES_OPENGL} ${DEFINES_EMSCRIPTEN})
target_include_directories(monstermash PRIVATE ${INCLUDEPATH})
target_link_libraries(monstermash ${LINKER_FLAGS} ${LINKER_FLAGS_OPENGL} ${OPENGL_LIBRARIES})
target_compile_options(monstermash PRIVATE ${COMPILER_FLAGS} ${COMPILER_FLAGS_OPENGL})