all repos — mgba @ 346f5dc0b53afa8ea1e11d8c94a0090b5d49abc9

mGBA Game Boy Advance Emulator

src/platform/cmake/FindFeature.cmake (view raw)

 1include(FindPkgConfig)
 2function(find_feature FEATURE_NAME FEATURE_REQUIRES)
 3	if (NOT ${FEATURE_NAME})
 4		return()
 5	endif()
 6	if (DISABLE_DEPS)
 7		set(${FEATURE_NAME} OFF PARENT_SCOPE)
 8		return()
 9	endif()
10	foreach(REQUIRE ${FEATURE_REQUIRES})
11		if(NOT ${REQUIRE}_FOUND)
12			find_package(${REQUIRE} QUIET)
13			if(NOT ${REQUIRE}_FOUND)
14				pkg_search_module(${REQUIRE} ${REQUIRE})
15				if (NOT ${REQUIRE}_FOUND)
16					message(WARNING "Requested module ${REQUIRE} missing for feature ${FEATURE_NAME}. Feature disabled.")
17					set(${FEATURE_NAME} OFF PARENT_SCOPE)
18					return()
19				endif()
20			endif()
21		endif()
22		string(TOUPPER ${REQUIRE} UREQUIRE)
23		set(${UREQUIRE}_CFLAGS_OTHER ${${REQUIRE}_CFLAGS_OTHER} PARENT_SCOPE)
24		set(${UREQUIRE}_FOUND ${${REQUIRE}_FOUND} PARENT_SCOPE)
25		set(${UREQUIRE}_INCLUDE_DIRS ${${REQUIRE}_INCLUDE_DIRS} PARENT_SCOPE)
26		set(${UREQUIRE}_VERSION_STRING ${${REQUIRE}_VERSION_STRING} PARENT_SCOPE)
27		if (APPLE)
28			set(IS_FRAMEWORK OFF)
29			set(LIBS)
30			foreach(LIB IN LISTS ${REQUIRE}_LIBRARIES)
31				if(LIB STREQUAL "-framework")
32					set(IS_FRAMEWORK ON)
33				elseif(IS_FRAMEWORK)
34					list(APPEND LIBS "-framework ${LIB}")
35					set(IS_FRAMEWORK OFF)
36				else()
37					list(APPEND LIBS ${LIB})
38				endif()
39			endforeach()
40			set(${UREQUIRE}_LIBRARIES ${LIBS} PARENT_SCOPE)
41		else()
42			set(${UREQUIRE}_LIBRARIES ${${REQUIRE}_LIBRARIES} PARENT_SCOPE)
43		endif()
44		set(${UREQUIRE}_LIBRARY_DIRS ${${REQUIRE}_LIBRARY_DIRS} PARENT_SCOPE)
45		set(${UREQUIRE}_LDFLAGS_OTHER ${${REQUIRE}_LDFLAGS_OTHER} PARENT_SCOPE)
46	endforeach()
47endfunction()