CMake: Use targets for all optionally-external dependencies

This commit is contained in:
TellowKrinkle 2023-04-16 00:57:34 -05:00
parent 63090d411d
commit 5b10a80401
25 changed files with 172 additions and 133 deletions

View File

@ -6,7 +6,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUBEB DEFAULT_MSG find_package_handle_standard_args(CUBEB DEFAULT_MSG
CUBEB_INCLUDE_DIR CUBEB_LIBRARY) CUBEB_INCLUDE_DIR CUBEB_LIBRARY)
if(CUBEB_FOUND AND NOT TARGET CUBEB) if(CUBEB_FOUND AND NOT TARGET cubeb::cubeb)
add_library(cubeb::cubeb UNKNOWN IMPORTED) add_library(cubeb::cubeb UNKNOWN IMPORTED)
set_target_properties(cubeb::cubeb PROPERTIES set_target_properties(cubeb::cubeb PROPERTIES
IMPORTED_LOCATION "${CUBEB_LIBRARY}" IMPORTED_LOCATION "${CUBEB_LIBRARY}"

15
CMake/FindLZO.cmake Normal file
View File

@ -0,0 +1,15 @@
find_path(LZO_INCLUDE_DIR lzo/lzo1x.h)
find_library(LZO_LIBRARY lzo2)
mark_as_advanced(LZO_INCLUDE_DIR LZO_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZO DEFAULT_MSG
LZO_INCLUDE_DIR LZO_LIBRARY)
if(LZO_FOUND AND NOT TARGET LZO::LZO)
add_library(LZO::LZO UNKNOWN IMPORTED)
set_target_properties(LZO::LZO PROPERTIES
IMPORTED_LOCATION "${LZO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LZO_INCLUDE_DIR}"
)
endif()

View File

@ -40,4 +40,11 @@ elseif (NOT LIBUSB_FOUND)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
endif () endif ()
if(LIBUSB_FOUND AND NOT TARGET LibUSB::LibUSB)
add_library(LibUSB::LibUSB UNKNOWN IMPORTED)
set_target_properties(LibUSB::LibUSB PROPERTIES
IMPORTED_LOCATION "${LIBUSB_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}"
)
endif()

View File

@ -7,18 +7,53 @@ find_library(MBEDCRYPTO_LIBRARY mbedcrypto PATH_SUFFIXES mbedtls2)
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR}) set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY}) set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES ${MBEDTLS_INCLUDE_DIRS}) if(NOT MBEDTLS_INCLUDE_DIR STREQUAL "MBEDTLS_INCLUDE_DIR-NOTFOUND")
check_cxx_source_compiles(" if(EXISTS ${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h)
#include <mbedtls/version.h> file(STRINGS ${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h MBEDTLS_VERSION_STR REGEX "^#define[ \t]+MBEDTLS_VERSION_STRING[\t ].*")
#if MBEDTLS_VERSION_NUMBER < 0x021C0000 else()
#error \"Your mbed TLS version is too old.\" file(STRINGS ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLS_VERSION_STR REGEX "^#define[ \t]+MBEDTLS_VERSION_STRING[\t ].*")
#endif endif()
int main() {}" string(REGEX REPLACE "^#define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"([.0-9]+)\".*" "\\1" MBEDTLS_VERSION ${MBEDTLS_VERSION_STR})
MBEDTLS_VERSION_OK) endif()
unset(CMAKE_REQUIRED_INCLUDES)
include(FindPackageHandleStandardArgs) if(NOT MBEDTLS_INCLUDE_DIR STREQUAL "MBEDTLS_INCLUDE_DIR-NOTFOUND" AND MBEDTLS_VERSION VERSION_GREATER_EQUAL 3)
find_package_handle_standard_args(MBEDTLS DEFAULT_MSG # Once CMake 3.19 is required, we can enable HANDLE_VERSION_RANGE and use that
MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY MBEDTLS_VERSION_OK) if(MBEDTLS_FIND_REQUIRED)
set(type FATAL_ERROR)
else()
set(type STATUS)
endif()
if(MBEDTLS_FIND_REQUIRED OR NOT MBEDTLS_FIND_QUIETLY)
message(${type} "Could NOT find MBEDTLS: Found unsuitable version \"${MBEDTLS_VERSION}\", but a 2.x version is required (found ${MBEDTLS_INCLUDE_DIR})")
endif()
set(MBEDTLS_FOUND FALSE)
else()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MBEDTLS
REQUIRED_VARS MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY
VERSION_VAR MBEDTLS_VERSION)
endif()
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
if(MBEDTLS_FOUND)
add_library(MbedTLS::mbedcrypto UNKNOWN IMPORTED)
set_target_properties(MbedTLS::mbedcrypto PROPERTIES
IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
)
add_library(MbedTLS::mbedx509 UNKNOWN IMPORTED)
set_target_properties(MbedTLS::mbedx509 PROPERTIES
IMPORTED_LOCATION "${MBEDX509_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES MbedTLS::mbedcrypto
)
add_library(MbedTLS::mbedtls UNKNOWN IMPORTED)
set_target_properties(MbedTLS::mbedtls PROPERTIES
IMPORTED_LOCATION "${MBEDTLS_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES MbedTLS::mbedx509
)
endif()

View File

@ -5,14 +5,17 @@ find_path(MINIUPNPC_INCLUDE_DIR miniupnpc.h PATH_SUFFIXES miniupnpc)
find_library(MINIUPNPC_LIBRARY miniupnpc) find_library(MINIUPNPC_LIBRARY miniupnpc)
if(MINIUPNPC_INCLUDE_DIR) if(MINIUPNPC_INCLUDE_DIR)
file(STRINGS "${MINIUPNPC_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+") file(STRINGS "${MINIUPNPC_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_VERSION[\t ]+.*")
if(MINIUPNPC_API_VERSION_STR) if(MINIUPNPC_VERSION_STR)
string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)" "\\1" MINIUPNPC_API_VERSION ${MINIUPNPC_API_VERSION_STR}) string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_VERSION[\t ]+\"([.0-9]+)\"" "\\1" MINIUPNPC_VERSION ${MINIUPNPC_VERSION_STR})
endif() endif()
endif() endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MINIUPNPC DEFAULT_MSG MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY MINIUPNPC_API_VERSION) find_package_handle_standard_args(MINIUPNPC
REQUIRED_VARS MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY
VERSION_VAR MINIUPNPC_VERSION
)
set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY}) set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY})
set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR}) set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR})

View File

@ -206,4 +206,20 @@ endif()
# handle success # handle success
if(SFML_FOUND) if(SFML_FOUND)
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}") message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
if(NOT TARGET sfml-${FIND_SFML_COMPONENT_LOWER})
add_library(sfml-${FIND_SFML_COMPONENT_LOWER} UNKNOWN IMPORTED)
set_target_properties(sfml-${FIND_SFML_COMPONENT_LOWER} PROPERTIES
IMPORTED_LOCATION "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SFML_INCLUDE_DIR}"
)
if(NOT ${FIND_SFML_COMPONENT_LOWER} STREQUAL system)
set_target_properties(sfml-${FIND_SFML_COMPONENT_LOWER} PROPERTIES
INTERFACE_LINK_LIBRARIES sfml-system
)
endif()
endif()
endforeach()
endif() endif()

View File

@ -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) option(ENABLE_CLI_TOOL "Enable dolphin-tool, a CLI-based utility for functions such as managing disc images" ON)
endif() 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(USE_UPNP "Enables UPnP port mapping support" ON)
option(ENABLE_NOGUI "Enable NoGUI frontend" ON) option(ENABLE_NOGUI "Enable NoGUI frontend" ON)
option(ENABLE_QT "Enable Qt (Default)" ON) option(ENABLE_QT "Enable Qt (Default)" ON)
@ -645,26 +644,8 @@ if(ENABLE_SDL)
message(STATUS "Using system SDL2") message(STATUS "Using system SDL2")
else() else()
message(STATUS "Using static SDL2 from Externals") message(STATUS "Using static SDL2 from Externals")
option(SDL2_DISABLE_SDL2MAIN "" ON) add_subdirectory(Externals/SDL)
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)
endif() endif()
add_definitions(-DHAVE_SDL2=1)
endif() endif()
if(ENABLE_ANALYTICS) if(ENABLE_ANALYTICS)
@ -747,31 +728,13 @@ if(NOT pugixml_FOUND)
add_subdirectory(Externals/pugixml) add_subdirectory(Externals/pugixml)
endif() endif()
if(USE_SHARED_ENET) pkg_check_modules(ENET libenet>=1.3.8 IMPORTED_TARGET)
check_lib(ENET libenet enet enet/enet.h QUIET) if(ENET_FOUND)
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)
message(STATUS "Using shared enet") message(STATUS "Using shared enet")
dolphin_alias_library(enet::enet PkgConfig::ENET)
else() else()
check_vendoring_approved(enet) check_vendoring_approved(enet)
message(STATUS "Using static enet from Externals") message(STATUS "Using static enet from Externals")
include_directories(Externals/enet/include)
add_subdirectory(Externals/enet) add_subdirectory(Externals/enet)
endif() endif()
@ -813,37 +776,32 @@ endif()
add_subdirectory(Externals/zlib-ng) 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) if(MINIZIP_FOUND)
message(STATUS "Using shared minizip") message(STATUS "Using shared minizip")
include_directories(${MINIZIP_INCLUDE_DIRS}) dolphin_alias_library(minizip::minizip PkgConfig::MINIZIP)
else() else()
check_vendoring_approved(minizip) check_vendoring_approved(minizip)
message(STATUS "Shared minizip not found, falling back to the static library") message(STATUS "Shared minizip not found, falling back to the static library")
add_subdirectory(Externals/minizip) add_subdirectory(Externals/minizip)
include_directories(External/minizip)
endif() endif()
if(NOT APPLE) find_package(LZO)
check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET)
endif()
if(LZO_FOUND) if(LZO_FOUND)
message(STATUS "Using shared lzo") message(STATUS "Using shared lzo")
else() else()
check_vendoring_approved(lzo) check_vendoring_approved(lzo)
message(STATUS "Using static lzo from Externals") message(STATUS "Using static lzo from Externals")
add_subdirectory(Externals/LZO) add_subdirectory(Externals/LZO EXCLUDE_FROM_ALL)
set(LZO lzo2)
endif() endif()
pkg_check_modules(pc_spng IMPORTED_TARGET spng) pkg_check_modules(pc_spng IMPORTED_TARGET spng)
if (pc_spng_FOUND AND TARGET PkgConfig::pc_spng) if (pc_spng_FOUND AND TARGET PkgConfig::pc_spng)
message(STATUS "Using the system libspng") message(STATUS "Using the system libspng")
set(spng_target PkgConfig::pc_spng) dolphin_alias_library(spng::spng PkgConfig::pc_spng)
else() else()
message(STATUS "Using static libspng from Externals") message(STATUS "Using static libspng from Externals")
add_subdirectory(Externals/libspng) add_subdirectory(Externals/libspng)
set(spng_target spng)
endif() endif()
# Using static FreeSurround from Externals # Using static FreeSurround from Externals
@ -873,40 +831,28 @@ endif()
if(NOT ANDROID) if(NOT ANDROID)
add_definitions(-D__LIBUSB__) add_definitions(-D__LIBUSB__)
if(NOT APPLE) find_package(LibUSB)
find_package(LibUSB) if(LIBUSB_FOUND)
endif()
if(LIBUSB_FOUND AND NOT APPLE)
message(STATUS "Using shared LibUSB") message(STATUS "Using shared LibUSB")
include_directories(${LIBUSB_INCLUDE_DIR})
else() else()
check_vendoring_approved(libusb) check_vendoring_approved(libusb)
message(STATUS "Using static LibUSB from Externals") message(STATUS "Using static LibUSB from Externals")
add_subdirectory(Externals/libusb) add_subdirectory(Externals/libusb EXCLUDE_FROM_ALL)
set(LIBUSB_LIBRARIES usb)
endif() endif()
set(LIBUSB_FOUND true)
endif() endif()
set(SFML_REQD_VERSION 2.1) find_package(SFML 2.1 COMPONENTS network system)
if(NOT APPLE)
find_package(SFML ${SFML_REQD_VERSION} COMPONENTS network system)
endif()
if(SFML_FOUND) if(SFML_FOUND)
message(STATUS "Using shared SFML") message(STATUS "Using shared SFML")
else() else()
check_vendoring_approved(sfml) check_vendoring_approved(sfml)
message(STATUS "Using static SFML ${SFML_REQD_VERSION} from Externals") message(STATUS "Using static SFML from Externals")
add_definitions(-DSFML_STATIC)
add_subdirectory(Externals/SFML) add_subdirectory(Externals/SFML)
include_directories(BEFORE Externals/SFML/include)
endif() endif()
if(USE_UPNP) if(USE_UPNP)
if(NOT APPLE) find_package(MINIUPNPC 1.6)
find_package(MINIUPNPC) if(MINIUPNPC_FOUND)
endif()
if(MINIUPNPC_FOUND AND MINIUPNPC_API_VERSION GREATER 8)
message(STATUS "Using shared miniupnpc") message(STATUS "Using shared miniupnpc")
else() else()
check_vendoring_approved(miniupnpc) check_vendoring_approved(miniupnpc)
@ -916,30 +862,22 @@ if(USE_UPNP)
add_definitions(-DUSE_UPNP) add_definitions(-DUSE_UPNP)
endif() endif()
if(NOT APPLE) find_package(MBEDTLS 2.28)
find_package(MBEDTLS)
endif()
if(MBEDTLS_FOUND) if(MBEDTLS_FOUND)
message(STATUS "Using shared mbed TLS") message(STATUS "Using shared mbed TLS")
include_directories(${MBEDTLS_INCLUDE_DIRS})
else() else()
check_vendoring_approved(mbedtls) check_vendoring_approved(mbedtls)
message(STATUS "Using static mbed TLS from Externals") message(STATUS "Using static mbed TLS from Externals")
set(MBEDTLS_LIBRARIES mbedtls mbedcrypto mbedx509)
add_subdirectory(Externals/mbedtls/ EXCLUDE_FROM_ALL) add_subdirectory(Externals/mbedtls/ EXCLUDE_FROM_ALL)
include_directories(Externals/mbedtls/include)
endif() endif()
find_package(CURL) find_package(CURL)
if(CURL_FOUND) if(CURL_FOUND)
message(STATUS "Using shared libcurl") message(STATUS "Using shared libcurl")
include_directories(${CURL_INCLUDE_DIRS})
else() else()
check_vendoring_approved(curl) check_vendoring_approved(curl)
message(STATUS "Using static libcurl from Externals") message(STATUS "Using static libcurl from Externals")
add_subdirectory(Externals/curl) add_subdirectory(Externals/curl EXCLUDE_FROM_ALL)
set(CURL_LIBRARIES curl)
include_directories(BEFORE Externals/curl/include)
endif() endif()
if(NOT ANDROID) if(NOT ANDROID)
@ -951,7 +889,7 @@ if(TARGET Iconv::Iconv)
else() else()
check_vendoring_approved(iconv) check_vendoring_approved(iconv)
message(STATUS "Using static iconv from Externals") message(STATUS "Using static iconv from Externals")
add_subdirectory(Externals/libiconv-1.14) add_subdirectory(Externals/libiconv-1.14 EXCLUDE_FROM_ALL)
endif() endif()
if(NOT ANDROID) if(NOT ANDROID)

View File

@ -7,3 +7,4 @@ target_include_directories(lzo2
PUBLIC PUBLIC
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
add_library(LZO::LZO ALIAS lzo2)

17
Externals/SDL/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,17 @@
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(SDL)
if (TARGET SDL2)
dolphin_disable_warnings_msvc(SDL2)
endif()
if (TARGET SDL2-static)
dolphin_disable_warnings_msvc(SDL2-static)
endif()

View File

@ -1,5 +1,3 @@
include_directories(BEFORE include src)
set(SRC_NETWORK set(SRC_NETWORK
src/SFML/Network/Http.cpp src/SFML/Network/Http.cpp
src/SFML/Network/IPAddress.cpp src/SFML/Network/IPAddress.cpp
@ -23,7 +21,11 @@ set(SRC_SYSTEM
src/SFML/System/Time.cpp src/SFML/System/Time.cpp
) )
add_library(sfml-network ${SRC_NETWORK}) add_library(sfml-network STATIC ${SRC_NETWORK})
add_library(sfml-system ${SRC_SYSTEM}) add_library(sfml-system STATIC ${SRC_SYSTEM})
target_compile_definitions(sfml-system PUBLIC SFML_STATIC)
target_include_directories(sfml-system PUBLIC include PRIVATE src)
target_include_directories(sfml-network PUBLIC include PRIVATE src)
target_link_libraries(sfml-network PUBLIC sfml-system)
dolphin_disable_warnings_msvc(sfml-network) dolphin_disable_warnings_msvc(sfml-network)
dolphin_disable_warnings_msvc(sfml-system) dolphin_disable_warnings_msvc(sfml-system)

View File

@ -352,3 +352,4 @@ if(USE_AUDIOUNIT AND USE_AUDIOUNIT_RUST)
debug "${PROJECT_SOURCE_DIR}/cubeb/src/cubeb-coreaudio-rs/target/debug/libcubeb_coreaudio.a" debug "${PROJECT_SOURCE_DIR}/cubeb/src/cubeb-coreaudio-rs/target/debug/libcubeb_coreaudio.a"
optimized "${PROJECT_SOURCE_DIR}/cubeb/src/cubeb-coreaudio-rs/target/release/libcubeb_coreaudio.a") optimized "${PROJECT_SOURCE_DIR}/cubeb/src/cubeb-coreaudio-rs/target/release/libcubeb_coreaudio.a")
endif() endif()
add_library(cubeb::cubeb ALIAS cubeb)

View File

@ -4,8 +4,6 @@ else()
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
endif() endif()
include_directories(.)
file(GLOB SRCS *.c vauth/*.c vtls/*.c) file(GLOB SRCS *.c vauth/*.c vtls/*.c)
add_library( add_library(
curl curl
@ -14,5 +12,7 @@ add_library(
) )
dolphin_disable_warnings_msvc(curl) dolphin_disable_warnings_msvc(curl)
target_link_libraries(curl ${MBEDTLS_LIBRARIES} zlibstatic) target_include_directories(curl PRIVATE . INTERFACE ../include)
target_link_libraries(curl MbedTLS::mbedtls zlibstatic)
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP) target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)
add_library(CURL::libcurl ALIAS curl)

View File

@ -59,8 +59,6 @@ if(HAS_SOCKLEN_T)
add_definitions(-DHAS_SOCKLEN_T=1) add_definitions(-DHAS_SOCKLEN_T=1)
endif() endif()
include_directories(${PROJECT_SOURCE_DIR}/include)
set(INCLUDE_FILES_PREFIX include/enet) set(INCLUDE_FILES_PREFIX include/enet)
set(INCLUDE_FILES set(INCLUDE_FILES
${INCLUDE_FILES_PREFIX}/callbacks.h ${INCLUDE_FILES_PREFIX}/callbacks.h
@ -92,8 +90,10 @@ add_library(enet STATIC
${INCLUDE_FILES} ${INCLUDE_FILES}
${SOURCE_FILES} ${SOURCE_FILES}
) )
target_include_directories(enet PUBLIC include)
dolphin_disable_warnings_msvc(enet) dolphin_disable_warnings_msvc(enet)
add_library(enet::enet ALIAS enet)
if (MINGW) if (MINGW)
target_link_libraries(enet winmm ws2_32) target_link_libraries(enet winmm ws2_32)

View File

@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 3.0)
project(spng C) project(spng C)
add_library(spng STATIC ${CMAKE_CURRENT_LIST_DIR}/libspng/spng/spng.c) add_library(spng STATIC libspng/spng/spng.c)
target_compile_definitions(spng PUBLIC SPNG_STATIC) target_compile_definitions(spng PUBLIC SPNG_STATIC)
target_link_libraries(spng PUBLIC ZLIB::ZLIB) target_link_libraries(spng PUBLIC ZLIB::ZLIB)
target_include_directories(spng PUBLIC ${CMAKE_CURRENT_LIST_DIR}/libspng/spng/) target_include_directories(spng PUBLIC libspng/spng)
dolphin_disable_warnings_msvc(spng) dolphin_disable_warnings_msvc(spng)
add_library(spng::spng ALIAS spng)

View File

@ -125,3 +125,4 @@ check_include_files(sys/timerfd.h HAVE_TIMERFD)
check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(unistd.h HAVE_UNISTD_H)
configure_file(config.h.in config.h) configure_file(config.h.in config.h)
add_library(LibUSB::LibUSB ALIAS usb)

View File

@ -222,6 +222,7 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
endif(USE_SHARED_MBEDTLS_LIBRARY) endif(USE_SHARED_MBEDTLS_LIBRARY)
foreach(target IN LISTS target_libraries) foreach(target IN LISTS target_libraries)
add_library(MbedTLS::${target} ALIAS ${target}) # add_subdirectory support
# Include public header files from /include and other directories # Include public header files from /include and other directories
# declared by /3rdparty/**/CMakeLists.txt. Include private header files # declared by /3rdparty/**/CMakeLists.txt. Include private header files
# from /library and others declared by /3rdparty/**/CMakeLists.txt. # from /library and others declared by /3rdparty/**/CMakeLists.txt.

View File

@ -67,4 +67,4 @@ endif()
target_link_libraries(minizip PUBLIC ZLIB::ZLIB) target_link_libraries(minizip PUBLIC ZLIB::ZLIB)
add_library(minizip-ng ALIAS minizip) add_library(minizip::minizip ALIAS minizip)

View File

@ -83,7 +83,7 @@ PUBLIC
common common
PRIVATE PRIVATE
cubeb cubeb::cubeb
SoundTouch SoundTouch
FreeSurround) FreeSurround)

View File

@ -144,16 +144,17 @@ endif()
target_link_libraries(common target_link_libraries(common
PUBLIC PUBLIC
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
enet enet::enet
fmt::fmt fmt::fmt
${MBEDTLS_LIBRARIES} MbedTLS::mbedtls
minizip-ng minizip::minizip
sfml-network
PRIVATE PRIVATE
${CURL_LIBRARIES} CURL::libcurl
FatFs FatFs
Iconv::Iconv Iconv::Iconv
${spng_target} spng::spng
${VTUNE_LIBRARIES} ${VTUNE_LIBRARIES}
) )

View File

@ -603,24 +603,23 @@ target_link_libraries(core
PUBLIC PUBLIC
audiocommon audiocommon
common common
cubeb
discio discio
enet enet::enet
expr expr
inputcommon inputcommon
${MBEDTLS_LIBRARIES} MbedTLS::mbedtls
pugixml pugixml
RangeSet::RangeSet RangeSet::RangeSet
sfml-network sfml-network
sfml-system
videonull videonull
videoogl videoogl
videosoftware videosoftware
PRIVATE PRIVATE
cubeb::cubeb
FatFs FatFs
fmt::fmt fmt::fmt
${LZO} LZO::LZO
ZLIB::ZLIB ZLIB::ZLIB
) )
@ -644,9 +643,8 @@ elseif (ANDROID)
) )
endif() endif()
if(LIBUSB_FOUND) if(TARGET LibUSB::LibUSB)
# Using shared LibUSB target_link_libraries(core PUBLIC LibUSB::LibUSB)
target_link_libraries(core PUBLIC ${LIBUSB_LIBRARIES})
target_sources(core PRIVATE target_sources(core PRIVATE
IOS/USB/LibusbDevice.cpp IOS/USB/LibusbDevice.cpp
IOS/USB/LibusbDevice.h IOS/USB/LibusbDevice.h

View File

@ -75,7 +75,7 @@ PUBLIC
PRIVATE PRIVATE
fmt::fmt fmt::fmt
minizip-ng minizip::minizip
pugixml pugixml
ZLIB::ZLIB ZLIB::ZLIB
) )

View File

@ -81,7 +81,8 @@ PUBLIC
PRIVATE PRIVATE
fmt::fmt fmt::fmt
${spng_target} sfml-network
spng::spng
) )
if(WIN32) if(WIN32)
@ -146,7 +147,7 @@ elseif(ANDROID)
endif() endif()
if(NOT ANDROID) if(NOT ANDROID)
target_link_libraries(inputcommon PUBLIC ${LIBUSB_LIBRARIES}) target_link_libraries(inputcommon PUBLIC LibUSB::LibUSB)
endif() endif()
if(LIBEVDEV_FOUND AND LIBUDEV_FOUND) if(LIBEVDEV_FOUND AND LIBUDEV_FOUND)
@ -174,12 +175,13 @@ if(UNIX)
) )
endif() endif()
if(SDL2_FOUND) if(ENABLE_SDL)
target_sources(inputcommon PRIVATE target_sources(inputcommon PRIVATE
ControllerInterface/SDL/SDL.cpp ControllerInterface/SDL/SDL.cpp
ControllerInterface/SDL/SDL.h ControllerInterface/SDL/SDL.h
) )
target_link_libraries(inputcommon PRIVATE SDL2::SDL2) target_link_libraries(inputcommon PRIVATE SDL2::SDL2)
target_compile_definitions(inputcommon PUBLIC HAVE_SDL2=1)
endif() endif()
if(MSVC) if(MSVC)

View File

@ -29,7 +29,7 @@ target_link_libraries(uicommon
PUBLIC PUBLIC
common common
cpp-optparse cpp-optparse
minizip-ng minizip::minizip
pugixml pugixml
PRIVATE PRIVATE
@ -48,8 +48,8 @@ if(ENABLE_X11 AND X11_FOUND)
target_link_libraries(uicommon PUBLIC ${XRANDR_LIBRARIES}) target_link_libraries(uicommon PUBLIC ${XRANDR_LIBRARIES})
endif() endif()
if(LIBUSB_FOUND) if(TARGET LibUSB::LibUSB)
target_link_libraries(uicommon PRIVATE ${LIBUSB_LIBRARIES}) target_link_libraries(uicommon PRIVATE LibUSB::LibUSB)
endif() endif()
if(ENABLE_LLVM) if(ENABLE_LLVM)

View File

@ -6,7 +6,7 @@ add_library(updatercommon
target_link_libraries(updatercommon PRIVATE target_link_libraries(updatercommon PRIVATE
uicommon uicommon
mbedtls MbedTLS::mbedtls
ZLIB::ZLIB ZLIB::ZLIB
ed25519 ed25519
cpp-optparse cpp-optparse

View File

@ -195,7 +195,7 @@ PUBLIC
core core
PRIVATE PRIVATE
fmt::fmt fmt::fmt
${spng_target} spng::spng
xxhash xxhash
imgui imgui
implot implot