forked from markaren/threepp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
115 lines (90 loc) · 3.87 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
cmake_minimum_required(VERSION 3.18)
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/version.txt" projectVersion)
project(threepp VERSION ${projectVersion})
message("Current ${PROJECT_NAME} version: ${CMAKE_PROJECT_VERSION}\n")
option(THREEPP_BUILD_EXAMPLES "Build examples" ON)
option(THREEPP_BUILD_EXAMPLE_PROJECTS "Build example projects" OFF)
option(THREEPP_BUILD_TESTS "Build test suite" ON)
option(THREEPP_USE_CUSTOM_BACKEND "Use custom backend" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# ==============================================================================
# Global internal configuration
# ==============================================================================
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# ==============================================================================
# Dependencies
# ==============================================================================
if(NOT THREEPP_USE_CUSTOM_BACKEND)
find_package(glfw3 CONFIG REQUIRED)
else()
add_definitions(-DCUSTOM_BACKEND)
endif()
find_package(glad CONFIG REQUIRED)
find_package(nlohmann_json CONFIG QUIET)
find_package(CURL CONFIG QUIET)
find_package(assimp CONFIG QUIET)
find_package(stb CONFIG QUIET)
if (NOT THREEPP_USE_CUSTOM_BACKEND AND NOT TARGET "glfw::glfw" AND TARGET "glfw")
add_library(glfw::glfw ALIAS glfw)
endif()
if (NOT stb_INCLUDE_DIR)
find_path(stb_INCLUDE_DIR "stb_c_lexer.h" REQUIRED)
endif()
include(FetchContent)
FetchContent_Declare(
glText
GIT_REPOSITORY https://github.com/vallentin/glText.git
GIT_TAG 8200fa70e32acec0a3cd777d404f41ee0c203ca4
)
FetchContent_Populate(glText)
set(gltext_INCLUDE_DIR "${gltext_SOURCE_DIR}")
add_subdirectory(src)
if (THREEPP_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()
if (THREEPP_BUILD_TESTS)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.8
)
FetchContent_MakeAvailable(Catch2)
enable_testing()
add_subdirectory(tests)
endif ()
# ==============================================================================
# Application resources
# ==============================================================================
# Data files
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data/favicon.png" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data/models" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin/data)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data/textures" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin/data)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data/fonts" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin/data)
# ==============================================================================
# Exports and remaining installation
# ==============================================================================
configure_package_config_file(cmake/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/threepp-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/threepp
NO_SET_AND_CHECK_MACRO)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/threepp-config-version.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/threepp-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/threepp-config-version.cmake
DESTINATION
${CMAKE_INSTALL_DATADIR}/threepp)
install(TARGETS threepp EXPORT threepp-targets)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT threepp-targets
NAMESPACE threepp::
DESTINATION ${CMAKE_INSTALL_DATADIR}/threepp)