mirror of https://github.com/mgba-emu/mgba.git
CMake: Cleanup and enhance FindFeature, fix static libedit
This commit is contained in:
parent
ddccbee47b
commit
a60bc18ad0
|
@ -501,7 +501,11 @@ if(USE_EDITLINE)
|
|||
list(APPEND FEATURES EDITLINE)
|
||||
include_directories(AFTER ${LIBEDIT_INCLUDE_DIRS})
|
||||
link_directories(${LIBEDIT_LIBRARY_DIRS})
|
||||
set(DEBUGGER_LIB ${LIBEDIT_LIBRARIES})
|
||||
if(BUILD_STATIC)
|
||||
set(DEBUGGER_LIB ${LIBEDIT_STATIC_LIBRARIES})
|
||||
else()
|
||||
set(DEBUGGER_LIB ${LIBEDIT_LIBRARIES})
|
||||
endif()
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libedit2")
|
||||
list(APPEND FEATURE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/feature/editline/cli-el-backend.c")
|
||||
else()
|
||||
|
|
|
@ -1,4 +1,34 @@
|
|||
include(FindPkgConfig)
|
||||
macro(_export SUFFIX)
|
||||
if(DEFINED ${REQUIRE}_${SUFFIX})
|
||||
set(${UREQUIRE}_${SUFFIX} ${${REQUIRE}_${SUFFIX}} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_${SUFFIX})
|
||||
set(${UREQUIRE}_${SUFFIX} ${${UREQUIRE}_${SUFFIX}} PARENT_SCOPE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(_exportLibraries SUFFIX)
|
||||
set(IS_FRAMEWORK OFF)
|
||||
set(LIBS)
|
||||
if(DEFINED ${REQUIRE}_${SUFFIX})
|
||||
set(PREFIX ${REQUIRE})
|
||||
elseif(DEFINED ${UREQUIRE}_${SUFFIX})
|
||||
set(PREFIX ${UREQUIRE})
|
||||
endif()
|
||||
foreach(LIB IN LISTS ${PREFIX}_${SUFFIX})
|
||||
if(LIB STREQUAL "-framework")
|
||||
set(IS_FRAMEWORK ON)
|
||||
elseif(IS_FRAMEWORK)
|
||||
list(APPEND LIBS "-framework ${LIB}")
|
||||
set(IS_FRAMEWORK OFF)
|
||||
else()
|
||||
list(APPEND LIBS ${LIB})
|
||||
endif()
|
||||
endforeach()
|
||||
unset(PREFIX)
|
||||
set(${UREQUIRE}_${SUFFIX} ${LIBS} PARENT_SCOPE)
|
||||
endmacro()
|
||||
|
||||
function(find_feature FEATURE_NAME FEATURE_REQUIRES)
|
||||
if (NOT ${FEATURE_NAME})
|
||||
return()
|
||||
|
@ -28,60 +58,22 @@ function(find_feature FEATURE_NAME FEATURE_REQUIRES)
|
|||
endif()
|
||||
if(${REQUIRE}_FOUND)
|
||||
string(TOUPPER ${REQUIRE} UREQUIRE)
|
||||
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}_INCLUDE_DIR)
|
||||
set(${UREQUIRE}_INCLUDE_DIR ${${REQUIRE}_INCLUDE_DIR} PARENT_SCOPE)
|
||||
elseif(DEFINED ${UREQUIRE}_INCLUDE_DIR)
|
||||
set(${UREQUIRE}_INCLUDE_DIR ${${UREQUIRE}_INCLUDE_DIR} 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()
|
||||
_export(CFLAGS_OTHER)
|
||||
_export(FOUND)
|
||||
_export(INCLUDE_DIRS)
|
||||
_export(INCLUDE_DIR)
|
||||
_export(VERSION_STRING)
|
||||
_export(VERSION_MAJOR)
|
||||
_export(VERSION_MINOR)
|
||||
if (APPLE)
|
||||
set(IS_FRAMEWORK OFF)
|
||||
set(LIBS)
|
||||
foreach(LIB IN LISTS ${REQUIRE}_LIBRARIES)
|
||||
if(LIB STREQUAL "-framework")
|
||||
set(IS_FRAMEWORK ON)
|
||||
elseif(IS_FRAMEWORK)
|
||||
list(APPEND LIBS "-framework ${LIB}")
|
||||
set(IS_FRAMEWORK OFF)
|
||||
else()
|
||||
list(APPEND LIBS ${LIB})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${UREQUIRE}_LIBRARIES ${LIBS} PARENT_SCOPE)
|
||||
_exportLibraries(LIBRARIES)
|
||||
_exportLibraries(STATIC_LIBRARIES)
|
||||
else()
|
||||
set(${UREQUIRE}_LIBRARIES ${${REQUIRE}_LIBRARIES} PARENT_SCOPE)
|
||||
_export(LIBRARIES)
|
||||
_export(STATIC_LIBRARIES)
|
||||
endif()
|
||||
set(${UREQUIRE}_LIBRARY_DIRS ${${REQUIRE}_LIBRARY_DIRS} PARENT_SCOPE)
|
||||
set(${UREQUIRE}_LDFLAGS_OTHER ${${REQUIRE}_LDFLAGS_OTHER} PARENT_SCOPE)
|
||||
_export(LIBRARY_DIRS)
|
||||
_export(LDFLAGS_OTHER)
|
||||
set(FOUND ON)
|
||||
break()
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue