diff options
author | erorcun <erorcunerorcun@hotmail.com.tr> | 2021-08-15 21:24:20 +0300 |
---|---|---|
committer | erorcun <erorcunerorcun@hotmail.com.tr> | 2021-08-16 15:20:40 +0300 |
commit | 4e40c6f2ed74776b1e46d368199e10c7dc18c7b8 (patch) | |
tree | d8e6c017db17e6f1f39540d66580078af0fea2bb /src | |
parent | 9deabc7b602e8c57b76ea9971aa61d6e7a0f2d0f (diff) |
Auto-detect X11 dependency
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/skel/glfw/glfw.cpp | 6 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7afdfa4d..b605d45b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,6 +130,22 @@ else() set(${PROJECT}_C_CXX_EXTENSIONS OFF) endif() +if(LIBRW_PLATFORM_GL3 AND LIBRW_GL3_GFXLIB STREQUAL "GLFW") + include(CheckSymbolExists) + + set(CMAKE_REQUIRED_LIBRARIES glfw) + set(CMAKE_REQUIRED_DEFINITIONS -DGLFW_EXPOSE_NATIVE_X11) + check_symbol_exists(glfwGetX11Display "GLFW/glfw3.h;GLFW/glfw3native.h" GLFW_HAS_X11) + unset(CMAKE_REQUIRED_DEFINITIONS) + unset(CMAKE_REQUIRED_LIBRARIES) + + if (GLFW_HAS_X11) + find_package(X11 REQUIRED) + target_link_libraries(${EXECUTABLE} PRIVATE X11::X11) + target_compile_definitions(${EXECUTABLE} PRIVATE GET_KEYBOARD_INPUT_FROM_X11) + endif (GLFW_HAS_X11) +endif() + set_target_properties(${EXECUTABLE} PROPERTIES C_STANDARD 11 diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index f8beee64..f1f97ee3 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -52,11 +52,7 @@ long _dwOperatingSystemVersion; #include "Font.h" #include "MemoryMgr.h" -// We found out that GLFW's keyboard input handling is still pretty delayed/not stable, so now we fetch input from X11 directly on Linux. -#if !defined _WIN32 && !defined __APPLE__ && !defined GTA_HANDHELD // && !defined WAYLAND -#define GET_KEYBOARD_INPUT_FROM_X11 -#endif - +// This is defined on project-level, via premake5 or cmake #ifdef GET_KEYBOARD_INPUT_FROM_X11 #include <X11/Xlib.h> #include <X11/XKBlib.h> |