mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
CMake: Use targets for all optionally-external dependencies
This commit is contained in:
100
CMakeLists.txt
100
CMakeLists.txt
@ -85,7 +85,6 @@ if(NOT ANDROID)
|
||||
option(ENABLE_CLI_TOOL "Enable dolphin-tool, a CLI-based utility for functions such as managing disc images" ON)
|
||||
endif()
|
||||
|
||||
option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF)
|
||||
option(USE_UPNP "Enables UPnP port mapping support" ON)
|
||||
option(ENABLE_NOGUI "Enable NoGUI frontend" ON)
|
||||
option(ENABLE_QT "Enable Qt (Default)" ON)
|
||||
@ -645,26 +644,8 @@ if(ENABLE_SDL)
|
||||
message(STATUS "Using system SDL2")
|
||||
else()
|
||||
message(STATUS "Using static SDL2 from Externals")
|
||||
option(SDL2_DISABLE_SDL2MAIN "" ON)
|
||||
option(SDL2_DISABLE_INSTALL "" ON)
|
||||
option(SDL2_DISABLE_UNINSTALL "" ON)
|
||||
set(SDL_SHARED OFF)
|
||||
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
|
||||
set(SDL_STATIC ON)
|
||||
set(SDL_STATIC_ENABLED_BY_DEFAULT ON)
|
||||
set(SDL_TEST OFF)
|
||||
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
|
||||
set(OPT_DEF_LIBC ON)
|
||||
add_subdirectory(Externals/SDL/SDL)
|
||||
if (TARGET SDL2)
|
||||
dolphin_disable_warnings_msvc(SDL2)
|
||||
endif()
|
||||
if (TARGET SDL2-static)
|
||||
dolphin_disable_warnings_msvc(SDL2-static)
|
||||
endif()
|
||||
set(SDL2_FOUND TRUE)
|
||||
add_subdirectory(Externals/SDL)
|
||||
endif()
|
||||
add_definitions(-DHAVE_SDL2=1)
|
||||
endif()
|
||||
|
||||
if(ENABLE_ANALYTICS)
|
||||
@ -747,31 +728,13 @@ if(NOT pugixml_FOUND)
|
||||
add_subdirectory(Externals/pugixml)
|
||||
endif()
|
||||
|
||||
if(USE_SHARED_ENET)
|
||||
check_lib(ENET libenet enet enet/enet.h QUIET)
|
||||
include(CheckSymbolExists)
|
||||
if (ENET_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ENET_INCLUDE_DIRS})
|
||||
# hack: LDFLAGS already contains -lenet but all flags but the first are
|
||||
# dropped; ugh, cmake
|
||||
set(CMAKE_REQUIRED_FLAGS ${ENET_LDFLAGS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ENET_LIBRARIES})
|
||||
check_symbol_exists(enet_socket_get_address enet/enet.h ENET_HAVE_SGA)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
if (NOT ENET_HAVE_SGA)
|
||||
# enet is too old
|
||||
set(ENET_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (ENET_FOUND)
|
||||
pkg_check_modules(ENET libenet>=1.3.8 IMPORTED_TARGET)
|
||||
if(ENET_FOUND)
|
||||
message(STATUS "Using shared enet")
|
||||
dolphin_alias_library(enet::enet PkgConfig::ENET)
|
||||
else()
|
||||
check_vendoring_approved(enet)
|
||||
message(STATUS "Using static enet from Externals")
|
||||
include_directories(Externals/enet/include)
|
||||
add_subdirectory(Externals/enet)
|
||||
endif()
|
||||
|
||||
@ -813,37 +776,32 @@ endif()
|
||||
|
||||
add_subdirectory(Externals/zlib-ng)
|
||||
|
||||
pkg_check_modules(MINIZIP minizip>=3.0.0)
|
||||
pkg_check_modules(MINIZIP minizip>=3.0.0 IMPORTED_TARGET)
|
||||
if(MINIZIP_FOUND)
|
||||
message(STATUS "Using shared minizip")
|
||||
include_directories(${MINIZIP_INCLUDE_DIRS})
|
||||
dolphin_alias_library(minizip::minizip PkgConfig::MINIZIP)
|
||||
else()
|
||||
check_vendoring_approved(minizip)
|
||||
message(STATUS "Shared minizip not found, falling back to the static library")
|
||||
add_subdirectory(Externals/minizip)
|
||||
include_directories(External/minizip)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET)
|
||||
endif()
|
||||
find_package(LZO)
|
||||
if(LZO_FOUND)
|
||||
message(STATUS "Using shared lzo")
|
||||
else()
|
||||
check_vendoring_approved(lzo)
|
||||
message(STATUS "Using static lzo from Externals")
|
||||
add_subdirectory(Externals/LZO)
|
||||
set(LZO lzo2)
|
||||
add_subdirectory(Externals/LZO EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
pkg_check_modules(pc_spng IMPORTED_TARGET spng)
|
||||
if (pc_spng_FOUND AND TARGET PkgConfig::pc_spng)
|
||||
message(STATUS "Using the system libspng")
|
||||
set(spng_target PkgConfig::pc_spng)
|
||||
dolphin_alias_library(spng::spng PkgConfig::pc_spng)
|
||||
else()
|
||||
message(STATUS "Using static libspng from Externals")
|
||||
add_subdirectory(Externals/libspng)
|
||||
set(spng_target spng)
|
||||
endif()
|
||||
|
||||
# Using static FreeSurround from Externals
|
||||
@ -873,40 +831,28 @@ endif()
|
||||
|
||||
if(NOT ANDROID)
|
||||
add_definitions(-D__LIBUSB__)
|
||||
if(NOT APPLE)
|
||||
find_package(LibUSB)
|
||||
endif()
|
||||
if(LIBUSB_FOUND AND NOT APPLE)
|
||||
find_package(LibUSB)
|
||||
if(LIBUSB_FOUND)
|
||||
message(STATUS "Using shared LibUSB")
|
||||
include_directories(${LIBUSB_INCLUDE_DIR})
|
||||
else()
|
||||
check_vendoring_approved(libusb)
|
||||
message(STATUS "Using static LibUSB from Externals")
|
||||
add_subdirectory(Externals/libusb)
|
||||
set(LIBUSB_LIBRARIES usb)
|
||||
add_subdirectory(Externals/libusb EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
set(LIBUSB_FOUND true)
|
||||
endif()
|
||||
|
||||
set(SFML_REQD_VERSION 2.1)
|
||||
if(NOT APPLE)
|
||||
find_package(SFML ${SFML_REQD_VERSION} COMPONENTS network system)
|
||||
endif()
|
||||
find_package(SFML 2.1 COMPONENTS network system)
|
||||
if(SFML_FOUND)
|
||||
message(STATUS "Using shared SFML")
|
||||
else()
|
||||
check_vendoring_approved(sfml)
|
||||
message(STATUS "Using static SFML ${SFML_REQD_VERSION} from Externals")
|
||||
add_definitions(-DSFML_STATIC)
|
||||
message(STATUS "Using static SFML from Externals")
|
||||
add_subdirectory(Externals/SFML)
|
||||
include_directories(BEFORE Externals/SFML/include)
|
||||
endif()
|
||||
|
||||
if(USE_UPNP)
|
||||
if(NOT APPLE)
|
||||
find_package(MINIUPNPC)
|
||||
endif()
|
||||
if(MINIUPNPC_FOUND AND MINIUPNPC_API_VERSION GREATER 8)
|
||||
find_package(MINIUPNPC 1.6)
|
||||
if(MINIUPNPC_FOUND)
|
||||
message(STATUS "Using shared miniupnpc")
|
||||
else()
|
||||
check_vendoring_approved(miniupnpc)
|
||||
@ -916,30 +862,22 @@ if(USE_UPNP)
|
||||
add_definitions(-DUSE_UPNP)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
find_package(MBEDTLS)
|
||||
endif()
|
||||
find_package(MBEDTLS 2.28)
|
||||
if(MBEDTLS_FOUND)
|
||||
message(STATUS "Using shared mbed TLS")
|
||||
include_directories(${MBEDTLS_INCLUDE_DIRS})
|
||||
else()
|
||||
check_vendoring_approved(mbedtls)
|
||||
message(STATUS "Using static mbed TLS from Externals")
|
||||
set(MBEDTLS_LIBRARIES mbedtls mbedcrypto mbedx509)
|
||||
add_subdirectory(Externals/mbedtls/ EXCLUDE_FROM_ALL)
|
||||
include_directories(Externals/mbedtls/include)
|
||||
endif()
|
||||
|
||||
find_package(CURL)
|
||||
if(CURL_FOUND)
|
||||
message(STATUS "Using shared libcurl")
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
else()
|
||||
check_vendoring_approved(curl)
|
||||
message(STATUS "Using static libcurl from Externals")
|
||||
add_subdirectory(Externals/curl)
|
||||
set(CURL_LIBRARIES curl)
|
||||
include_directories(BEFORE Externals/curl/include)
|
||||
add_subdirectory(Externals/curl EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID)
|
||||
@ -951,7 +889,7 @@ if(TARGET Iconv::Iconv)
|
||||
else()
|
||||
check_vendoring_approved(iconv)
|
||||
message(STATUS "Using static iconv from Externals")
|
||||
add_subdirectory(Externals/libiconv-1.14)
|
||||
add_subdirectory(Externals/libiconv-1.14 EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID)
|
||||
|
Reference in New Issue
Block a user