1############################################################################ 2# 3# Copyright 2014 BMW Car IT GmbH 4# 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18############################################################################ 19 20CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 21 22FIND_PACKAGE(gtest) 23 24IF(NOT gtest_FOUND) 25 MESSAGE(STATUS "gtest not found, disabling unit tests (BUILD_ILM_API_TESTS=OFF)") 26 SET(BUILD_ILM_API_TESTS FALSE CACHE BOOL "Build unit tests for IVI LayerManagement API" FORCE) 27ENDIF() 28 29IF(BUILD_ILM_API_TESTS) 30 31 PROJECT(ivi-layermanagement-api-test) 32 33 INCLUDE_DIRECTORIES( 34 ${CMAKE_CURRENT_SOURCE_DIR}/../ilmCommon/include 35 ${CMAKE_CURRENT_SOURCE_DIR}/../ilmControl/include 36 ${CMAKE_CURRENT_SOURCE_DIR}/../ilmInput/include 37 ${CMAKE_CURRENT_BINARY_DIR}/../../protocol 38 ${WAYLAND_CLIENT_INCLUDE_DIRS} 39 ${gtest_INCLUDE_DIRS} 40 ) 41 42 LINK_DIRECTORIES( 43 ${WAYLAND_CLIENT_LIBRARY_DIRS} 44 ) 45 46 SET(LIBS 47 ilmCommon 48 ilmControl 49 ilmInput 50 ivi-application 51 ${gtest_LIBRARIES} 52 ${WAYLAND_CLIENT_LIBRARIES} 53 ) 54 55 SET(SRC_FILES 56 TestBase.cpp 57 ilm_control_test.cpp 58 ilm_control_notification_test.cpp 59 ilm_input_test.cpp 60 ilm_input_null_pointer_test.cpp 61 ) 62 63 SET(GCC_SANITIZER_COMPILE_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector-all") 64 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_SANITIZER_COMPILE_FLAGS}" ) 65 SET( CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -static-libasan -static-libubsan" ) 66 67 ADD_EXECUTABLE(${PROJECT_NAME} ${SRC_FILES}) 68 69 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS}) 70 71 ADD_DEPENDENCIES(${PROJECT_NAME} ${LIBS}) 72 73 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) 74 75 # use CTest 76 ENABLE_TESTING() 77 ADD_TEST(ilmCommon ${PROJECT_NAME}) 78 ADD_TEST(ilmControl ${PROJECT_NAME}) 79 ADD_TEST(ilmInput ${PROJECT_NAME}) 80 81ENDIF() 82