mirror of https://github.com/mgba-emu/mgba.git
CMake: Add version checking in find_feature
This commit is contained in:
parent
0035b5a22b
commit
86f7acbbb9
|
@ -7,22 +7,57 @@ function(find_feature FEATURE_NAME FEATURE_REQUIRES)
|
|||
set(${FEATURE_NAME} OFF PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(ARGV2)
|
||||
set(VERSION "${ARGV2}")
|
||||
set(FIND_VERSION "${VERSION}" EXACT)
|
||||
set(PKG_CONFIG_VERSION_CHECK " >=${VERSION}")
|
||||
else()
|
||||
set(VERSION)
|
||||
set(FIND_VERSION)
|
||||
set(PKG_CONFIG_VERSION_CHECK)
|
||||
endif()
|
||||
foreach(NAMES ${FEATURE_REQUIRES})
|
||||
string(REPLACE "|" ";" NAMELIST "${NAMES}")
|
||||
set(FOUND OFF)
|
||||
foreach(REQUIRE ${NAMELIST})
|
||||
if(NOT ${REQUIRE}_FOUND)
|
||||
find_package(${REQUIRE} QUIET)
|
||||
find_package(${REQUIRE} ${FIND_VERSION} QUIET)
|
||||
if(NOT ${REQUIRE}_FOUND)
|
||||
pkg_search_module(${REQUIRE} ${REQUIRE})
|
||||
pkg_search_module(${REQUIRE} "${REQUIRE}${PKG_CONFIG_VERSION_CHECK}")
|
||||
endif()
|
||||
endif()
|
||||
if(${REQUIRE}_FOUND)
|
||||
string(TOUPPER ${REQUIRE} UREQUIRE)
|
||||
set(${UREQUIRE}_CFLAGS_OTHER ${${REQUIRE}_CFLAGS_OTHER} PARENT_SCOPE)
|
||||
set(${UREQUIRE}_FOUND ${${REQUIRE}_FOUND} PARENT_SCOPE)
|
||||
set(${UREQUIRE}_INCLUDE_DIRS ${${REQUIRE}_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
set(${UREQUIRE}_VERSION_STRING ${${REQUIRE}_VERSION_STRING} PARENT_SCOPE)
|
||||
if(DEFINED ${REQUIRE}_CFLAGS_OTHER)
|
||||
set(${UREQUIRE}_CFLAGS_OTHER ${${REQUIRE}_CFLAGS_OTHER} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_CFLAGS_OTHER)
|
||||
set(${UREQUIRE}_CFLAGS_OTHER ${${UREQUIRE}_CFLAGS_OTHER} PARENT_SCOPE)
|
||||
endif()
|
||||
if(DEFINED ${REQUIRE}_FOUND)
|
||||
set(${UREQUIRE}_FOUND ${${REQUIRE}_FOUND} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_FOUND)
|
||||
set(${UREQUIRE}_FOUND ${${UREQUIRE}_FOUND} PARENT_SCOPE)
|
||||
endif()
|
||||
if(DEFINED ${REQUIRE}_INCLUDE_DIRS)
|
||||
set(${UREQUIRE}_INCLUDE_DIRS ${${REQUIRE}_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_INCLUDE_DIRS)
|
||||
set(${UREQUIRE}_INCLUDE_DIRS ${${UREQUIRE}_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
endif()
|
||||
if(DEFINED ${REQUIRE}_VERSION_STRING)
|
||||
set(${UREQUIRE}_VERSION_STRING ${${REQUIRE}_VERSION_STRING} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_VERSION_STRING)
|
||||
set(${UREQUIRE}_VERSION_STRING ${${UREQUIRE}_VERSION_STRING} PARENT_SCOPE)
|
||||
endif()
|
||||
if(DEFINED ${REQUIRE}_VERSION_MAJOR)
|
||||
set(${UREQUIRE}_VERSION_MAJOR ${${REQUIRE}_VERSION_MAJOR} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_VERSION_MAJOR)
|
||||
set(${UREQUIRE}_VERSION_MAJOR ${${UREQUIRE}_VERSION_MAJOR} PARENT_SCOPE)
|
||||
endif()
|
||||
if(DEFINED ${REQUIRE}_VERSION_MINOR)
|
||||
set(${UREQUIRE}_VERSION_MINOR ${${REQUIRE}_VERSION_MINOR} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_VERSION_MINOR)
|
||||
set(${UREQUIRE}_VERSION_MINOR ${${UREQUIRE}_VERSION_MINOR} PARENT_SCOPE)
|
||||
endif()
|
||||
if (APPLE)
|
||||
set(IS_FRAMEWORK OFF)
|
||||
set(LIBS)
|
||||
|
|
Loading…
Reference in New Issue