Commit aab8e0e3 authored by Ghislain MARY's avatar Ghislain MARY

Find tester component of bctoolbox for tester build + do not use object library.

parent 916a3bc8
......@@ -61,22 +61,12 @@ endif()
include(GNUInstallDirs)
include(CheckLibraryExists)
check_library_exists("m" "sqrt" "" HAVE_SQRT)
if(ENABLE_TESTS)
find_package(CUnit)
if(CUNIT_FOUND)
check_library_exists(${CUNIT_LIBRARIES} "CU_add_suite" "" HAVE_CU_ADD_SUITE)
check_library_exists(${CUNIT_LIBRARIES} "CU_get_suite" "" HAVE_CU_GET_SUITE)
check_library_exists(${CUNIT_LIBRARIES} "CU_curses_run_tests" "" HAVE_CU_CURSES)
else()
message(WARNING "Could not find cunit framework, tests will not be compiled.")
set(ENABLE_TESTS OFF CACHE BOOL "Enable compilation of tests" FORCE)
endif()
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox REQUIRED)
find_package(BcToolbox REQUIRED OPTIONAL_COMPONENTS tester)
endif()
find_package(XML2)
......@@ -107,15 +97,11 @@ endif()
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}
${BCTOOLBOX_INCLUDE_DIRS}
${BCTOOLBOX_CORE_INCLUDE_DIRS}
)
set(LIBS ${BCTOOLBOX_LIBRARIES})
set(LIBS ${BCTOOLBOX_CORE_LIBRARIES})
if(CUNIT_FOUND)
include_directories(${CUNIT_INCLUDE_DIRS})
list(APPEND LIBS ${CUNIT_LIBRARIES})
endif()
if(XML2_FOUND)
include_directories(${XML2_INCLUDE_DIRS})
list(APPEND LIBS ${XML2_LIBRARIES})
......@@ -134,7 +120,7 @@ endif()
add_subdirectory(include)
add_subdirectory(src)
if(ENABLE_TESTS)
if(ENABLE_TESTS AND BCTOOLBOX_TESTER_FOUND)
enable_testing()
add_subdirectory(test)
endif()
......
......@@ -34,7 +34,7 @@ endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox REQUIRED)
find_package(BcToolbox REQUIRED COMPONENTS core)
endif()
get_filename_component(BZRTP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
......@@ -43,8 +43,8 @@ if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
else()
set(BZRTP_INCLUDE_DIRS "${BZRTP_CMAKE_DIR}/../../../include")
endif()
list(APPEND BZRTP_INCLUDE_DIRS ${BCTOOLBOX_INCLUDE_DIRS})
list(APPEND BZRTP_LIBRARIES ${BCTOOLBOX_LIBRARIES})
list(APPEND BZRTP_INCLUDE_DIRS ${BCTOOLBOX_CORE_INCLUDE_DIRS})
list(APPEND BZRTP_LIBRARIES ${BCTOOLBOX_CORE_LIBRARIES})
if(@ENABLE_SHARED@)
set(BZRTP_LIBRARIES bzrtp)
else()
......
############################################################################
# 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)
......@@ -36,11 +36,8 @@ endif()
apply_compile_flags(SOURCE_FILES "CPP")
add_library(bzrtp-objects OBJECT ${SOURCE_FILES})
set_target_properties(bzrtp-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(ENABLE_STATIC)
add_library(bzrtp-static STATIC $<TARGET_OBJECTS:bzrtp-objects>)
add_library(bzrtp-static STATIC ${SOURCE_FILES})
set_target_properties(bzrtp-static PROPERTIES OUTPUT_NAME bzrtp)
target_link_libraries(bzrtp-static ${LIBS})
install(TARGETS bzrtp-static EXPORT ${EXPORT_TARGETS_NAME}Targets
......@@ -49,7 +46,7 @@ if(ENABLE_STATIC)
)
endif()
if(ENABLE_SHARED)
add_library(bzrtp SHARED $<TARGET_OBJECTS:bzrtp-objects>)
add_library(bzrtp SHARED ${SOURCE_FILES})
set_target_properties(bzrtp PROPERTIES VERSION 0)
target_link_libraries(bzrtp ${LIBS})
if(MSVC)
......
......@@ -25,14 +25,21 @@ set(TEST_SOURCES
bzrtpParserTest.c
bzrtpTest.c
testUtils.c
../src/bzrtp.c
../src/cryptoUtils.c
../src/packetParser.c
../src/pgpwords.c
../src/stateMachine.c
../src/zidCache.c
)
apply_compile_flags(TEST_SOURCES "CPP")
add_executable(bzrtpTest ${TEST_SOURCES} $<TARGET_OBJECTS:bzrtp-objects>)
add_executable(bzrtpTest ${TEST_SOURCES})
set_target_properties(bzrtpTest PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
target_include_directories(bzrtpTest PUBLIC ${CUNIT_INCLUDE_DIR})
target_link_libraries(bzrtpTest ${CUNIT_LIBRARIES} bzrtp)
target_include_directories(bzrtpTest PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIR})
target_link_libraries(bzrtpTest ${BCTOOLBOX_TESTER_LIBRARIES} bzrtp)
if(HAVE_SQRT)
target_link_libraries(bzrtpTest m)
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