forked from godotengine/FBX2glTF
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
250 lines (223 loc) · 7.51 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
cmake_minimum_required(VERSION 3.5)
project(FBX2glTF)
set(typical_usage_str
"Example usage:\n\
> mkdir -p build_debug\n\
> conan install . -i build_debug -s build_type=Debug -e FBXSDK_SDKS=/home/zell/FBXSDK\n\
> conan build . -bf build_debug")
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR
"Building from within the source tree is not supported! ${typical_usage_str}")
endif ()
set(CMAKE_CXX_STANDARD 11)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
include(ExternalProject)
# FBX
foreach (FBXSDK_VERSION "2020.2")
find_package(FBX)
if (FBXSDK_FOUND)
break()
endif()
endforeach(FBXSDK_VERSION)
if (NOT FBXSDK_FOUND)
message(FATAL_ERROR
"Can't find FBX SDK in either:\n"
" - Mac OS X: ${FBXSDK_APPLE_ROOT}\n"
" - Windows: ${FBXSDK_WINDOWS_ROOT}\n"
" - Linux: ${FBXSDK_LINUX_ROOT}"
)
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan_paths.cmake")
message(FATAL_ERROR
"The Conan package manager must run ('install') first. ${typical_usage_str}")
endif()
include("${CMAKE_BINARY_DIR}/conan_paths.cmake")
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_BINARY_DIR}")
# stuff we get from Conan
find_package(Boost 1.76 COMPONENTS system filesystem program_options nowide REQUIRED )
find_package(ZLIB MODULE REQUIRED)
find_package(fmt MODULE REQUIRED)
find_package(Iconv MODULE REQUIRED)
find_package(LibXml2 MODULE REQUIRED)
# create a compilation database for e.g. clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# DRACO
ExternalProject_Add(Draco
GIT_REPOSITORY https://github.com/google/draco
GIT_TAG 8786740086a9f4d83f44aa83badfbea4dce7a1b5
PREFIX draco
INSTALL_DIR
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DBUILD_FOR_GLTF=1
)
set(DRACO_INCLUDE_DIR "${CMAKE_BINARY_DIR}/draco/include")
find_file(FEDORA_FOUND fedora-release
PATHS /etc
)
if (WIN32)
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/${CMAKE_SHARED_MODULE_PREFIX}draco.lib")
elseif(FEDORA_FOUND)
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib64/${CMAKE_SHARED_MODULE_PREFIX}draco.a")
else()
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/${CMAKE_SHARED_MODULE_PREFIX}draco.a")
endif()
# MATHFU
set(mathfu_build_benchmarks OFF CACHE BOOL "")
set(mathfu_build_tests OFF CACHE BOOL "")
ExternalProject_Add(MathFu
PREFIX mathfu
GIT_REPOSITORY https://github.com/google/mathfu
GIT_TAG v1.1.0
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu configure step."
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu build step."
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu install step."
)
set(MATHFU_INCLUDE_DIRS
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/include/"
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/dependencies/vectorial/include")
# OrderedMap
ExternalProject_Add(FiFoMap
PREFIX fifo_map
GIT_REPOSITORY https://github.com/nlohmann/fifo_map
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap configure step."
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap build step."
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap install step."
)
set(FIFO_MAP_INCLUDE_DIR "${CMAKE_BINARY_DIR}/fifo_map/src/FiFoMap/src")
# cppcodec
ExternalProject_Add(CPPCodec
PREFIX cppcodec
GIT_REPOSITORY https://github.com/tplgy/cppcodec
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec configure step."
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec build step."
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec install step."
)
set(CPPCODEC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cppcodec/src/CPPCodec")
if (APPLE)
find_library(CF_FRAMEWORK CoreFoundation)
message("CoreFoundation Framework: ${CF_FRAMEWORK}")
set(FRAMEWORKS ${CF_FRAMEWORK})
endif()
set(LIB_SOURCE_FILES
src/FBX2glTF.h
src/fbx/materials/3dsMaxPhysicalMaterial.cpp
src/fbx/materials/FbxMaterials.cpp
src/fbx/materials/FbxMaterials.hpp
src/fbx/materials/RoughnessMetallicMaterials.hpp
src/fbx/materials/StingrayPBSMaterial.cpp
src/fbx/materials/TraditionalMaterials.cpp
src/fbx/materials/TraditionalMaterials.hpp
src/fbx/Fbx2Raw.cpp
src/fbx/Fbx2Raw.hpp
src/fbx/FbxBlendShapesAccess.cpp
src/fbx/FbxBlendShapesAccess.hpp
src/fbx/FbxLayerElementAccess.hpp
src/fbx/FbxSkinningAccess.cpp
src/fbx/FbxSkinningAccess.hpp
src/gltf/Raw2Gltf.cpp
src/gltf/Raw2Gltf.hpp
src/gltf/GltfModel.cpp
src/gltf/GltfModel.hpp
src/gltf/TextureBuilder.cpp
src/gltf/TextureBuilder.hpp
src/gltf/properties/AccessorData.cpp
src/gltf/properties/AccessorData.hpp
src/gltf/properties/AnimationData.cpp
src/gltf/properties/AnimationData.hpp
src/gltf/properties/BufferData.cpp
src/gltf/properties/BufferData.hpp
src/gltf/properties/BufferViewData.cpp
src/gltf/properties/BufferViewData.hpp
src/gltf/properties/CameraData.cpp
src/gltf/properties/CameraData.hpp
src/gltf/properties/ImageData.cpp
src/gltf/properties/ImageData.hpp
src/gltf/properties/LightData.cpp
src/gltf/properties/LightData.hpp
src/gltf/properties/MaterialData.cpp
src/gltf/properties/MaterialData.hpp
src/gltf/properties/MeshData.cpp
src/gltf/properties/MeshData.hpp
src/gltf/properties/NodeData.cpp
src/gltf/properties/NodeData.hpp
src/gltf/properties/PrimitiveData.cpp
src/gltf/properties/PrimitiveData.hpp
src/gltf/properties/SamplerData.hpp
src/gltf/properties/SceneData.cpp
src/gltf/properties/SceneData.hpp
src/gltf/properties/SkinData.cpp
src/gltf/properties/SkinData.hpp
src/gltf/properties/TextureData.cpp
src/gltf/properties/TextureData.hpp
src/mathfu.hpp
src/raw/RawModel.cpp
src/raw/RawModel.hpp
src/utils/File_Utils.cpp
src/utils/File_Utils.hpp
src/utils/Image_Utils.cpp
src/utils/Image_Utils.hpp
src/utils/String_Utils.hpp
third_party/CLI11/CLI11.hpp
)
add_library(libFBX2glTF STATIC ${LIB_SOURCE_FILES})
set_target_properties(libFBX2glTF PROPERTIES OUTPUT_NAME "libFBX2glTF")
add_executable(FBX2glTF src/FBX2glTF.cpp)
set_target_properties(FBX2glTF PROPERTIES OUTPUT_NAME "FBX2glTF")
add_dependencies(libFBX2glTF
Draco
MathFu
FiFoMap
CPPCodec
)
if (NOT MSVC)
# Disable annoying & spammy warning from FBX SDK header file
target_compile_options(libFBX2glTF PRIVATE
"-Wno-null-dereference"
"-Wunused"
)
target_compile_options(FBX2glTF PRIVATE
"-Wno-null-dereference"
"-Wunused"
)
endif()
target_link_libraries(libFBX2glTF
${FRAMEWORKS}
${DRACO_LIB}
Boost::system
Boost::filesystem
Boost::nowide
optimized ${FBXSDK_LIBRARY}
debug ${FBXSDK_LIBRARY_DEBUG}
fmt::fmt
ZLIB::ZLIB
LibXml2::LibXml2
${ICONV_MAC_LIB}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
)
target_include_directories(libFBX2glTF PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_include_directories(libFBX2glTF SYSTEM PUBLIC
"third_party/stb"
"third_party/json"
${FBXSDK_INCLUDE_DIR}
${DRACO_INCLUDE_DIR}
${MATHFU_INCLUDE_DIRS}
${FIFO_MAP_INCLUDE_DIR}
${CPPCODEC_INCLUDE_DIR}
)
target_include_directories(FBX2glTF PUBLIC
"third_party/CLI11"
)
if (APPLE)
set(ICONV_MAC_LIB iconv)
endif()
target_link_libraries(FBX2glTF libFBX2glTF ${ICONV_MAC_LIB})
install (TARGETS libFBX2glTF FBX2glTF
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
)