Autogenerate the CMake build

Adds a GNUMakefile that will generate the cmake files based upon the
android makefiles. This will make it easier to keep the makefiles in
sync. If the makefiles change, we will have to run make in this
directory.

It relies on the following:

- The android.mk files are using the emugl dependency mechanism
- You are in the emulator repo (as we need the emulator build.mk files)
- We translate the emugl -> json representation.
- We write the json representation to disk
- We have a python script that transforms the json to cmake

It is all driven by GNUmake, so all you have to do is type make to
regenerate the files. SOONG does not use GNUMakefiles so we should be
able to co-exist.

Change-Id: I6f9ae22397bcf9987699b946aa14921b00fc94b0
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..cf8eb96
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,14 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(GOLDFISH_DEVICE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
+add_subdirectory(shared/OpenglCodecCommon)
+add_subdirectory(system/GLESv1_enc)
+add_subdirectory(system/GLESv2_enc)
+add_subdirectory(system/renderControl_enc)
+add_subdirectory(system/OpenglSystemCommon)
+add_subdirectory(system/GLESv1)
+add_subdirectory(system/GLESv2)
+add_subdirectory(system/gralloc)
+add_subdirectory(system/egl)
+add_subdirectory(system/vulkan)
\ No newline at end of file
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..0610f29
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,60 @@
+# Copyright 2018 The Android Open Source Project
+#
+# 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.
+#
+
+# Check that we have at least GNU Make 3.81
+# We do this by detecting whether 'lastword' is supported
+#
+MAKE_TEST := $(lastword a b c d e f)
+ifneq ($(MAKE_TEST),f)
+    $(error,This build system requires GNU Make 3.81 or higher to run !)
+endif
+
+# Find the source installation path, should be this file's location.
+_BUILD_ROOT := $(dir $(lastword $(MAKEFILE_LIST)))
+_BUILD_ROOT := $(_BUILD_ROOT:%/=%)
+
+# Complain if the path contains spaces
+ifneq ($(words $(_BUILD_ROOT)),1)
+    $(info,The source installation path contains spaces: '$(_BUILD_ROOT)')
+    $(error,Please fix the problem by reinstalling to a different location.)
+endif
+
+# We are going to generate a JSON representation from the build
+GOLDFISH_OPENGL_BUILD_FOR_HOST := true
+CMAKE_GENERATE := true
+_BUILD_CORE_DIR  := ../../../external/qemu/android/build
+
+# We need the emulator's android makefile defs, so we can understand
+# the makefiles.
+include $(_BUILD_CORE_DIR)/emulator/definitions.make
+
+# We need the ability to dump json.
+include $(_BUILD_ROOT)/json-dump.mk
+
+# And we are going to build like we are an emulator host.
+include $(_BUILD_ROOT)/common.mk
+include $(_BUILD_ROOT)/Android.mk
+
+JSON_FILE := /tmp/build.json
+JSON_DUMP := [ "" $(JSON_DUMP) ]
+
+# And we are going to transform our generated json list into a set of 
+# cmake files.
+
+# This is the first target, so also the default target
+cmake:
+	@rm -f $(JSON_FILE)
+	$(call write-to-file,$(JSON_FILE),30,$(JSON_DUMP))
+	$(hide) python cmake_transform.py -i $(JSON_FILE) -c $(JSON_FILE) -o ${_BUILD_ROOT} 
\ No newline at end of file
diff --git a/cmake_transform.py b/cmake_transform.py
new file mode 100644
index 0000000..f065488
--- /dev/null
+++ b/cmake_transform.py
@@ -0,0 +1,163 @@
+#!/bin/python
+import argparse
+import json
+import logging
+import os
+import sys
+
+
+def cleanup_json(data):
+    """Cleans up the json structure by removing empty "", and empty key value
+    pairs."""
+    if (isinstance(data, unicode)):
+        copy = data.strip()
+        return None if len(copy) == 0 else copy
+
+    if (isinstance(data, dict)):
+        copy = {}
+        for key, value in data.iteritems():
+            rem = cleanup_json(value)
+            if (rem is not None):
+                copy[key] = rem
+        return None if len(copy) == 0 else copy
+
+    if (isinstance(data, list)):
+        copy = []
+        for elem in data:
+            rem = cleanup_json(elem)
+            if (rem is not None):
+                if rem not in copy:
+                    copy.append(rem)
+
+        if len(copy) == 0:
+            return None
+        return copy
+
+
+class AttrDict(dict):
+    def __init__(self, *args, **kwargs):
+        super(AttrDict, self).__init__(*args, **kwargs)
+        self.__dict__ = self
+
+    def as_list(self, name):
+        v = self.get(name, [])
+        if (isinstance(v, list)):
+            return v
+
+        return [v]
+
+
+def remove_lib_prefix(module):
+    """Removes the lib prefix, as we are not using them in CMake."""
+    if module.startswith('lib'):
+        return module[3:]
+    else:
+        return module
+
+
+def escape(msg):
+    """Escapes the "."""
+    return '"' + msg.replace('"', '\\"') + '"'
+
+
+def header():
+    """The auto generate header."""
+    return [
+        '# This is an autogenerated file! Do not edit!',
+        '# instead run make from .../device/generic/goldfish-opengl',
+        '# which will re-generate this file.'
+    ]
+
+
+def generate_module(module):
+    """Generates a cmake module."""
+    name = remove_lib_prefix(module['module'])
+    make = header()
+    make.append('set(%s_src %s)' % (name, ' '.join(module['src'])))
+    if module['type'] == 'SHARED_LIBRARY':
+        make.append('android_add_shared_library(%s)' % name)
+    else:
+        raise ValueError('Unexpected module type: %s' % module['type'])
+
+    # Fix up the includes.
+    includes = ['${GOLDFISH_DEVICE_ROOT}/' + s for s in module['includes']]
+    make.append('target_include_directories(%s PRIVATE %s)' %
+                (name, ' '.join(includes)))
+
+    # filter out definitions
+    defs = [escape(d) for d in module['cflags'] if d.startswith('-D')]
+
+    #  And the remaining flags.
+    flags = [escape(d) for d in module['cflags'] if not d.startswith('-D')]
+
+    # Make sure we remove the lib prefix from all our dependencies.
+    libs = [remove_lib_prefix(l) for l in module['libs']]
+
+    # Configure the target.
+    make.append('target_compile_definitions(%s PRIVATE %s)' %
+                (name, ' '.join(defs)))
+    make.append('target_compile_options(%s PRIVATE %s)' %
+                (name, ' '.join(flags)))
+    make.append('target_link_libraries(%s PRIVATE %s)' %
+                (name, ' '.join(libs)))
+    return make
+
+
+def main(argv=None):
+    parser = argparse.ArgumentParser(
+        description='Generates a set of cmake files'
+        'based up the js representation.'
+        'Use this to generate cmake files that can be consumed by the emulator build')
+    parser.add_argument('-i', '--input', dest='input', type=str, required=True,
+                        help='json file containing the build tree')
+    parser.add_argument('-v', '--verbose',
+                        action='store_const', dest='loglevel',
+                        const=logging.INFO, default=logging.ERROR,
+                        help='Log what is happening')
+    parser.add_argument('-o', '--output',
+                        dest='outdir', type=str, default=None,
+                        help='Output directory for create CMakefile.txt')
+    parser.add_argument('-c', '--clean', dest='output', type=str,
+                        default=None,
+                        help='Write out the cleaned up js')
+    args = parser.parse_args()
+
+    logging.basicConfig(level=args.loglevel)
+
+    with open(args.input) as data_file:
+        data = json.load(data_file)
+
+    modules = cleanup_json(data)
+
+    # Write out cleaned up json, mainly useful for debugging etc.
+    if (args.output is not None):
+        with open(args.output, 'w') as out_file:
+            out_file.write(json.dumps(modules, indent=2))
+
+    # Location --> CMakeLists.txt
+    cmake = {}
+
+    # The root, it will basically just include all the generated files.
+    root = os.path.join(args.outdir, 'CMakeLists.txt')
+    cmake[root] = header()
+    cmake[root].append('set(GOLDFISH_DEVICE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})')
+
+    # Generate the modules.
+    for module in modules:
+        location = os.path.join(args.outdir, module['path'], 'CMakeLists.txt')
+
+        # Make sure we handle the case where we have >2 modules in the same dir.
+        if location not in cmake:
+            cmake[root].append('add_subdirectory(%s)' % module['path'])
+            cmake[location] = []
+        cmake[location].extend(generate_module(module))
+
+    # Write them to disk.
+    for (loc, cmklist) in cmake.iteritems():
+        logging.info('Writing to %s', loc)
+        with open(loc, 'w') as fn:
+            fn.write('\n'.join(cmklist))
+
+
+if __name__ == '__main__':
+    sys.exit(main())
diff --git a/common.mk b/common.mk
index c15812e..7991712 100644
--- a/common.mk
+++ b/common.mk
@@ -58,7 +58,8 @@
     $(eval include $(_EMUGL_INCLUDE_TYPE))\
     $(eval _EMUGL_INCLUDE_TYPE :=) \
     $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\
-    $(if $(EMUGL_DEBUG),$(call emugl-dump-module))
+    $(if $(EMUGL_DEBUG),$(call emugl-dump-module)) \
+    $(if $(CMAKE_GENERATE), $(call dump-json-module))
 
 # Managing module exports and imports.
 #
diff --git a/json-dump.mk b/json-dump.mk
new file mode 100644
index 0000000..8abc9e7
--- /dev/null
+++ b/json-dump.mk
@@ -0,0 +1,40 @@
+JSON_DUMP :=
+
+# Older versions of GNUmake do not support actual writing to file, so we sort of do what we can
+# and write out text in chunks, escaping "
+write-to-file = \
+  $(eval _args:=) \
+  $(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),@printf "%s" $(subst ",\",$(_args)) >> $1 $(EOL)$(eval _args:=))) \
+  $(if $(_args),@printf "%s" $(subst ",\", $(_args)) >> $1) \
+
+define EOL
+
+
+endef
+
+# Functions to dump build information into a JSON tree.
+# This creates a [ "", "elem1", "elem2" ]
+dump-json-list = \
+	$(eval JSON_DUMP += [ "" ) \
+	$(if $(1),\
+      $(foreach _list_item,$(strip $1),$(eval JSON_DUMP += , "$(subst ",\",$(_list_item))")) \
+	) \
+	$(eval JSON_DUMP += ] )\
+
+# This creates , "name" : ["", "e1", "e2" ] 
+dump-property-list = \
+    $(eval JSON_DUMP += , "$(1)" : ) \
+	$(call dump-json-list, $($(2)))\
+
+# Dumps the module
+dump-json-module = \
+    $(eval JSON_DUMP += , { "module" : "$(_emugl_MODULE) ")\
+    $(eval JSON_DUMP += ,  "path" : "$(LOCAL_PATH) ")\
+    $(eval JSON_DUMP += , "type" : "$(_emugl.$(_emugl_MODULE).type)")\
+	$(call dump-property-list,includes,LOCAL_C_INCLUDES) \
+	$(call dump-property-list,cflags,LOCAL_CFLAGS) \
+	$(call dump-property-list,libs,LOCAL_SHARED_LIBRARIES) \
+	$(call dump-property-list,src,LOCAL_SRC_FILES) \
+    $(eval JSON_DUMP += } )\
+
+		
\ No newline at end of file
diff --git a/shared/OpenglCodecCommon/CMakeLists.txt b/shared/OpenglCodecCommon/CMakeLists.txt
new file mode 100644
index 0000000..dc3eb3f
--- /dev/null
+++ b/shared/OpenglCodecCommon/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(OpenglCodecCommon_host_src GLClientState.cpp GLESTextureUtils.cpp ChecksumCalculator.cpp GLSharedGroup.cpp glUtils.cpp IndexRangeCache.cpp SocketStream.cpp TcpStream.cpp auto_goldfish_dma_context.cpp goldfish_dma_host.cpp qemu_pipe_host.cpp)
+android_add_shared_library(OpenglCodecCommon_host)
+target_include_directories(OpenglCodecCommon_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(OpenglCodecCommon_host PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"eglCodecCommon\"")
+target_compile_options(OpenglCodecCommon_host PRIVATE "-fvisibility=default")
+target_link_libraries(OpenglCodecCommon_host PRIVATE android-emu-shared cutils utils log)
\ No newline at end of file
diff --git a/system/GLESv1/CMakeLists.txt b/system/GLESv1/CMakeLists.txt
new file mode 100644
index 0000000..04545d0
--- /dev/null
+++ b/system/GLESv1/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(GLESv1_CM_emulation_src gl.cpp)
+android_add_shared_library(GLESv1_CM_emulation)
+target_include_directories(GLESv1_CM_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(GLESv1_CM_emulation PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"GLES_emulation\"")
+target_compile_options(GLESv1_CM_emulation PRIVATE "-fvisibility=default")
+target_link_libraries(GLESv1_CM_emulation PRIVATE OpenglSystemCommon android-emu-shared _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
\ No newline at end of file
diff --git a/system/GLESv1_enc/CMakeLists.txt b/system/GLESv1_enc/CMakeLists.txt
new file mode 100644
index 0000000..c20ced7
--- /dev/null
+++ b/system/GLESv1_enc/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(GLESv1_enc_src GLEncoder.cpp GLEncoderUtils.cpp gl_client_context.cpp gl_enc.cpp gl_entry.cpp)
+android_add_shared_library(GLESv1_enc)
+target_include_directories(GLESv1_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(GLESv1_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"emuglGLESv1_enc\"")
+target_compile_options(GLESv1_enc PRIVATE "-fvisibility=default")
+target_link_libraries(GLESv1_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared)
\ No newline at end of file
diff --git a/system/GLESv2/CMakeLists.txt b/system/GLESv2/CMakeLists.txt
new file mode 100644
index 0000000..45d1856
--- /dev/null
+++ b/system/GLESv2/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(GLESv2_emulation_src gl2.cpp)
+android_add_shared_library(GLESv2_emulation)
+target_include_directories(GLESv2_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(GLESv2_emulation PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"GLESv2_emulation\"")
+target_compile_options(GLESv2_emulation PRIVATE "-fvisibility=default")
+target_link_libraries(GLESv2_emulation PRIVATE OpenglSystemCommon android-emu-shared _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
\ No newline at end of file
diff --git a/system/GLESv2_enc/CMakeLists.txt b/system/GLESv2_enc/CMakeLists.txt
new file mode 100644
index 0000000..a13f52e
--- /dev/null
+++ b/system/GLESv2_enc/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(GLESv2_enc_src GL2EncoderUtils.cpp GL2Encoder.cpp GLESv2Validation.cpp gl2_client_context.cpp gl2_enc.cpp gl2_entry.cpp ../enc_common/IOStream_common.cpp)
+android_add_shared_library(GLESv2_enc)
+target_include_directories(GLESv2_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(GLESv2_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"emuglGLESv2_enc\"")
+target_compile_options(GLESv2_enc PRIVATE "-fvisibility=default")
+target_link_libraries(GLESv2_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared)
\ No newline at end of file
diff --git a/system/OpenglSystemCommon/CMakeLists.txt b/system/OpenglSystemCommon/CMakeLists.txt
new file mode 100644
index 0000000..5728465
--- /dev/null
+++ b/system/OpenglSystemCommon/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(OpenglSystemCommon_src FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp ThreadInfo_host.cpp)
+android_add_shared_library(OpenglSystemCommon)
+target_include_directories(OpenglSystemCommon PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(OpenglSystemCommon PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096")
+target_compile_options(OpenglSystemCommon PRIVATE "-fvisibility=default")
+target_link_libraries(OpenglSystemCommon PRIVATE android-emu-shared _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
\ No newline at end of file
diff --git a/system/egl/CMakeLists.txt b/system/egl/CMakeLists.txt
new file mode 100644
index 0000000..9c2915c
--- /dev/null
+++ b/system/egl/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(EGL_emulation_src eglDisplay.cpp egl.cpp ClientAPIExts.cpp)
+android_add_shared_library(EGL_emulation)
+target_include_directories(EGL_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(EGL_emulation PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"EGL_emulation\"" "-DEGL_EGLEXT_PROTOTYPES")
+target_compile_options(EGL_emulation PRIVATE "-fvisibility=default")
+target_link_libraries(EGL_emulation PRIVATE OpenglSystemCommon android-emu-shared _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
\ No newline at end of file
diff --git a/system/gralloc/CMakeLists.txt b/system/gralloc/CMakeLists.txt
new file mode 100644
index 0000000..9a451ce
--- /dev/null
+++ b/system/gralloc/CMakeLists.txt
@@ -0,0 +1,18 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(gralloc.goldfish_src gralloc.cpp)
+android_add_shared_library(gralloc.goldfish)
+target_include_directories(gralloc.goldfish PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(gralloc.goldfish PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"gralloc_goldfish\"")
+target_compile_options(gralloc.goldfish PRIVATE "-fvisibility=default" "-Wno-missing-field-initializers")
+target_link_libraries(gralloc.goldfish PRIVATE OpenglSystemCommon android-emu-shared GLESv2_enc _renderControl_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(gralloc.ranchu_src gralloc.cpp)
+android_add_shared_library(gralloc.ranchu)
+target_include_directories(gralloc.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(gralloc.ranchu PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"gralloc_ranchu\"")
+target_compile_options(gralloc.ranchu PRIVATE "-fvisibility=default" "-Wno-missing-field-initializers")
+target_link_libraries(gralloc.ranchu PRIVATE OpenglSystemCommon android-emu-shared GLESv2_enc _renderControl_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
\ No newline at end of file
diff --git a/system/renderControl_enc/CMakeLists.txt b/system/renderControl_enc/CMakeLists.txt
new file mode 100644
index 0000000..9558c05
--- /dev/null
+++ b/system/renderControl_enc/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(_renderControl_enc_src renderControl_client_context.cpp renderControl_enc.cpp renderControl_entry.cpp)
+android_add_shared_library(_renderControl_enc)
+target_include_directories(_renderControl_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(_renderControl_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096")
+target_compile_options(_renderControl_enc PRIVATE "-fvisibility=default")
+target_link_libraries(_renderControl_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared)
\ No newline at end of file
diff --git a/system/vulkan/CMakeLists.txt b/system/vulkan/CMakeLists.txt
new file mode 100644
index 0000000..196c9d7
--- /dev/null
+++ b/system/vulkan/CMakeLists.txt
@@ -0,0 +1,9 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+set(vulkan.ranchu_src goldfish_vulkan.cpp)
+android_add_shared_library(vulkan.ranchu)
+target_include_directories(vulkan.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/vulkan ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include)
+target_compile_definitions(vulkan.ranchu PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DLOG_TAG=\"goldfish_vulkan\"" "-DVK_USE_PLATFORM_ANDROID_KHR" "-DVK_NO_PROTOTYPES")
+target_compile_options(vulkan.ranchu PRIVATE "-fvisibility=default" "-Wno-missing-field-initializers" "-fvisibility=hidden" "-fstrict-aliasing")
+target_link_libraries(vulkan.ranchu PRIVATE OpenglSystemCommon android-emu-shared _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host cutils utils log)
\ No newline at end of file