Commit 722e1e80 authored by Ghislain MARY's avatar Ghislain MARY

Build a separate library for tester part of bctoolbox.

parent ce02a6b3
......@@ -74,7 +74,7 @@ if(POLARSSL_FOUND)
set(LIBS_PRIVATE "${LIBS_PRIVATE} -L${polarssl_library_path} -lpolarssl")
endif()
if (ENABLE_TESTS)
if(ENABLE_TESTS)
find_package(CUnit)
if(CUNIT_FOUND)
cmake_push_check_state(RESET)
......@@ -85,7 +85,6 @@ if (ENABLE_TESTS)
cmake_pop_check_state()
else()
message(WARNING "Could not find the cunit library!")
set(ENABLE_UNIT_TESTS OFF CACHE BOOL "Enable compilation of unit tests." FORCE)
endif()
endif()
......
......@@ -20,28 +20,55 @@
#
############################################################################
#
# Config file for the belle-sip package.
# Config file for the bctoolbox package.
# Some components can be asked for: core, tester.
#
# It defines the following variables:
#
# BCTOOLBOX_FOUND - system has bctoolbox
# BCTOOLBOX_INCLUDE_DIRS - the bctoolbox include directory
# BCTOOLBOX_LIBRARIES - The libraries needed to use bctoolbox
# BCTOOLBOX_LDFLAGS - The linking flags needed to use bctoolbox
# BCTOOLBOX_${comp}_FOUND - system has bctoolbox "comp" component
# BCTOOLBOX_${comp}_INCLUDE_DIRS - the bctoolbox "comp" component include directory
# BCTOOLBOX_${comp}_LIBRARIES - The libraries needed to use bctoolbox "comp" component
if(NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${CMAKE_CURRENT_LIST_DIR}/BcToolboxTargets.cmake")
endif()
list(APPEND BcToolbox_FIND_COMPONENTS core)
list(REMOVE_DUPLICATES BcToolbox_FIND_COMPONENTS)
set(BcToolbox_FIND_REQUIRED_core TRUE)
get_filename_component(BCTOOLBOX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BCTOOLBOX_INCLUDE_DIRS "${EP_bctoolbox_INCLUDE_DIR}")
else()
set(BCTOOLBOX_INCLUDE_DIRS "${BCTOOLBOX_CMAKE_DIR}/../../../include")
endif()
if(@ENABLE_SHARED@)
set(BCTOOLBOX_LIBRARIES bctoolbox)
else()
set(BCTOOLBOX_LIBRARIES bctoolbox-static)
endif()
set(BCTOOLBOX_LDFLAGS "@LINK_FLAGS_STR@")
set(BCTOOLBOX_FOUND 1)
set(BCTOOLBOX_LIBRARIES )
foreach(comp ${BcToolbox_FIND_COMPONENTS})
string(TOUPPER ${comp} uppercomp)
if(comp STREQUAL "core")
set(targetname "bctoolbox")
else()
set(targetname "bctoolbox-${comp}")
endif()
if(NOT @ENABLE_SHARED@)
set(targetname "${targetname}-static")
endif()
if(TARGET ${targetname})
set(BCTOOLBOX_${uppercomp}_INCLUDE_DIRS "${BCTOOLBOX_INCLUDE_DIRS}")
set(BCTOOLBOX_${uppercomp}_LIBRARIES ${targetname})
list(APPEND BCTOOLBOX_LIBRARIES ${targetname})
set(BCTOOLBOX_${uppercomp}_FOUND 1)
if(comp STREQUAL "core")
set(BCTOOLBOX_FOUND 1)
endif()
elseif(BcToolbox_FIND_REQUIRED_${comp})
message(FATAL_ERROR "Required bctoolbox component \"${comp}\" cannot be found")
endif()
endforeach()
......@@ -31,19 +31,20 @@ if(POLARSSL_FOUND)
list(APPEND BCTOOLBOX_SOURCE_FILES crypto/polarssl1.2.c)
endif()
endif()
if (ENABLE_TESTS)
list(APPEND BCTOOLBOX_SOURCE_FILES tester/utils.c)
if(CUNIT_FOUND)
set(BCTOOLBOX_TESTER_SOURCE_FILES tester/utils.c)
endif()
add_library(bctoolbox-objects OBJECT ${BCTOOLBOX_SOURCE_FILES})
set_target_properties(bctoolbox-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(ENABLE_STATIC)
add_library(bctoolbox-static STATIC $<TARGET_OBJECTS:bctoolbox-objects>)
add_library(bctoolbox-static STATIC ${BCTOOLBOX_SOURCE_FILES})
set_target_properties(bctoolbox-static PROPERTIES OUTPUT_NAME bctoolbox)
if(CUNIT_FOUND)
add_library(bctoolbox-tester-static STATIC ${BCTOOLBOX_TESTER_SOURCE_FILES})
set_target_properties(bctoolbox-tester-static PROPERTIES OUTPUT_NAME bctoolbox-tester)
endif()
endif()
if(ENABLE_SHARED)
add_library(bctoolbox SHARED $<TARGET_OBJECTS:bctoolbox-objects>)
add_library(bctoolbox SHARED ${BCTOOLBOX_SOURCE_FILES})
set_target_properties(bctoolbox PROPERTIES VERSION 0.0.0 SOVERSION 0)
set_target_properties(bctoolbox PROPERTIES LINKER_LANGUAGE "CXX")
if(MSVC)
......@@ -54,6 +55,19 @@ if(ENABLE_SHARED)
)
endif()
endif()
if(CUNIT_FOUND)
add_library(bctoolbox-tester SHARED ${BCTOOLBOX_TESTER_SOURCE_FILES})
set_target_properties(bctoolbox-tester PROPERTIES VERSION 0.0.0 SOVERSION 0)
set_target_properties(bctoolbox-tester PROPERTIES LINKER_LANGUAGE "CXX")
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bctoolbox-tester.pdb
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
endif()
endif()
......@@ -79,12 +93,12 @@ if(POLARSSL_FOUND)
endif()
if(CUNIT_FOUND)
if(ENABLE_STATIC)
target_include_directories(bctoolbox-static PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-static ${CUNIT_LIBRARIES})
target_include_directories(bctoolbox-tester-static PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester-static ${CUNIT_LIBRARIES})
endif()
if(ENABLE_SHARED)
target_include_directories(bctoolbox PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox ${CUNIT_LIBRARIES})
target_include_directories(bctoolbox-tester PUBLIC ${CUNIT_INCLUDE_DIRS})
target_link_libraries(bctoolbox-tester ${CUNIT_LIBRARIES})
endif()
endif()
......@@ -93,7 +107,15 @@ if(ENABLE_STATIC)
install(TARGETS bctoolbox-static EXPORT ${EXPORT_TARGETS_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT core
)
if(CUNIT_FOUND)
install(TARGETS bctoolbox-tester-static EXPORT ${EXPORT_TARGETS_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT tester
)
endif()
endif()
if(ENABLE_SHARED)
install(TARGETS bctoolbox EXPORT ${EXPORT_TARGETS_NAME}Targets
......@@ -101,5 +123,15 @@ if(ENABLE_SHARED)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT core
)
if(CUNIT_FOUND)
install(TARGETS bctoolbox-tester EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT tester
)
endif()
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