Compare commits

...

3 Commits

Author SHA1 Message Date
Andrea Pappacoda
4629edca38 Merge 70f7ff3db5 into a78a475815 2023-02-28 06:21:42 +00:00
Andrea Pappacoda
70f7ff3db5 build(externals): move to MbedTLS upstream 2.28.1
The latest LTS release now includes the changes of the yuzu-emu fork,
so we can now directly use the upstream version instead.
2023-01-07 18:07:56 +01:00
Andrea Pappacoda
caa25146f2 build: use system MbedTLS when available
Since MbedTLS pre-3.0.0 doesn't ship neither a pkg-config file nor a
CMake package config file it is required to use a custom
FindMbedTLS.cmake file.

Since yuzu requires CMAC support it is also needed to check for the
`mbedtls_cipher_cmac` symbol.

I also changed src/core/CMakeLists.txt to only link against mbedcrypto,
as yuzu doesn't use the full MbedTLS library
2023-01-07 18:07:42 +01:00
6 changed files with 64 additions and 7 deletions

2
.gitmodules vendored
View File

@@ -30,7 +30,7 @@
url = https://github.com/yuzu-emu/sirit
[submodule "mbedtls"]
path = externals/mbedtls
url = https://github.com/yuzu-emu/mbedtls
url = https://github.com/Mbed-TLS/mbedtls
[submodule "xbyak"]
path = externals/xbyak
url = https://github.com/herumi/xbyak.git

View File

@@ -0,0 +1,43 @@
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda <andrea@pappacoda.it>
# SPDX-License-Identifier: GPL-2.0-or-later
# MbedTLS 3.0.0 will ship with a CMake package config file,
# see ARMmbed/mbedtls@d259e347e6e3a630acfc1a811709ca05e5d3b92e,
# so when yuzu will switch to that version this won't be required anymore.
#
# yuzu only uses mbedcrypto, searching for mbedtls and mbedx509 is not
# needed.
find_path(MbedTLS_INCLUDE_DIR mbedtls/cipher.h)
find_library(MbedTLS_LIBRARY mbedcrypto)
if (MbedTLS_INCLUDE_DIR AND MbedTLS_LIBRARY)
# Check for CMAC support
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES ${MbedTLS_LIBRARY})
check_symbol_exists(mbedtls_cipher_cmac ${MbedTLS_INCLUDE_DIR}/mbedtls/cmac.h mbedcrypto_HAS_CMAC)
unset(CMAKE_REQUIRED_LIBRARIES)
# Check if version 2.x is available
file(READ "${MbedTLS_INCLUDE_DIR}/mbedtls/version.h" MbedTLS_VERSION_FILE)
string(REGEX MATCH "#define[ ]+MBEDTLS_VERSION_STRING[ ]+\"([0-9.]+)\"" _ ${MbedTLS_VERSION_FILE})
set(MbedTLS_VERSION "${CMAKE_MATCH_1}")
if (NOT TARGET MbedTLS::mbedcrypto)
add_library(MbedTLS::mbedcrypto UNKNOWN IMPORTED GLOBAL)
set_target_properties(MbedTLS::mbedcrypto PROPERTIES
IMPORTED_LOCATION "${MbedTLS_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MbedTLS_INCLUDE_DIR}"
)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MbedTLS
REQUIRED_VARS
MbedTLS_LIBRARY
MbedTLS_INCLUDE_DIR
mbedcrypto_HAS_CMAC
VERSION_VAR MbedTLS_VERSION
)

View File

@@ -33,9 +33,23 @@ if (NOT TARGET inih::INIReader)
add_subdirectory(inih)
endif()
# mbedtls
add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
target_include_directories(mbedtls PUBLIC ./mbedtls/include)
# MbedTLS
find_package(MbedTLS 2.16)
if(NOT MbedTLS_FOUND)
message(STATUS "MbedTLS not found, falling back to externals")
set(ENABLE_PROGRAMS OFF CACHE BOOL "")
set(ENABLE_TESTING OFF CACHE BOOL "")
# Edit MbedTLS config header to enable CMAC
file(READ "./mbedtls/include/mbedtls/config.h" MbedTLS_CONFIG_FILE)
string(REPLACE "//#define MBEDTLS_CMAC_C" "#define MBEDTLS_CMAC_C" MbedTLS_CONFIG_FILE_CMAC "${MbedTLS_CONFIG_FILE}")
file(WRITE "./mbedtls/include/mbedtls/config.h" "${MbedTLS_CONFIG_FILE_CMAC}")
add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
target_include_directories(mbedcrypto PUBLIC ./mbedtls/include)
add_library(MbedTLS::mbedcrypto ALIAS mbedcrypto)
endif()
# MicroProfile
add_library(microprofile INTERFACE)

View File

@@ -832,7 +832,7 @@ endif()
create_target_directory_groups(core)
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::opus)
target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt::fmt nlohmann_json::nlohmann_json MbedTLS::mbedcrypto Opus::opus)
if (MINGW)
target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY})
endif()

View File

@@ -15,7 +15,7 @@ if (ENABLE_WEB_SERVICE)
target_link_libraries(yuzu-room PRIVATE web_service)
endif()
target_link_libraries(yuzu-room PRIVATE mbedtls mbedcrypto)
target_link_libraries(yuzu-room PRIVATE MbedTLS::mbedcrypto)
if (MSVC)
target_link_libraries(yuzu-room PRIVATE getopt)
endif()