-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
118 lines (95 loc) · 4.15 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
cmake_minimum_required (VERSION 3.9.0)
project (BsZenLib)
option(BSZENLIB_BUILD_SAMPLES "Whether to build BsZenLib samples" OFF)
option(BSZENLIB_BUILD_DOCS "Whether to add targets to build the documentation" OFF)
option(BSZENLIB_DOWNLOAD_BSF_BINARIES "Download and use precompiled binaries for bsf." OFF)
option(BSZENLIB_SKIP_FIND_BSF "When set, BsZenLib will not try to find and build bsf." OFF)
set(BSZENLIB_BSF_SUBMODULE_PATH "" CACHE PATH "Path to bsf sources to add as cmake subdirectory")
# Add necessary compiler flags
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" OR
CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# This is what the example file does, is this really needed at a global scale?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -g")
endif()
# Make sure to use the C++14 standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
###############################################################################
# Optional Prebuilt bs:f Download #
###############################################################################
if (BSZENLIB_DOWNLOAD_BSF_BINARIES)
message(STATUS "Downloading prebuilt bs:f...")
include(FetchContent)
set(bsf_INSTALL_DIR ${CMAKE_BINARY_DIR}/bsf-binaries CACHE PATH "" FORCE)
if (WIN32)
FetchContent_Declare(bsfBinaries
SOURCE_DIR ${bsf_INSTALL_DIR}
URL https://dilborceisv8p.cloudfront.net/bsf_2019.01.23_win64.zip
)
elseif (APPLE)
FetchContent_Declare(bsfBinaries
SOURCE_DIR ${bsf_INSTALL_DIR}
URL https://dilborceisv8p.cloudfront.net/bsf_2019.01.23_osx.tar.gz
)
elseif (UNIX)
FetchContent_Declare(bsfBinaries
SOURCE_DIR ${bsf_INSTALL_DIR}
URL https://dilborceisv8p.cloudfront.net/bsf_2019.01.23_linux.tar.gz
)
else()
message(FATAL_ERROR "No prebuilt binaries available for this platform!")
endif()
FetchContent_Populate(bsfBinaries)
endif()
###############################################################################
# Add external libraries #
###############################################################################
# Let CMake know where to find the Findbsf.cmake file (at current folder)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
if(NOT BSZENLIB_SKIP_FIND_BSF)
if(BSZENLIB_BSF_SUBMODULE_PATH)
# Optionally include bsf as cmake submodule for easier development on bsf
add_subdirectory(${BSZENLIB_BSF_SUBMODULE_PATH} bsf)
else()
# Find bsf libraries and headers
find_package(bsf REQUIRED)
endif()
endif()
add_subdirectory(lib/ZenLib)
###############################################################################
# Add main library #
###############################################################################
add_library(BsZenLib
src/ImportSkeletalMesh.cpp
src/ImportStaticMesh.cpp
src/ImportMorphMesh.cpp
src/ImportTexture.cpp
src/ImportMaterial.cpp
src/ImportZEN.cpp
src/ImportPath.cpp
src/ImportAnimation.cpp
src/ImportFont.cpp
src/ZenResources.cpp
src/ResourceManifest.cpp
src/CacheUtility.cpp
)
target_link_libraries(BsZenLib PRIVATE bsf daedalus zenload vdfs utils)
target_include_directories(BsZenLib PRIVATE include/BsZenLib)
target_link_libraries(BsZenLib PUBLIC vdfs)
target_include_directories(BsZenLib PUBLIC include)
# Make sure our calls to BS_LOG work
target_compile_definitions(BsZenLib PRIVATE -DBS_LOG_VERBOSITY=LogVerbosity::Log)
# target_link_libraries(BsZenLib PRIVATE bsfFreeImgImporter)
# target_include_directories(BsZenLib PRIVATE lib/FreeImage)
###############################################################################
# Add Samples, etc #
###############################################################################
if (BSZENLIB_BUILD_SAMPLES)
add_subdirectory(samples)
endif()
if (BSZENLIB_BUILD_DOCS)
add_subdirectory(docs-source)
endif()