-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
136 lines (120 loc) · 6.31 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
########################################################################################
# This file is licensed under CC0: #
# #
# https://github.com/svenevs/nanogui-customization-demo/blob/master/LICENSE #
########################################################################################
project("nanogui-customization-demo")
cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR)
# CMAKE_CXX_STANDARD introduced in v3.1.3
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Doing this makes testing easier, NanoGUI example* will all go to ./bin/
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
# Populate the list of extra fonts NanoGUI should compile.
list(APPEND NANOGUI_EXTRA_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/resources/spirax/Spirax-Regular.ttf")
list(APPEND NANOGUI_EXTRA_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/resources/membra/membra.ttf")
list(APPEND NANOGUI_EXTRA_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/resources/spectral/SpectralSC-Regular.ttf")
list(APPEND NANOGUI_EXTRA_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/resources/spectral/SpectralSC-Bold.ttf")
# Setup the custom icon font for NanoGUI, the requirements are that these files are
# all in the same directory:
#
# - some/path/fontawesome.ttf <- The font to embed.
# - some/path/fontawesome.h <- C++ header that #define's the constants.
# - some/path/constants_fontawesome.cpp <- Python bindings.
list(APPEND NANOGUI_EXTRA_ICON_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/resources/fontawesome/fontawesome.ttf")
# NOTE: see http://nanogui.readthedocs.io/en/latest/compilation.html#default-configurations
# these are slightly different, as this is a testing repo.
set(NANOGUI_BUILD_EXAMPLE ON CACHE BOOL " " FORCE)# dev repo, testing c++ examples
set(NANOGUI_BUILD_PYTHON ON CACHE BOOL " " FORCE)# dev repo, testing python examples
set(NANOGUI_INSTALL OFF CACHE BOOL " " FORCE)
if (NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ext/nanogui/include")
message(FATAL_ERROR "The NanoGUI dependency is missing! You probably did not "
"clone the project with --recursive. It is possible to "
"recover by calling\n "
"git submodule update --init --recursive")
endif()
# Add the configurations from nanogui
add_subdirectory(ext/nanogui)
# For reliability of parallel build, make the NanoGUI targets dependencies
# Addition of nanogui-python is specific to this repo.
set_property(TARGET glfw_objects nanogui nanogui-python PROPERTY FOLDER "dependencies")
# Various preprocessor definitions have been generated by NanoGUI
add_definitions(${NANOGUI_EXTRA_DEFS})
# On top of adding the path to nanogui/include, you may need extras
include_directories(ext/nanogui/include ${NANOGUI_EXTRA_INCS})
add_executable(custom_theme_and_fonts
cpp/custom_screen.hpp
cpp/custom_theme.hpp
cpp/gl_texture.hpp
cpp/make_compare_window.hpp
cpp/custom_theme_and_fonts.cpp
)
# Lastly, additional libraries may have been built for you. In addition to linking
# against NanoGUI, we need to link against those as well.
target_link_libraries(custom_theme_and_fonts nanogui ${NANOGUI_EXTRA_LIBS})
add_executable(custom_icon_theme_and_fonts
cpp/custom_screen.hpp
cpp/custom_theme.hpp
cpp/gl_texture.hpp
cpp/make_compare_window.hpp
cpp/custom_icon_theme_and_fonts.cpp
)
target_link_libraries(custom_icon_theme_and_fonts nanogui ${NANOGUI_EXTRA_LIBS})
add_executable(example_fontawesome cpp/example_fontawesome.cpp)
target_link_libraries(example_fontawesome nanogui ${NANOGUI_EXTRA_LIBS})
########################################################################################
# Everything below here is "advanced", and should not be required for your own project #
# using NanoGUI. This repository was used to aid the development of custom font #
# support for NanoGUI, and everything below is here to make that development easier. #
#
# AKA you should happily ignore everything going on here.
########################################################################################
# Always run e.g., ./bin/example1 (icons directory needs to be in current working dir)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icons")
file(GLOB NANOGUI_EXAMPLE_ICONS "${CMAKE_CURRENT_BINARY_DIR}/ext/nanogui/icons/*.png")
foreach (png ${NANOGUI_EXAMPLE_ICONS})
file(COPY "${png}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/icons")
endforeach()
# Make testing the python bindings easier.
set(TEST_PYTHON_DIR "${CMAKE_CURRENT_BINARY_DIR}/python")
file(MAKE_DIRECTORY "${TEST_PYTHON_DIR}")
add_custom_command(
TARGET example_fontawesome # nanogui-python is a dependency, you cannot add a custom
POST_BUILD # command for a target created in a different CMakeLists.txt
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:nanogui-python> "${TEST_PYTHON_DIR}"
)
list(APPEND NANOGUI_PYTHON_EXAMPLES "example2.py;example3.py;example4.py;example_icons.py")
set(NANOGUI_PY_EXAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/nanogui/python")
foreach (pythonExample ${NANOGUI_PYTHON_EXAMPLES})
file(
COPY "${NANOGUI_PY_EXAMPLE_DIR}/${pythonExample}"
DESTINATION "${TEST_PYTHON_DIR}"
)
endforeach()
# Example 1 is special
file(READ "${NANOGUI_PY_EXAMPLE_DIR}/example1.py" NANOGUI_PY_EXAMPLE_1_TEXT)
string(
REPLACE
"os.chdir(sys.path[0])"
"# os.chdir(sys.path[0])"
NANOGUI_PY_EXAMPLE_1_TEXT_FIXED
"${NANOGUI_PY_EXAMPLE_1_TEXT}"
)
file(WRITE "${TEST_PYTHON_DIR}/example1.py" "${NANOGUI_PY_EXAMPLE_1_TEXT_FIXED}")
# Copy the example customization python demo files
list(APPEND CUSTOM_PYTHON_TESTS custom_theme_and_fonts.py)
list(APPEND CUSTOM_PYTHON_TESTS example_fontawesome.py)
list(APPEND CUSTOM_PYTHON_TESTS custom_icon_theme_and_fonts.py)
list(APPEND CUSTOM_PYTHON_TESTS custom_screen.py)
list(APPEND CUSTOM_PYTHON_TESTS custom_theme.py)
list(APPEND CUSTOM_PYTHON_TESTS make_compare_window.py)
list(APPEND CUSTOM_PYTHON_TESTS theme_builder.py)
foreach(py ${CUSTOM_PYTHON_TESTS})
file(
COPY "${CMAKE_CURRENT_SOURCE_DIR}/python/${py}"
DESTINATION "${TEST_PYTHON_DIR}"
)
endforeach()