Boost unit test framework is always available 35/234335/8
authorDariusz Michaluk <d.michaluk@samsung.com>
Mon, 25 May 2020 10:54:30 +0000 (12:54 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Mon, 6 Jul 2020 09:59:38 +0000 (11:59 +0200)
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
tests/CMakeLists.txt

index 631e9c9..87851a5 100644 (file)
@@ -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)
 
index bae6eb4..fb35fbd 100644 (file)
@@ -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 <d.michaluk@samsung.com>
+# @author      Jaroslaw Pelczar <j.pelczar@samsung.com>
 
-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})