Add tester wrapper

parent a27584e1
......@@ -27,6 +27,7 @@ option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
option(ENABLE_POLARSSL "Enable polarssl support" ON)
option(ENABLE_MBEDTLS "Enable mabedtls support" ON)
option(ENABLE_TESTS "Enable compilation of tests helper library" ON)
include(CheckLibraryExists)
include(CheckSymbolExists)
......@@ -73,6 +74,10 @@ if(POLARSSL_FOUND)
set(LIBS_PRIVATE "${LIBS_PRIVATE} -L${polarssl_library_path} -lpolarssl")
endif()
if (ENABLE_TESTS)
find_package(CUnit REQUIRED)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bctoolbox.pc.in ${CMAKE_CURRENT_BINARY_DIR}/bctoolbox.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bctoolbox.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
......
############################################################################
# FindCUnit.txt
# Copyright (C) 2015 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the CUnit include file and library
#
# CUNIT_FOUND - system has CUnit
# CUNIT_INCLUDE_DIRS - the CUnit include directory
# CUNIT_LIBRARIES - The libraries needed to use CUnit
include(CheckIncludeFile)
include(CheckLibraryExists)
set(_CUNIT_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(CUNIT_INCLUDE_DIRS
NAMES CUnit/CUnit.h
HINTS _CUNIT_ROOT_PATHS
PATH_SUFFIXES include
)
if(CUNIT_INCLUDE_DIRS)
set(HAVE_CUNIT_CUNIT_H 1)
endif()
find_library(CUNIT_LIBRARIES
NAMES cunit
HINTS ${_CUNIT_ROOT_PATHS}
PATH_SUFFIXES bin lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUnit
DEFAULT_MSG
CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES
)
mark_as_advanced(CUNIT_INCLUDE_DIRS CUNIT_LIBRARIES)
......@@ -20,9 +20,11 @@
#
############################################################################
set(HEADER_FILES
crypto.h
)
set(HEADER_FILES crypto.h)
if (ENABLE_TESTS)
list(APPEND HEADER_FILES tester.h)
endif()
set(BCTOOLBOX_HEADER_FILES )
foreach(HEADER_FILE ${HEADER_FILES})
......
This diff is collapsed.
......@@ -20,22 +20,22 @@
#
############################################################################
set(BCTOOLBOX_SOURCE_FILES
)
set(BCTOOLBOX_SOURCE_FILES)
if(MBEDTLS_FOUND)
list(APPEND BCTOOLBOX_SOURCE_FILES crypto_mbedtls.c)
list(APPEND BCTOOLBOX_SOURCE_FILES crypto/mbedtls.c)
endif()
if(POLARSSL_FOUND)
if(POLARSSL_VERSION13_OK)
list(APPEND BCTOOLBOX_SOURCE_FILES crypto_polarssl.c)
list(APPEND BCTOOLBOX_SOURCE_FILES crypto/polarssl.c)
else()
list(APPEND BCTOOLBOX_SOURCE_FILES crypto_polarssl1.2.c)
list(APPEND BCTOOLBOX_SOURCE_FILES crypto/polarssl1.2.c)
endif()
endif()
if (ENABLE_TESTS)
list(APPEND BCTOOLBOX_SOURCE_FILES tester/utils.c)
endif()
add_library(bctoolbox-objects OBJECT ${BCTOOLBOX_HEADERS_FILES} ${BCTOOLBOX_SOURCE_FILES})
add_library(bctoolbox-objects OBJECT ${BCTOOLBOX_SOURCE_FILES})
set_target_properties(bctoolbox-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(ENABLE_STATIC)
......@@ -77,6 +77,17 @@ if(POLARSSL_FOUND)
target_link_libraries(bctoolbox ${POLARSSL_LIBRARIES})
endif()
endif()
if(CUNIT_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-static PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-static ${CUNIT_LIBRARIES})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox ${CUNIT_LIBRARIES})
endif()
endif()
if(ENABLE_STATIC)
install(TARGETS bctoolbox-static EXPORT ${EXPORT_TARGETS_NAME}Targets
......@@ -92,4 +103,3 @@ if(ENABLE_SHARED)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
This diff is collapsed.
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