1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00
transmission/cmake/FindMbedTLS.cmake
Mike Gelfand bc380511db
Modernize CMake code (ongoing refactoring) (#4507)
* Reformat CMake code

* Bump minimum CMake version to 3.12

* Add target sources separately via `target_source()`

* Make `tr_win32_app_info()` add target sources on its own

* Don't use `include_directories()`

* Don't use `add_definitions()`

* Limit use of `add_compile_options()`

* Move VDKQueue target declaration to a subdirectory

* Add `tr_disable_source_files_compile()` helper

* Add `tr_target_glib_resources()` helper

* Add `tr_gettext_msgfmt()` helper

* Enable AUTOUIC for Qt client

* Enable AUTORCC for Qt client

* Remove AUTO{MOC,RCC,UIC} source group overrides

* Add `tr_target_idl_files()` helper

* Move source group setup to `tr_qt_add_translation()`

* Add `tr_target_xib_files()` helper

* Prefer `target_sources()` to intermediate variables

* Use explicit visibility versions of `target_*()` commands

* Prefer genexes to conditions in `target_*()` commands

* Add `tr_allow_compile_if()` helper

* Leave only top-level `project()`, remove the rest

* Minor fixups

* Fixup Mac QL plugin install

* Fixup IDE target folders and source groups
2023-01-01 19:49:48 +00:00

51 lines
1.5 KiB
CMake

if(MBEDTLS_PREFER_STATIC_LIB)
set(MBEDTLS_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
endif()
if(UNIX)
find_package(PkgConfig QUIET)
pkg_check_modules(_MBEDTLS QUIET mbedtls)
endif()
find_path(MBEDTLS_INCLUDE_DIR
NAMES mbedtls/version.h
HINTS ${_MBEDTLS_INCLUDEDIR})
find_library(MBEDTLS_LIBRARY
NAMES mbedtls
HINTS ${_MBEDTLS_LIBDIR})
find_library(MBEDCRYPTO_LIBRARY
NAMES mbedcrypto
HINTS ${_MBEDTLS_LIBDIR})
if(_MBEDTLS_VERSION)
set(MBEDTLS_VERSION ${_MBEDTLS_VERSION})
elseif(MBEDTLS_INCLUDE_DIR)
file(STRINGS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h" MBEDTLS_VERSION_STR
REGEX "^#define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"[^\"]+\"")
if(MBEDTLS_VERSION_STR MATCHES "\"([^\"]+)\"")
set(MBEDTLS_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDCRYPTO_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MbedTLS
REQUIRED_VARS
MBEDTLS_LIBRARY
MBEDTLS_INCLUDE_DIR
VERSION_VAR MBEDTLS_VERSION)
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDCRYPTO_LIBRARY)
if(MBEDTLS_PREFER_STATIC_LIB)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${MBEDTLS_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(MBEDTLS_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()