From b4c7b723889fce60c22276b8bc31ace54c1ce300 Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Mon, 25 May 2020 12:54:30 +0200 Subject: [PATCH] Boost unit test framework is always available Boost is widely used framework, we can assume that unit test component is always available. Additionally test/CMakeLists.txt file was rewritten a bit. Change-Id: I0efba0b1e042cd8f87d327f3ad15d3bccb7fdb78 --- cmake/CheckFrameworks.cmake | 16 ++++++------- tests/CMakeLists.txt | 55 ++++++++++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/cmake/CheckFrameworks.cmake b/cmake/CheckFrameworks.cmake index 631e9c9..87851a5 100644 --- a/cmake/CheckFrameworks.cmake +++ b/cmake/CheckFrameworks.cmake @@ -4,16 +4,14 @@ INCLUDE(CheckLibraryExists) INCLUDE(CheckFunctionExists) INCLUDE(CheckIncludeFiles) -FIND_PACKAGE(Boost 1.54 COMPONENTS unit_test_framework) - -FIND_PACKAGE(Boost 1.54 - REQUIRED +FIND_PACKAGE(Boost REQUIRED COMPONENTS - serialization - filesystem - log - thread - system) + serialization + filesystem + log + thread + system + unit_test_framework) FIND_PACKAGE(PkgConfig REQUIRED) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bae6eb4..fb35fbd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,29 +1,42 @@ -include_directories(../dcm-client ../shared ../dcm-daemon) -include_directories(${CMAKE_BINARY_DIR}/dcm-client) +# Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @file tests/CMakeLists.txt +# @author Dariusz Michaluk +# @author Jaroslaw Pelczar -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) +INCLUDE_DIRECTORIES(../dcm-client ../shared ${CMAKE_BINARY_DIR}/dcm-client) + +INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK) ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK) -add_executable(dcm_example_client example_client.cpp) -target_link_libraries(dcm_example_client device-certificate-manager) - -add_executable(dcm_example_capi example_capi.c) -target_link_libraries(dcm_example_capi device-certificate-manager) +ADD_EXECUTABLE(dcm_example_capi example_capi.c) +TARGET_LINK_LIBRARIES(dcm_example_capi device-certificate-manager) -install(TARGETS dcm_example_client dcm_example_capi - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +ADD_EXECUTABLE(dcm_example_client example_client.cpp) +TARGET_LINK_LIBRARIES(dcm_example_client device-certificate-manager) -IF(Boost_UNIT_TEST_FRAMEWORK_FOUND) - add_executable(dcm_api_test api_test.cpp) - target_link_libraries(dcm_api_test - device-certificate-manager - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +ADD_EXECUTABLE(dcm_api_test api_test.cpp) +TARGET_LINK_LIBRARIES(dcm_api_test + device-certificate-manager + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) - install(TARGETS dcm_api_test - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -ELSE() - message(STATUS "Boost::test library not found. Disabling unit test build") -ENDIF() +INSTALL(TARGETS + dcm_example_capi + dcm_example_client + dcm_api_test + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -- 2.7.4