depot/third_party/nixpkgs/pkgs/by-name/li/libajantv2/use-system-mbedtls.patch

86 lines
3.4 KiB
Diff

Commit ID: 1aeee534119a22e717ce3d0e9f62c8791cd825b9
Change ID: pzyrusopmyvtvnwnruvrltqtpqtzxrpo
Author: Luke Granger-Brown <git@lukegb.com> (2024-12-20 18:03:16)
Committer: Luke Granger-Brown <git@lukegb.com> (2024-12-20 18:03:25)
Use system mbedtls, rather than downloading from a random Git branch...
diff --git a/ajantv2/CMakeLists.txt b/ajantv2/CMakeLists.txt
index ffa572e9c8..74c23e8e4e 100644
--- a/ajantv2/CMakeLists.txt
+++ b/ajantv2/CMakeLists.txt
@@ -52,49 +52,13 @@
else()
message(STATUS "NTV2 SDK will load signed 3rd-party plugins")
- set(MBEDTLS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/mbedtls-install)
- set(MBEDTLS_INCLUDE_DIR ${MBEDTLS_INSTALL_DIR}/include)
- set(MBEDTLS_LIBRARY_DIR ${MBEDTLS_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
-
- if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- set(MBEDTLS_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedtls.lib)
- set(MBEDX509_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedx509.lib)
- set(MBEDCRYPTO_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedcrypto.lib)
- set(MBEDTLS_EXTRA_CONFIG_FLAGS
- "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
- "-DMSVC_STATIC_RUNTIME=ON"
- "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
- elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin)$")
- set(MBEDTLS_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedtls.a)
- set(MBEDX509_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedx509.a)
- set(MBEDCRYPTO_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedcrypto.a)
- set(MBEDTLS_C_FLAGS -fPIC)
- endif()
-
- # BUILD_BYPRODUCTS informing CMake where the .a files are located is required to make Ninja build work
- ExternalProject_Add(
- mbedtls
- GIT_REPOSITORY https://github.com/aja-video/mbedtls.git
- GIT_TAG fix-win-dll-cmake
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MBEDTLS_INSTALL_DIR}
- -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- -DENABLE_TESTING=OFF
- -DENABLE_PROGRAMS=OFF
- -DCMAKE_C_FLAGS=${MBEDTLS_C_FLAGS}
- -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
- -DUSE_STATIC_MBEDTLS_LIBRARY=ON
- -DUSE_SHARED_MBEDTLS_LIBRARY=OFF
- ${MBEDTLS_EXTRA_CONFIG_FLAGS}
- BUILD_ALWAYS TRUE
- BUILD_BYPRODUCTS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY}
- )
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(MBEDTLS REQUIRED mbedtls mbedcrypto mbedx509)
list(APPEND TARGET_INCLUDE_DIRS
${MBEDTLS_INCLUDE_DIR})
list(APPEND MBEDTLS_LINK_LIBS
- ${MBEDTLS_LIBRARY}
- ${MBEDCRYPTO_LIBRARY}
- ${MBEDX509_LIBRARY})
+ ${MBEDTLS_LIBRARIES})
endif()
@@ -668,10 +632,6 @@
aja_ntv2_log_build_info()
add_library(${PROJECT_NAME} SHARED ${TARGET_SOURCES})
-
- if (NOT AJANTV2_DISABLE_PLUGIN_LOAD)
- add_dependencies(${PROJECT_NAME} mbedtls)
- endif()
target_compile_definitions(${PROJECT_NAME} PUBLIC
${TARGET_COMPILE_DEFS_DYNAMIC}
@@ -687,10 +647,6 @@
add_library(${PROJECT_NAME} STATIC ${TARGET_SOURCES})
- if (NOT AJANTV2_DISABLE_PLUGIN_LOAD)
- add_dependencies(${PROJECT_NAME} mbedtls)
- endif()
-
target_compile_definitions(${PROJECT_NAME} PUBLIC
${TARGET_COMPILE_DEFS_STATIC}
${AJANTV2_TARGET_COMPILE_DEFS})