Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the build on OpenBSD #136

Merged
merged 1 commit into from May 6, 2022
Merged

fix the build on OpenBSD #136

merged 1 commit into from May 6, 2022

Conversation

guijan
Copy link
Contributor

@guijan guijan commented Apr 29, 2022

Hi, the build fails on OpenBSD because the X11 include directory is missing. This small change fixes it.

The FindX11.cmake module seems to only trigger on Unix so I'm not putting it in a conditional or anything: https://github.com/Kitware/CMake/blob/3585d117e8da6e3423d515616b3fcc4869cbd817/Modules/FindX11.cmake#L93

@k4zmu2a
Copy link
Owner

k4zmu2a commented May 4, 2022

Hello.

This fix looks fine to me, but first I would like to you to try an alternative solution.
Add SDL defines that hide X11 includes from SDL headers, should be safe to do since the game does not use SDL_SYSWMEVENT or EGL.

Pch.h:
#define SDL_MAIN_HANDLED
#define SDL_PROTOTYPES_ONLY
#define MESA_EGL_NO_X11_HEADERS
#include "SDL.h"
#include <SDL_mixer.h>

@guijan
Copy link
Contributor Author

guijan commented May 4, 2022

Still fails with that fix:

$ cmake --build build --config Release                              
[8/69] Building CXX object CMakeFiles/SpaceCad...all.dir/SpaceCadetPinball/imgui_impl_sdl.cpp.o
FAILED: CMakeFiles/SpaceCadetPinball.dir/SpaceCadetPinball/imgui_impl_sdl.cpp.o 
/usr/bin/c++  -I/usr/local/include/SDL2 -std=gnu++11 -MD -MT CMakeFiles/SpaceCadetPinball.dir/SpaceCadetPinball/imgui_impl_sdl.cpp.o -MF CMakeFiles/SpaceCadetPinball.dir/SpaceCadetPinball/imgui_impl_sdl.cpp.o.d -o CMakeFiles/SpaceCadetPinball.dir/SpaceCadetPinball/imgui_impl_sdl.cpp.o -c ../SpaceCadetPinball/imgui_impl_sdl.cpp
In file included from ../SpaceCadetPinball/imgui_impl_sdl.cpp:58:
/usr/local/include/SDL2/SDL_syswm.h:69:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^~~~~~~~~~~~
1 error generated.
[13/69] Building CXX object CMakeFiles/SpaceCadetPinball.dir/SpaceCadetPinball/control.cpp.o
ninja: build stopped: subcommand failed.

@k4zmu2a
Copy link
Owner

k4zmu2a commented May 5, 2022

Ok, so the source of X11 include leak is not SDL.h in pch.
As it turns out, there is a direct include of SDL_syswm.h in ImGui, and it is only needed on win32.

Disregard the previous fix; try this next, in imgui_impl_sdl.cpp:
// SDL
#include <SDL.h>
#ifdef _WIN32
#include <SDL_syswm.h>
#endif

This fixes the build on OpenBSD.
@guijan
Copy link
Contributor Author

guijan commented May 5, 2022

That change does fix the build on OpenBSD, I've updated the PR with it.

@k4zmu2a k4zmu2a merged commit 3f7526b into k4zmu2a:master May 6, 2022
@k4zmu2a
Copy link
Owner

k4zmu2a commented May 6, 2022

Merged.
It is good that it works without unnecessary CMake package dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants