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
This commit is contained in:
wdl1697454803 2024-03-01 13:27:44 +08:00 committed by Xiaofeng Wang
parent a554fab5fb
commit 210894ed83

View File

@ -21,8 +21,6 @@
# SOFTWARE. # SOFTWARE.
# #
cmake_minimum_required(VERSION 3.6.0)
set(LINK_LIBRARIES ${MK_LINK_LIBRARIES}) set(LINK_LIBRARIES ${MK_LINK_LIBRARIES})
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
@ -33,7 +31,9 @@ if(PKG_CONFIG_FOUND)
list(APPEND LINK_LIBRARIES PkgConfig::SDL2) list(APPEND LINK_LIBRARIES PkgConfig::SDL2)
message(STATUS "found library: ${SDL2_LIBRARIES}") message(STATUS "found library: ${SDL2_LIBRARIES}")
endif() endif()
else() endif()
if(NOT SDL2_FOUND)
find_package(SDL2 QUIET) find_package(SDL2 QUIET)
if(SDL2_FOUND) if(SDL2_FOUND)
include_directories(SYSTEM ${SDL2_INCLUDE_DIR}) include_directories(SYSTEM ${SDL2_INCLUDE_DIR})