summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liamwhite2022-12-06 09:58:48 -0500
committerGravatar GitHub2022-12-06 09:58:48 -0500
commita225ba4cda6a5e38af6cd7464d19754506152ec9 (patch)
tree3506ce99ec9730d6ae08e593c0c7a4979d9e8ce2
parentMerge pull request #9387 from abouvier/cmake-libusb (diff)
parentcmake: use sdl2 imported target (diff)
downloadyuzu-a225ba4cda6a5e38af6cd7464d19754506152ec9.tar.gz
yuzu-a225ba4cda6a5e38af6cd7464d19754506152ec9.tar.xz
yuzu-a225ba4cda6a5e38af6cd7464d19754506152ec9.zip
Merge pull request #9391 from abouvier/cmake-sdl
cmake: use sdl2 imported target
-rw-r--r--CMakeLists.txt16
-rw-r--r--src/audio_core/CMakeLists.txt6
-rw-r--r--src/input_common/CMakeLists.txt6
-rw-r--r--src/yuzu/CMakeLists.txt6
-rw-r--r--src/yuzu_cmd/CMakeLists.txt8
5 files changed, 7 insertions, 35 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2bdee819..cd59e7485 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -432,23 +432,13 @@ if (ENABLE_SDL2)
432 set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library") 432 set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library")
433 set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll") 433 set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll")
434 434
435 add_library(SDL2 INTERFACE) 435 add_library(SDL2::SDL2 INTERFACE IMPORTED)
436 target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") 436 target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARY}")
437 target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") 437 target_include_directories(SDL2::SDL2 INTERFACE "${SDL2_INCLUDE_DIR}")
438 elseif (YUZU_USE_EXTERNAL_SDL2) 438 elseif (YUZU_USE_EXTERNAL_SDL2)
439 message(STATUS "Using SDL2 from externals.") 439 message(STATUS "Using SDL2 from externals.")
440 else() 440 else()
441 find_package(SDL2 2.0.18 REQUIRED) 441 find_package(SDL2 2.0.18 REQUIRED)
442
443 # Some installations don't set SDL2_LIBRARIES
444 if("${SDL2_LIBRARIES}" STREQUAL "")
445 message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2")
446 set(SDL2_LIBRARIES "SDL2::SDL2")
447 endif()
448
449 include_directories(SYSTEM ${SDL2_INCLUDE_DIRS})
450 add_library(SDL2 INTERFACE)
451 target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}")
452 endif() 442 endif()
453endif() 443endif()
454 444
diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt
index f573a23e6..420ba62e0 100644
--- a/src/audio_core/CMakeLists.txt
+++ b/src/audio_core/CMakeLists.txt
@@ -227,11 +227,7 @@ if(ENABLE_CUBEB)
227 target_compile_definitions(audio_core PRIVATE -DHAVE_CUBEB=1) 227 target_compile_definitions(audio_core PRIVATE -DHAVE_CUBEB=1)
228endif() 228endif()
229if(ENABLE_SDL2) 229if(ENABLE_SDL2)
230 if (YUZU_USE_EXTERNAL_SDL2) 230 target_link_libraries(audio_core PRIVATE SDL2::SDL2)
231 target_link_libraries(audio_core PRIVATE SDL2-static)
232 else()
233 target_link_libraries(audio_core PRIVATE SDL2)
234 endif()
235 target_compile_definitions(audio_core PRIVATE HAVE_SDL2) 231 target_compile_definitions(audio_core PRIVATE HAVE_SDL2)
236endif() 232endif()
237 233
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt
index 2c9e1d359..7932aaab0 100644
--- a/src/input_common/CMakeLists.txt
+++ b/src/input_common/CMakeLists.txt
@@ -56,11 +56,7 @@ if (ENABLE_SDL2)
56 drivers/sdl_driver.cpp 56 drivers/sdl_driver.cpp
57 drivers/sdl_driver.h 57 drivers/sdl_driver.h
58 ) 58 )
59 if (YUZU_USE_EXTERNAL_SDL2) 59 target_link_libraries(input_common PRIVATE SDL2::SDL2)
60 target_link_libraries(input_common PRIVATE SDL2-static)
61 else()
62 target_link_libraries(input_common PRIVATE SDL2)
63 endif()
64 target_compile_definitions(input_common PRIVATE HAVE_SDL2) 60 target_compile_definitions(input_common PRIVATE HAVE_SDL2)
65endif() 61endif()
66 62
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 9971bdfab..d23eb2907 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -391,11 +391,7 @@ if (YUZU_USE_BUNDLED_QT AND QT_VERSION VERSION_LESS 6)
391endif() 391endif()
392 392
393if (ENABLE_SDL2) 393if (ENABLE_SDL2)
394 if (YUZU_USE_EXTERNAL_SDL2) 394 target_link_libraries(yuzu PRIVATE SDL2::SDL2)
395 target_link_libraries(yuzu PRIVATE SDL2-static)
396 else()
397 target_link_libraries(yuzu PRIVATE SDL2)
398 endif()
399 target_compile_definitions(yuzu PRIVATE HAVE_SDL2) 395 target_compile_definitions(yuzu PRIVATE HAVE_SDL2)
400endif() 396endif()
401 397
diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt
index 19b1d258c..f6eeb9d8d 100644
--- a/src/yuzu_cmd/CMakeLists.txt
+++ b/src/yuzu_cmd/CMakeLists.txt
@@ -43,13 +43,7 @@ target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
43create_resource("../../dist/yuzu.bmp" "yuzu_cmd/yuzu_icon.h" "yuzu_icon") 43create_resource("../../dist/yuzu.bmp" "yuzu_cmd/yuzu_icon.h" "yuzu_icon")
44target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR}) 44target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR})
45 45
46target_link_libraries(yuzu-cmd PRIVATE Vulkan::Headers) 46target_link_libraries(yuzu-cmd PRIVATE SDL2::SDL2 Vulkan::Headers)
47
48if (YUZU_USE_EXTERNAL_SDL2)
49 target_link_libraries(yuzu-cmd PRIVATE SDL2-static)
50else()
51 target_link_libraries(yuzu-cmd PRIVATE SDL2)
52endif()
53 47
54if(UNIX AND NOT APPLE) 48if(UNIX AND NOT APPLE)
55 install(TARGETS yuzu-cmd) 49 install(TARGETS yuzu-cmd)