Skip to content

Commit 6195bd0

Browse files
authored
Imgui generic path resolving via pkg-config (project-chip#42056)
* build: paths to homebrew sdl on macos corrected * build: readded _REENTRANT flag for linux cflags * comment: keep the old FUTURE comment
1 parent a0136a5 commit 6195bd0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

third_party/imgui/BUILD.gn

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17+
import("${build_root}/config/linux/pkg_config.gni")
18+
19+
pkg_config("sdl2_pkgconfig") {
20+
packages = [ "sdl2" ]
21+
}
1722

1823
config("imgui_config") {
1924
include_dirs = [
@@ -22,18 +27,17 @@ config("imgui_config") {
2227
]
2328
defines = [ "CHIP_IMGUI_ENABLED=1" ]
2429

25-
# FUTURE: these should be parsed from `sdl2-config --cflags`
30+
# Use pkg-config for SDL2 on all platforms
31+
# FUTURE: SDL2 libs should be from `sdl2-config --libs`
32+
configs = [ ":sdl2_pkgconfig" ]
33+
2634
if (current_os == "mac") {
27-
# Default path setup by `brew install sdl2`
28-
include_dirs += [ "/usr/local/include/SDL2" ]
2935
defines += [ "_THREAD_SAFE" ]
3036
ldflags = [
3137
"-framework",
3238
"OpenGL",
3339
]
3440
} else {
35-
# Linux defaults
36-
include_dirs += [ "/usr/include/SDL2" ]
3741
defines += [ "_REENTRANT" ]
3842
}
3943
}
@@ -61,14 +65,12 @@ source_set("imgui") {
6165
"repo/backends/imgui_impl_sdl2.h",
6266
]
6367

64-
# FUTURE: SDL2 libs should be from `sdl2-config --libs`
65-
libs = [
66-
"SDL2",
67-
"dl",
68-
]
69-
68+
# Additional libs needed on Linux beyond what pkg-config provides
7069
if (current_os == "linux") {
71-
libs += [ "GL" ]
70+
libs = [
71+
"dl",
72+
"GL",
73+
]
7274
}
7375

7476
public_configs = [ ":imgui_config" ]

0 commit comments

Comments
 (0)