aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/CMakeLists.txt
blob: dd1cd8e2cd2510d03ad69536e31aaea333a5fd62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
###########################################################################
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. 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.
###########################################################################

PROJECT_TARGET_ADD(vshl-capabilities-api)

    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)

    set(VSHL_CAPABILITIES_LIB_SRC
        ${CMAKE_CURRENT_SOURCE_DIR}/VshlCapabilitiesApi.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/VshlCapabilitiesApi.h

        # Interfaces
        ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/afb/IAFBApi.h
        ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/capabilities/ICapability.h
        ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/utilities/events/IEventFilter.h
        ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/utilities/logging/ILogger.h

        # AFB
        ${CMAKE_CURRENT_SOURCE_DIR}/afb/AFBApiImpl.h
        ${CMAKE_CURRENT_SOURCE_DIR}/afb/AFBApiImpl.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/afb/AFBRequestImpl.h
        ${CMAKE_CURRENT_SOURCE_DIR}/afb/AFBRequestImpl.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/afb/include/AFBEventImpl.h
        ${CMAKE_CURRENT_SOURCE_DIR}/afb/src/AFBEventImpl.cpp

        #Capabilities
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilitiesFactory.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilitiesFactory.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilityMessagingService.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilityMessagingService.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/include/MessageChannel.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/src/MessageChannel.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/include/PublisherForwarder.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/src/PublisherForwarder.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/include/SubscriberForwarder.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/src/SubscriberForwarder.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/communication/include/PhoneControlMessages.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/communication/include/PhoneControlCapability.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/communication/src/PhoneControlCapability.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/playbackcontroller/include/PlaybackControllerMessages.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/playbackcontroller/include/PlaybackControllerCapability.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/playbackcontroller/src/PlaybackControllerCapability.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/navigation/include/NavigationMessages.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/navigation/include/NavigationCapability.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/navigation/src/NavigationCapability.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/guimetadata/include/GuiMetadataMessages.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/guimetadata/include/GuiMetadataCapability.h
        ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/guimetadata/src/GuiMetadataCapability.cpp

        #Utilities
        ${CMAKE_CURRENT_SOURCE_DIR}/utilities/events/EventRouter.h
        ${CMAKE_CURRENT_SOURCE_DIR}/utilities/events/EventRouter.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/utilities/logging/Logger.h
        ${CMAKE_CURRENT_SOURCE_DIR}/utilities/logging/Logger.cpp
    )

    # Define targets
    ADD_LIBRARY(${TARGET_NAME} MODULE
        ${VSHL_CAPABILITIES_LIB_SRC}
    )

    # VSHL Capabilities plugin properties
    SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
        LABELS "PLUGIN"
        PREFIX ""
        SUFFIX ".ctlso"
        OUTPUT_NAME ${TARGET_NAME}
    )

    # Define target includes
    TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
        PUBLIC ${GLIB_PKG_INCLUDE_DIRS}
        PUBLIC  "${CMAKE_CURRENT_SOURCE_DIR}"
    )

    # Library dependencies (include updates automatically)
    TARGET_LINK_LIBRARIES(${TARGET_NAME}
        ${GLIB_PKG_LIBRARIES}
        ${link_libraries}
    )

    option(ENABLE_UNIT_TESTS "Build unit tests or not" OFF)
    if (ENABLE_UNIT_TESTS)
        execute_process(
            COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/agreement.sh"
            RESULT_VARIABLE AGREEMENT_RESULT
        )
        message(STATUS "Agreement Result: ${AGREEMENT_RESULT}")
        if (${AGREEMENT_RESULT} MATCHES "1")
            message(FATAL_ERROR "User agreement not accepted. Quitting")
        endif()

        include(cmake/gtest.cmake)

        set(VSHL_CAPABILITIES_TEST_SRC ${VSHL_CAPABILITIES_LIB_SRC})
        list(APPEND VSHL_CAPABILITIES_TEST_SRC
            # Main
            ${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp

            # Test common
            ${CMAKE_CURRENT_SOURCE_DIR}/test/common/ConsoleLogger.h
            ${CMAKE_CURRENT_SOURCE_DIR}/test/common/ConsoleLogger.cpp

            # Test Mocks
            ${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/AFBApiMock.h
            ${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/AFBEventMock.h
            ${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/AFBRequestMock.h
            ${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/CapabilityMock.h

            # Capabilities
            ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/test/CapabilityMessagingServiceTest.cpp
            ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/test/PublisherForwarderTest.cpp
            ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/test/SubscriberForwarderTest.cpp
        )

        ADD_EXECUTABLE(${TARGET_NAME}_Test
            ${VSHL_CAPABILITIES_TEST_SRC}
        )

        TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}_Test
            PUBLIC ${GLIB_PKG_INCLUDE_DIRS}
            PUBLIC  "${CMAKE_CURRENT_SOURCE_DIR}"
        )

        TARGET_LINK_LIBRARIES(${TARGET_NAME}_Test
            libgtest
            libgmock
            ${GLIB_PKG_LIBRARIES}
            ${link_libraries}
        )

        ENABLE_TESTING()
        ADD_TEST(VshlCapabilitiesTest ${TARGET_NAME}_Test)
    endif()