Commit 4c02d8cf authored by johan's avatar johan

Add basic cmake find decaf library

parent 36fbc4b6
......@@ -43,6 +43,7 @@ option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." ON)
option(ENABLE_POLARSSL "Enable polarssl support" ON)
option(ENABLE_MBEDTLS "Enable mabedtls support" ON)
option(ENABLE_DECAF "Enable Elliptic Curve Cryptography support" ON)
option(ENABLE_STRICT "Pass strict flags to the compiler" ON)
option(ENABLE_TESTS_COMPONENT "Enable compilation of tests helper library" ON)
option(ENABLE_TESTS "Enable compilation of tests" ON)
......@@ -70,6 +71,14 @@ if(ENABLE_MBEDTLS)
message(STATUS "Using mbedTLS")
endif()
endif()
if(ENABLE_DECAF)
find_package(Decaf)
if(DECAF_FOUND)
message(STATUS "Using Decaf")
set(HAVE_DECAF 1)
endif()
endif()
if(ENABLE_POLARSSL AND NOT MBEDTLS_FOUND)
find_package(PolarSSL REQUIRED)
if(POLARSSL_FOUND)
......
############################################################################
# FindDecaf.txt
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the decaf include files and library
#
# DECAF_FOUND - system has lib decaf
# DECAF_INCLUDE_DIRS - the decaf include directory
# DECAF_LIBRARY - The library needed to use decaf
include(CMakePushCheckState)
include(CheckIncludeFile)
find_path(DECAF_INCLUDE_DIRS
NAMES decaf.h
PATH_SUFFIXES include
)
# find the three mbedtls library
find_library(DECAF_LIBRARY
NAMES decaf
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Decaf
DEFAULT_MSG
DECAF_INCLUDE_DIRS DECAF_LIBRARY
)
mark_as_advanced(DECAF_INCLUDE_DIRS DECAF_LIBRARY)
......@@ -21,6 +21,7 @@
****************************************************************************/
#cmakedefine HAVE_DTLS_SRTP 1
#cmakedefine HAVE_DECAF 1
#cmakedefine HAVE_CTR_DRGB_FREE 1
#cmakedefine HAVE_CU_GET_SUITE 1
#cmakedefine HAVE_CU_CURSES 1
......
......@@ -174,6 +174,17 @@ if(POLARSSL_FOUND)
target_link_libraries(bctoolbox PRIVATE ${POLARSSL_LIBRARIES})
endif()
endif()
if(DECAF_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-static PUBLIC ${DECAF_INCLUDE_DIRS})
target_link_libraries(bctoolbox-static INTERFACE ${DECAF_LIBRARY})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox PUBLIC ${DECAF_INCLUDE_DIRS})
target_link_libraries(bctoolbox PRIVATE ${DECAF_LIBRARY})
endif()
endif()
if(BCUNIT_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-tester-static PUBLIC ${BCUNIT_INCLUDE_DIRS})
......
......@@ -17,6 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <bctoolbox/crypto.h>
#ifdef HAVE_DECAF
......
......@@ -50,6 +50,9 @@ if(BCUNIT_FOUND AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(POLARSSL_FOUND)
target_link_libraries(bctoolbox_tester_exe PRIVATE ${POLARSSL_LIBRARIES})
endif()
if(DECAF_FOUND)
target_link_libraries(bctoolbox_tester_exe PRIVATE ${DECAF_LIBRARY})
endif()
set_target_properties(bctoolbox_tester_exe PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
add_test(NAME bctoolbox_tester COMMAND bctoolbox_tester --verbose)
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment