-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (96 loc) · 3.35 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
cmake_minimum_required(VERSION 3.14.7)
project(uikit
VERSION 0.2.0
DESCRIPTION "A set of libraries for application development."
LANGUAGES C CXX)
option(UIKIT_PYTHON "Whether or not to build the Python bindings." OFF)
option(UIKIT_INSTALL "Whether or not to build the install rules." OFF)
option(UIKIT_BUILD_GLFW "Whether or not to download and build GLFW." OFF)
option(UIKIT_BUILD_PYBIND11 "Whether or not to download and build pybind11." OFF)
option(UIKIT_MAIN "Whether or not to build the entry point code." OFF)
set(GLFW_URL "https://github.com/glfw/glfw/archive/refs/tags/3.4.zip" CACHE STRING "The release URL of GLFW.")
set(IMGUI_URL "https://github.com/ocornut/imgui/archive/refs/tags/v1.89.9-docking.zip" CACHE STRING "The release URL of ImGui.")
set(IMPLOT_URL "https://github.com/epezent/implot/archive/refs/tags/v0.16.zip" CACHE STRING "The release URL of ImPlot.")
set(PYBIND11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.zip" CACHE STRING "The release URL of pybind11.")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/overrides.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/overrides.cmake")
endif()
if(UIKIT_PYTHON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
if(NOT EMSCRIPTEN)
if(UIKIT_BUILD_GLFW)
include(cmake/GLFW.cmake)
else()
find_package(glfw3 CONFIG REQUIRED)
endif()
add_subdirectory(gles2)
endif()
include(cmake/ImGui.cmake)
include(cmake/ImPlot.cmake)
include(cmake/CMakeRC.cmake)
cmrc_add_resource_library(uikit_font_data
"fonts/JetBrainsMonoNL-Regular.ttf"
"fonts/JetBrainsMonoNL-Italic.ttf"
"fonts/JetBrainsMonoNL-Bold.ttf"
"fonts/JetBrainsMonoNL-BoldItalic.ttf"
WHENCE "fonts")
if(NOT EMSCRIPTEN)
FetchContent_Declare(pfd URL "https://github.com/samhocevar/portable-file-dialogs/archive/refs/tags/0.1.0.zip")
FetchContent_MakeAvailable(pfd)
endif()
add_library(uikit STATIC
include/uikit/shader_compiler.hpp
include/uikit/fonts.hpp
include/uikit/viewport.hpp
src/fonts.cpp
src/shader_compiler.cpp
src/viewport.cpp)
target_include_directories(uikit PUBLIC include)
target_link_libraries(uikit
PUBLIC
uikit_font_data
imgui::imgui
imgui::opengl3
implot::implot)
if(EMSCRIPTEN)
target_link_libraries(uikit PUBLIC imgui::sdl2)
else()
target_link_libraries(uikit PUBLIC imgui::glfw glfw glad::glad portable_file_dialogs)
endif()
add_library(uikit::uikit ALIAS uikit)
if(UIKIT_PYTHON)
add_subdirectory(python)
endif()
if(UIKIT_MAIN)
set(main_file)
if(EMSCRIPTEN)
set(main_file src/main_emscripten.cpp)
else()
set(main_file src/main.cpp)
endif()
add_library(uikit_main STATIC
${main_file}
include/uikit/main.hpp
sago/platform_folders.h
sago/platform_folders.cpp
src/platform_base.h
src/platform_base.cpp)
target_include_directories(uikit_main PUBLIC include)
target_link_libraries(uikit_main PUBLIC uikit::uikit)
add_library(uikit::main ALIAS uikit_main)
if(EMSCRIPTEN)
target_compile_options(uikit_main PUBLIC "SHELL: -s USE_SDL=2")
target_link_options(uikit_main
PUBLIC
"SHELL: -s USE_SDL=2")
endif()
endif()
if((CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) AND UIKIT_MAIN)
add_executable(demo WIN32
demo/main.cpp)
target_link_libraries(demo PUBLIC uikit::main)
endif()