forked from slages/love-imgui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
148 lines (129 loc) · 4.3 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
PROJECT(imgui-bindings)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
OPTION(EnableCodeGen "automatically recompile the code-generated imgui header. requires luajit." ON)
OPTION(EnableLove "build the love-imgui bindings" ON)
OPTION(EnableWren "build the wren sdl+vulkan example bindings" ON)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
IF(EnableCodeGen)
find_package(LuaJIT REQUIRED)
SET(BindSource
bindings2/generate_bindings.lua
bindings2/parse.lua
bindings2/util.lua
bindings2/buffer.lua
bindings2/wren/types.lua
bindings2/wren/generate.lua
bindings2/wren/wrap_imgui_codegen.cpp
bindings2/wren/wrap_imgui_codegen.h
bindings2/wren/imgui.wren
bindings2/wren/api_details.md
bindings2/lua/types.lua
bindings2/lua/generate.lua
bindings2/lua/generate_autocomplete.lua
bindings2/lua/wrap_imgui_codegen.cpp
bindings2/lua/wrap_imgui_codegen.h
bindings2/lua/api_details.md
bindings2/lua/autocomplete.json
deps/libimgui/imgui.h
deps/libimgui/misc/cpp/imgui_stdlib.h
)
SET(BindOutput
${CMAKE_SOURCE_DIR}/src/wren-bindings/wrap_imgui_codegen.h
${CMAKE_SOURCE_DIR}/src/wren-bindings/wrap_imgui_codegen.cpp
${CMAKE_SOURCE_DIR}/src/wren-bindings/api_details.md
${CMAKE_SOURCE_DIR}/src/lua-bindings/wrap_imgui_codegen.h
${CMAKE_SOURCE_DIR}/src/lua-bindings/wrap_imgui_codegen.cpp
${CMAKE_SOURCE_DIR}/src/lua-bindings/api_details.md
${CMAKE_SOURCE_DIR}/src/lua-bindings/autocomplete.json
)
ADD_CUSTOM_COMMAND(
COMMAND ${LUAJIT_EXE} ${CMAKE_SOURCE_DIR}/bindings2/generate_bindings.lua
DEPENDS ${BindSource}
OUTPUT ${BindOutput}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating bindings"
)
ENDIF()
ADD_LIBRARY(imgui
STATIC
deps/libimgui/imconfig.h
deps/libimgui/imgui.cpp
deps/libimgui/imgui.h
deps/libimgui/imgui_demo.cpp
deps/libimgui/imgui_draw.cpp
deps/libimgui/imgui_internal.h
deps/libimgui/imgui_tables.cpp
deps/libimgui/imgui_widgets.cpp
deps/libimgui/imstb_rectpack.h
deps/libimgui/imstb_textedit.h
deps/libimgui/imstb_truetype.h
# NOTICE: we do use imgui_stdlib. will maybe inline this in the future
deps/libimgui/misc/cpp/imgui_stdlib.cpp
deps/libimgui/misc/cpp/imgui_stdlib.h
)
TARGET_INCLUDE_DIRECTORIES(imgui
PUBLIC
deps/libimgui
deps/libimgui/misc/cpp
)
SET_PROPERTY(TARGET imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
##############################################
# love-imgui: prebuilt integration with love2d
##############################################
if(EnableLove)
find_package(LuaJIT REQUIRED)
ADD_LIBRARY(love-imgui
MODULE
src/love-imgui/imgui_impl.cpp
src/love-imgui/imgui_impl.h
src/love-imgui/wrap_imgui_impl.cpp
src/love-imgui/wrap_imgui_impl.h
src/lua-bindings/wrap_imgui_codegen.cpp
src/lua-bindings/wrap_imgui_codegen.h
)
TARGET_INCLUDE_DIRECTORIES(love-imgui
PUBLIC
${LUAJIT_INCLUDE_DIR}
src/lua-bindings
)
TARGET_LINK_LIBRARIES(love-imgui ${LUAJIT_LIBRARY} imgui)
SET_PROPERTY(TARGET love-imgui PROPERTY CXX_STANDARD 17)
SET_TARGET_PROPERTIES(love-imgui PROPERTIES PREFIX "")
if(MSVC)
else()
TARGET_COMPILE_OPTIONS(love-imgui PRIVATE -Wconversion)
SET_SOURCE_FILES_PROPERTIES(src/lua-bindings/wrap_imgui_codegen.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-function -Wno-unused-parameter")
endif()
INSTALL(TARGETS love-imgui LIBRARY DESTINATION lib)
endif()
##############################################
# Wren example: this uses the SDL/Vulkan integration demoed in the imgui repo
##############################################
if(EnableWren)
find_package(SDL2 REQUIRED)
find_package(Vulkan REQUIRED)
include(wren)
set_property(TARGET wren PROPERTY POSITION_INDEPENDENT_CODE ON)
ADD_EXECUTABLE(wren-example-imgui
src/wren-bindings/wrap_imgui_codegen.cpp
src/wren-bindings/wrap_imgui_codegen.h
deps/libimgui/backends/imgui_impl_sdl.cpp
deps/libimgui/backends/imgui_impl_vulkan.cpp
src/wren-example-imgui/main.cpp
)
TARGET_INCLUDE_DIRECTORIES(wren-example-imgui
PUBLIC
src/wren-bindings
deps/libimgui/backends
"${SDL2_INCLUDE_DIR}"
"${SDL2_INCLUDE_DIR}/SDL2"
"${Vulkan_INCLUDE_DIR}"
)
TARGET_LINK_LIBRARIES(wren-example-imgui wren imgui ${SDL2_LIBRARY} ${Vulkan_LIBRARIES})
SET_PROPERTY(TARGET wren-example-imgui PROPERTY CXX_STANDARD 17)
SET_TARGET_PROPERTIES(wren-example-imgui PROPERTIES PREFIX "")
if(MSVC)
else()
TARGET_COMPILE_OPTIONS(wren-example-imgui PRIVATE -Wconversion)
endif()
endif()