cmake: improve add_vpp_plugin macro
[vpp.git] / src / plugins / tlsmbedtls / CMakeLists.txt
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 message(STATUS "Looking for mbedTLS")
15 find_path(MBEDTLS_INCLUDE_DIR NAMES mbedtls/ssl.h)
16 find_library(MBEDTLS_LIB1 NAMES mbedtls)
17 find_library(MBEDTLS_LIB2 NAMES mbedx509)
18 find_library(MBEDTLS_LIB3 NAMES mbedcrypto)
19
20 set (MBEDTLS_LIB ${MBEDTLS_LIB1} ${MBEDTLS_LIB2} ${MBEDTLS_LIB3})
21
22 if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB)
23   include_directories(${MBEDTLS_INCLUDE_DIR})
24   add_vpp_plugin(tlsmbedtls
25     SOURCES
26     tls_mbedtls.c
27
28     LINK_LIBRARIES
29     ${MBEDTLS_LIB}
30   )
31   message(STATUS "Found mbedTLS in ${MBEDTLS_INCLUDE_DIR}")
32 else()
33   message(WARNING "-- mbedTLS not found - tlsmbedtls_plugin disabled")
34 endif()
35