The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

authored by

samuel degrande and committed by
Jakob Bornecrantz
1ad168cf a07942b7

+10 -17
+4 -6
CMakeLists.txt
··· 427 427 endif() 428 428 429 429 if(XRT_HAVE_SDL2) 430 - if(NOT DEFINED SDL2_LIBRARIES) 431 - if(TARGET SDL2::SDL2-static) 432 - set(SDL2_LIBRARIES SDL2::SDL2-static) 433 - elseif(TARGET SDL2::SDL2) 434 - set(SDL2_LIBRARIES SDL2::SDL2) 435 - endif() 430 + if(NOT TARGET SDL2::SDL2 AND DEFINED SDL2_LIBRARIES) 431 + add_library(SDL2::SDL2 INTERFACE IMPORTED) 432 + target_include_directories(SDL2::SDL2 SYSTEM INTERFACE "${SDL2_INCLUDE_DIRS}") 433 + target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARIES}") 436 434 endif() 437 435 endif() 438 436
+1 -3
src/external/CMakeLists.txt
··· 138 138 target_link_libraries( 139 139 xrt-external-imgui-sdl2 140 140 PUBLIC xrt-external-imgui 141 - PUBLIC ${SDL2_LIBRARIES} 141 + PUBLIC SDL2::SDL2 142 142 ) 143 - 144 - target_include_directories(xrt-external-imgui-sdl2 PUBLIC ${SDL2_INCLUDE_DIRS}) 145 143 target_include_directories( 146 144 xrt-external-imgui-sdl2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui 147 145 )
+1 -1
src/xrt/auxiliary/util/CMakeLists.txt
··· 163 163 164 164 if(XRT_HAVE_SDL2) 165 165 target_link_libraries( 166 - aux_util_debug_gui PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES} 166 + aux_util_debug_gui PRIVATE st_gui xrt-external-imgui-sdl2 SDL2::SDL2 167 167 ) 168 168 169 169 if(XRT_BUILD_DRIVER_QWERTY)
+1 -2
src/xrt/compositor/CMakeLists.txt
··· 215 215 endif() 216 216 if(XRT_FEATURE_WINDOW_PEEK) 217 217 target_sources(comp_main PRIVATE main/comp_window_peek.c) 218 - target_link_libraries(comp_main PRIVATE ${SDL2_LIBRARIES}) 219 - target_include_directories(comp_main PRIVATE ${SDL2_INCLUDE_DIRS}) 218 + target_link_libraries(comp_main PRIVATE SDL2::SDL2) 220 219 endif() 221 220 if(WIN32) 222 221 target_sources(comp_main PRIVATE main/comp_window_mswin.c)
+1 -2
src/xrt/drivers/CMakeLists.txt
··· 70 70 qwerty/qwerty_prober.c 71 71 qwerty/qwerty_sdl.c 72 72 ) 73 - target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util ${SDL2_LIBRARIES}) 74 - target_include_directories(drv_qwerty PRIVATE ${SDL2_INCLUDE_DIRS}) 73 + target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util SDL2::SDL2) 75 74 list(APPEND ENABLED_DRIVERS qwerty) 76 75 77 76 add_library(drv_qwerty_includes INTERFACE)
-1
src/xrt/targets/gui/CMakeLists.txt
··· 20 20 target_instance_no_comp 21 21 xrt-external-imgui-sdl2 22 22 ) 23 - target_include_directories(gui PUBLIC ${SDL2_INCLUDE_DIRS}) 24 23 if(WIN32) 25 24 target_link_libraries(gui PRIVATE SDL2::SDL2main) 26 25 endif()
+2 -2
tests/CMakeLists.txt
··· 105 105 106 106 if(_have_opengl_test) 107 107 target_link_libraries( 108 - tests_comp_client_opengl PRIVATE comp_client comp_mock aux_ogl ${SDL2_LIBRARIES} 108 + tests_comp_client_opengl PRIVATE comp_client comp_mock aux_ogl SDL2::SDL2 109 109 ) 110 - target_include_directories(tests_comp_client_opengl PRIVATE ${SDL2_INCLUDE_DIRS}) 110 + target_include_directories(tests_comp_client_opengl PRIVATE SDL2::SDL2) 111 111 endif() 112 112 113 113 if(XRT_HAVE_VULKAN AND XRT_HAVE_D3D11)