1# TODO(gregschlom) move this to base
2
3if(NOT DEFINED LOGGING_LIB_NAME)
4   set(LOGGING_LIB_NAME logging-base)
5endif()
6
7add_library(${LOGGING_LIB_NAME}
8    logging.cpp
9    GfxstreamFatalError.cpp
10    ../base/Metrics.cpp)
11target_include_directories(
12    ${LOGGING_LIB_NAME}
13    PRIVATE
14    include/host-common)
15target_link_libraries(
16    ${LOGGING_LIB_NAME}
17    PUBLIC
18    PRIVATE
19    aemu-base.headers
20    aemu-host-common.headers)
21
22if (BUILD_SHARED_LIBS)
23    set_target_properties(
24        ${LOGGING_LIB_NAME}
25        PROPERTIES
26        VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
27        SOVERSION ${VERSION_MAJOR})
28endif()
29
30add_library(aemu-host-common.headers INTERFACE)
31target_link_libraries(
32    aemu-host-common.headers
33    INTERFACE
34    gfxstream-snapshot.headers)
35target_include_directories(
36    aemu-host-common.headers
37    INTERFACE
38    include)
39
40if (MSVC)
41    target_link_libraries(
42        aemu-host-common.headers
43        INTERFACE
44        msvc-posix-compat)
45endif()
46if (BUILD_STANDALONE)
47    add_library(
48        aemu-host-common
49
50        # emugl glue
51        empty-crash-handler.cpp
52        crash_reporter.cpp
53        vm_operations.cpp
54        feature_control.cpp
55        dma_device.cpp
56        sync_device.cpp
57        misc.cpp
58        window_operations.cpp
59
60        # What used to be android-emu
61        AndroidPipe.cpp
62        HostmemIdMapping.cpp
63        RefcountPipe.cpp
64        GraphicsAgentFactory.cpp
65
66        # goldfish sync
67        GoldfishSyncCommandQueue.cpp
68        goldfish_sync.cpp
69
70        # goldfish dma
71        DmaMap.cpp
72        GoldfishDma.cpp
73
74        # Address space device
75        address_space_device_control_ops.cpp
76        address_space_device.cpp
77        address_space_host_memory_allocator.cpp
78        address_space_shared_slots_host_memory_allocator.cpp
79        address_space_graphics.cpp
80        address_space_host_media.cpp
81
82	# SubAllocator
83        ../base/SubAllocator.cpp
84
85        hw-config.cpp
86        )
87
88    if (BUILD_SHARED_LIBS)
89        set_target_properties(
90            aemu-host-common
91            PROPERTIES
92            VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
93            SOVERSION ${VERSION_MAJOR})
94    endif()
95
96    target_include_directories(
97        aemu-host-common
98        PRIVATE
99        include/host-common
100        ${AEMU_COMMON_REPO_ROOT}/../../../external/angle/include)
101    target_link_libraries(
102        aemu-host-common
103        PUBLIC
104        aemu-base.headers
105        aemu-host-common.headers
106        ${GFXSTREAM_BASE_LIB}
107        PRIVATE
108        ${LOGGING_LIB_NAME}
109    )
110endif()
111
112if(NOT TARGET aemu-host-common.product-feature-override)
113    add_library(aemu-host-common.product-feature-override OBJECT FeatureControlOverride.cpp)
114    target_link_libraries(
115        aemu-host-common.product-feature-override
116        PRIVATE
117        aemu-host-common.headers
118        aemu-base.headers)
119endif()
120
121if (GFXSTREAM_HOST_COMMON_LIB)
122    target_link_libraries(
123        ${GFXSTREAM_HOST_COMMON_LIB}
124        PRIVATE
125        aemu-host-common.product-feature-override)
126endif()
127
128if (ENABLE_VKCEREAL_TESTS)
129    # Tests
130    add_library(
131        aemu-host-common-testing-support
132        testing/HostAddressSpace.cpp
133        testing/MockGraphicsAgentFactory.cpp
134        testing/MockAndroidEmulatorWindowAgent.cpp
135        testing/MockAndroidMultiDisplayAgent.cpp
136        testing/MockAndroidVmOperations.cpp)
137    target_include_directories(
138        aemu-host-common-testing-support
139        PUBLIC
140        ${AEMU_COMMON_REPO_ROOT})
141    target_link_libraries(
142        aemu-host-common-testing-support
143        PUBLIC
144        PRIVATE
145        aemu-base.headers
146        aemu-host-common.headers
147        gtest
148        gmock)
149
150    add_executable(
151        aemu-host-common_unittests
152        address_space_graphics_unittests.cpp
153        address_space_host_memory_allocator_unittests.cpp
154        address_space_shared_slots_host_memory_allocator_unittests.cpp
155        HostAddressSpace_unittest.cpp
156        HostmemIdMapping_unittest.cpp
157        logging_unittest.cpp
158        GfxstreamFatalError_unittest.cpp)
159
160    target_include_directories(
161        aemu-host-common_unittests
162        PRIVATE
163        ${AEMU_COMMON_REPO_ROOT})
164
165    target_link_libraries(
166        aemu-host-common_unittests
167        PRIVATE
168        aemu-base.headers
169        aemu-host-common.headers
170        ${GFXSTREAM_BASE_LIB}
171        ${GFXSTREAM_HOST_COMMON_LIB}
172        aemu-host-common-testing-support
173        gtest_main
174        gmock_main)
175
176    gtest_discover_tests(aemu-host-common_unittests)
177endif()
178