From af786beba6e195dea9ca02ae47315945c8f9b1c8 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 24 Jan 2019 09:28:17 +0100 Subject: fix the SDL2 library search This allows to handle two variants of SDL2 find modules, which are incompatible: - the first kind of module sets the SDL2_* variables - the other kind exports the library target SDL2::SDL2 --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4355b75..7cffbda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,6 +233,20 @@ else() add_library(ADLMIDI ALIAS ADLMIDI_static) endif() +function(libADLMIDI_find_SDL2) + if(NOT TARGET ADLMIDI_SDL2) + find_package(SDL2 REQUIRED) + add_library(ADLMIDI_SDL2 INTERFACE) + if(TARGET SDL2::SDL2) + target_link_libraries(ADLMIDI_SDL2 INTERFACE SDL2::SDL2) + else() + string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES) + target_include_directories(ADLMIDI_SDL2 INTERFACE ${SDL2_INCLUDE_DIRS}) + target_link_libraries(ADLMIDI_SDL2 INTERFACE ${SDL2_LIBRARIES}) + endif() + endif() +endfunction() + if(WITH_OLD_UTILS) # Old utility to dump AdLib bank files add_subdirectory(utils/dumpbank) -- cgit v1.2.3