citra-emu
/
citra
Archived
1
0
Fork 0

externals: allow users to use system libenet (#7100)

This commit is contained in:
Castor215 2023-10-31 21:01:50 +00:00 committed by GitHub
parent 597a2e8ead
commit d3ce43782d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 2 deletions

View File

@ -228,8 +228,14 @@ else()
endif() endif()
# ENet # ENet
add_subdirectory(enet) if(USE_SYSTEM_ENET)
target_include_directories(enet INTERFACE ./enet/include) find_package(libenet REQUIRED)
add_library(enet INTERFACE)
target_link_libraries(enet INTERFACE libenet::libenet)
else()
add_subdirectory(enet)
target_include_directories(enet INTERFACE ./enet/include)
endif()
# Cubeb # Cubeb
if (ENABLE_CUBEB) if (ENABLE_CUBEB)

View File

@ -19,6 +19,7 @@ option(USE_SYSTEM_FDK_AAC_HEADERS "Use the system fdk-aac headers (instead of th
option(USE_SYSTEM_FFMPEG_HEADERS "Use the system FFmpeg headers (instead of the bundled one)" OFF) option(USE_SYSTEM_FFMPEG_HEADERS "Use the system FFmpeg headers (instead of the bundled one)" OFF)
option(USE_SYSTEM_GLSLANG "Use the system glslang and SPIR-V libraries (instead of the bundled ones)" OFF) option(USE_SYSTEM_GLSLANG "Use the system glslang and SPIR-V libraries (instead of the bundled ones)" OFF)
option(USE_SYSTEM_ZSTD "Use the system Zstandard library (instead of the bundled one)" OFF) option(USE_SYSTEM_ZSTD "Use the system Zstandard library (instead of the bundled one)" OFF)
option(USE_SYSTEM_ENET "Use the system libenet (instead of the bundled one)" OFF)
# Qt and MoltenVK are handled separately # Qt and MoltenVK are handled separately
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_SDL2 "Disable system SDL2" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_SDL2 "Disable system SDL2" OFF "USE_SYSTEM_LIBS" OFF)
@ -37,6 +38,7 @@ CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_FDK_AAC_HEADERS "Disable system fdk_aac" O
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_FFMPEG_HEADERS "Disable system ffmpeg" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_FFMPEG_HEADERS "Disable system ffmpeg" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_GLSLANG "Disable system glslang" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_GLSLANG "Disable system glslang" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ZSTD "Disable system Zstandard" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ZSTD "Disable system Zstandard" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ENET "Disable system libenet" OFF "USE_SYSTEM_LIBS" OFF)
set(LIB_VAR_LIST set(LIB_VAR_LIST
SDL2 SDL2
@ -55,6 +57,7 @@ set(LIB_VAR_LIST
FFMPEG_HEADERS FFMPEG_HEADERS
GLSLANG GLSLANG
ZSTD ZSTD
ENET
) )
# First, check that USE_SYSTEM_XXX is not used with USE_SYSTEM_LIBS # First, check that USE_SYSTEM_XXX is not used with USE_SYSTEM_LIBS

View File

@ -0,0 +1,34 @@
if(NOT libenet_FOUND)
pkg_check_modules(ENET_TMP libenet)
find_path(libenet_INCLUDE_DIRS NAMES enet.h PATH_SUFFIXES enet
PATHS
${ENET_TMP_INCLUDE_DIRS}
/usr/include
/usr/local/include
)
find_library(libenet_LIBRARY_DIRS NAMES enet
PATHS
${ENET_TMP_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
if(libenet_INCLUDE_DIRS AND libenet_LIBRARY_DIRS)
set(libenet_FOUND TRUE CACHE INTERNAL "Found libenet")
message(STATUS "Found libenet ${libenet_LIBRARY_DIRS}, ${libenet_INCLUDE_DIRS}")
else()
set(libenet_FOUND FALSE CACHE INTERNAL "Found libenet")
message(STATUS "Libenet not found.")
endif()
endif()
if(libenet_FOUND AND NOT TARGET libenet::libenet)
add_library(libenet::libenet UNKNOWN IMPORTED)
set_target_properties(libenet::libenet PROPERTIES
INCLUDE_DIRECTORIES ${libenet_INCLUDE_DIRS}
INTERFACE_LINK_LIBRARIES ${libenet_LIBRARY_DIRS}
IMPORTED_LOCATION ${libenet_LIBRARY_DIRS}
)
endif()