diff options
author | Bohdan Solonenko (GitHub) <BSolonenko@luxoft.com> | 2018-11-29 16:00:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-29 16:00:30 +0200 |
commit | da271730c21bfe6e91be21c64e64762d5716cf07 (patch) | |
tree | e3856eb9b6a73675d39f9c2aefd2e493fdd81a92 | |
parent | 3237aade159479e56a66110aa530b61baf25800a (diff) | |
parent | 0a8bc58aaabd8b0f6c7580b21d4f1009d2c6b01c (diff) | |
download | sdl_core-feature/sdl_on_qnx7_and_agl.tar.gz |
Merge pull request #2768 from BSolonenko/feature/Refactoring_CMakeLists_for_unit_testsfeature/sdl_on_qnx7_and_agl
Feature/refactoring c make lists for unit tests
-rw-r--r-- | src/appMain/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/appMain/test/CMakeLists.txt | 38 | ||||
-rw-r--r-- | src/components/transport_manager/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tools/cmake/helpers/sources.cmake | 20 |
4 files changed, 64 insertions, 5 deletions
diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt index 61e9e01c30..5b8034f898 100644 --- a/src/appMain/CMakeLists.txt +++ b/src/appMain/CMakeLists.txt @@ -158,3 +158,7 @@ configure_file(${SDL_IN_CONFIG_FILE} ${SDL_OUT_CONFIG_FILE} @ONLY install(FILES ${SDL_OUT_CONFIG_FILE} DESTINATION ${SDL_CONFIG_INSTALL_DIR} COMPONENT sdl_core) + +if(BUILD_TESTS) + add_subdirectory(test) +endif() diff --git a/src/appMain/test/CMakeLists.txt b/src/appMain/test/CMakeLists.txt new file mode 100644 index 0000000000..8f109205cd --- /dev/null +++ b/src/appMain/test/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright (c) 2018, Ford Motor Company All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# Neither the name of the Ford Motor Company nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +project(low_voltage_signals_handler_test) + +create_test(${PROJECT_NAME}) + +target_sources(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../low_voltage_signals_handler.cc + ${CMAKE_CURRENT_LIST_DIR}/low_voltage_signals_handler_test.cc + ${COMPONENTS_DIR}/utils/test/mock_signals_posix.cc) + +target_link_libraries(${PROJECT_NAME} PRIVATE components::interface) diff --git a/src/components/transport_manager/CMakeLists.txt b/src/components/transport_manager/CMakeLists.txt index 5155f81690..add51b8283 100644 --- a/src/components/transport_manager/CMakeLists.txt +++ b/src/components/transport_manager/CMakeLists.txt @@ -50,6 +50,13 @@ target_sources( "${CMAKE_CURRENT_LIST_DIR}/src/transport_adapter/transport_adapter_listener_impl.cc" ) +if(BUILD_TESTS) + target_sources(${PROJECT_NAME} + PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/src/iap2_emulation/iap2_transport_adapter.cc" + ) +endif() + if(QNXNTO) target_sources( ${PROJECT_NAME} PRIVATE diff --git a/tools/cmake/helpers/sources.cmake b/tools/cmake/helpers/sources.cmake index 657197eaac..32b865642a 100644 --- a/tools/cmake/helpers/sources.cmake +++ b/tools/cmake/helpers/sources.cmake @@ -134,12 +134,22 @@ function(collect_sources SOURCES PATHS) set(${SOURCES} ${SOURCES_LOCAL} PARENT_SCOPE) endfunction() -function(create_test NAME SOURCES LIBS) - add_executable("${NAME}" ${CMAKE_SOURCE_DIR}/src/components/test_main.cc ${SOURCES}) - target_link_libraries("${NAME}" ${LIBS}) - target_link_libraries("${NAME}" Utils) +function(create_test NAME) + add_executable(${NAME}) + add_executable(${NAME}::${NAME} ALIAS ${NAME}) + + target_include_directories(${NAME} + PUBLIC ${GMOCK_INCLUDE_DIRECTORY} + "${COMPONENTS_DIR}/utils/test/include" + "${COMPONENTS_DIR}/include") + + target_sources(${NAME} PRIVATE + ${CMAKE_SOURCE_DIR}/src/components/test_main.cc) + + target_link_libraries(${NAME} PUBLIC utils::utils gmock) + add_test(NAME ${NAME} - COMMAND ${NAME} --gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/) + COMMAND ${NAME} --gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/) endfunction() function(create_cotired_test NAME SOURCES LIBS) |