From 210894ed8305fdb322bb2c86518067d643848e4c Mon Sep 17 00:00:00 2001 From: wdl1697454803 <50978870+wdl1697454803@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:27:44 +0800 Subject: [PATCH] Use find_package when pkg_check_modules fails Fixed the issue that when the cmake version was earlier than 3.6.0, the pkg_check_modules did not support IMPORTED_TARGET parameters, resulting in the SDL2 library not being found --- player/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/player/CMakeLists.txt b/player/CMakeLists.txt index 9c2d74f6..e36b2a46 100644 --- a/player/CMakeLists.txt +++ b/player/CMakeLists.txt @@ -21,8 +21,6 @@ # SOFTWARE. # -cmake_minimum_required(VERSION 3.6.0) - set(LINK_LIBRARIES ${MK_LINK_LIBRARIES}) find_package(PkgConfig QUIET) @@ -33,7 +31,9 @@ if(PKG_CONFIG_FOUND) list(APPEND LINK_LIBRARIES PkgConfig::SDL2) message(STATUS "found library: ${SDL2_LIBRARIES}") endif() -else() +endif() + +if(NOT SDL2_FOUND) find_package(SDL2 QUIET) if(SDL2_FOUND) include_directories(SYSTEM ${SDL2_INCLUDE_DIR})