mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
cmake: Fix build failure on msys2/mingw64
This is due to the use of `${SDL2_LIBRARIES}` over `SDL2::SDL2`. On some 'old' OSes such as Ubuntu 20.04, the SDL2 CMake config does not set an SDL2:SDL2 target but rather defines SDL2_LIBRARIES and SDL2_INCLUDE_DIRS variables. This patch creates an SDL2::SDL2 target, if not already set, based on those 2 variables.
This commit is contained in:
parent
a07942b782
commit
1ad168cfc5
|
@ -427,12 +427,10 @@ if(XRT_HAVE_OPENGLES AND NOT XRT_HAVE_EGL)
|
|||
endif()
|
||||
|
||||
if(XRT_HAVE_SDL2)
|
||||
if(NOT DEFINED SDL2_LIBRARIES)
|
||||
if(TARGET SDL2::SDL2-static)
|
||||
set(SDL2_LIBRARIES SDL2::SDL2-static)
|
||||
elseif(TARGET SDL2::SDL2)
|
||||
set(SDL2_LIBRARIES SDL2::SDL2)
|
||||
endif()
|
||||
if(NOT TARGET SDL2::SDL2 AND DEFINED SDL2_LIBRARIES)
|
||||
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||
target_include_directories(SDL2::SDL2 SYSTEM INTERFACE "${SDL2_INCLUDE_DIRS}")
|
||||
target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
4
src/external/CMakeLists.txt
vendored
4
src/external/CMakeLists.txt
vendored
|
@ -138,10 +138,8 @@ if(XRT_HAVE_OPENGL)
|
|||
target_link_libraries(
|
||||
xrt-external-imgui-sdl2
|
||||
PUBLIC xrt-external-imgui
|
||||
PUBLIC ${SDL2_LIBRARIES}
|
||||
PUBLIC SDL2::SDL2
|
||||
)
|
||||
|
||||
target_include_directories(xrt-external-imgui-sdl2 PUBLIC ${SDL2_INCLUDE_DIRS})
|
||||
target_include_directories(
|
||||
xrt-external-imgui-sdl2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
||||
)
|
||||
|
|
|
@ -163,7 +163,7 @@ if(XRT_FEATURE_DEBUG_GUI)
|
|||
|
||||
if(XRT_HAVE_SDL2)
|
||||
target_link_libraries(
|
||||
aux_util_debug_gui PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES}
|
||||
aux_util_debug_gui PRIVATE st_gui xrt-external-imgui-sdl2 SDL2::SDL2
|
||||
)
|
||||
|
||||
if(XRT_BUILD_DRIVER_QWERTY)
|
||||
|
|
|
@ -215,8 +215,7 @@ if(XRT_MODULE_COMPOSITOR_MAIN)
|
|||
endif()
|
||||
if(XRT_FEATURE_WINDOW_PEEK)
|
||||
target_sources(comp_main PRIVATE main/comp_window_peek.c)
|
||||
target_link_libraries(comp_main PRIVATE ${SDL2_LIBRARIES})
|
||||
target_include_directories(comp_main PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(comp_main PRIVATE SDL2::SDL2)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_sources(comp_main PRIVATE main/comp_window_mswin.c)
|
||||
|
|
|
@ -70,8 +70,7 @@ if(XRT_BUILD_DRIVER_QWERTY)
|
|||
qwerty/qwerty_prober.c
|
||||
qwerty/qwerty_sdl.c
|
||||
)
|
||||
target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util ${SDL2_LIBRARIES})
|
||||
target_include_directories(drv_qwerty PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util SDL2::SDL2)
|
||||
list(APPEND ENABLED_DRIVERS qwerty)
|
||||
|
||||
add_library(drv_qwerty_includes INTERFACE)
|
||||
|
|
|
@ -20,7 +20,6 @@ target_link_libraries(
|
|||
target_instance_no_comp
|
||||
xrt-external-imgui-sdl2
|
||||
)
|
||||
target_include_directories(gui PUBLIC ${SDL2_INCLUDE_DIRS})
|
||||
if(WIN32)
|
||||
target_link_libraries(gui PRIVATE SDL2::SDL2main)
|
||||
endif()
|
||||
|
|
|
@ -105,9 +105,9 @@ endif()
|
|||
|
||||
if(_have_opengl_test)
|
||||
target_link_libraries(
|
||||
tests_comp_client_opengl PRIVATE comp_client comp_mock aux_ogl ${SDL2_LIBRARIES}
|
||||
tests_comp_client_opengl PRIVATE comp_client comp_mock aux_ogl SDL2::SDL2
|
||||
)
|
||||
target_include_directories(tests_comp_client_opengl PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_include_directories(tests_comp_client_opengl PRIVATE SDL2::SDL2)
|
||||
endif()
|
||||
|
||||
if(XRT_HAVE_VULKAN AND XRT_HAVE_D3D11)
|
||||
|
|
Loading…
Reference in a new issue