blob: 43807a4fdbfc5e2dd993ad7b50ca33472078099a [file] [log] [blame]
set(ANDROID_EMUGL_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(GOLDFISH_EMUGL_DIR
${ANDROID_QEMU2_TOP_DIR}/../../device/generic/goldfish-opengl/)
# We start of defining an interface library that defines all the compiler
# settings we wish to use for all libs. please keep this at a bare minimum!
android_add_interface(TARGET emugl_base LICENSE Apache-2.0)
target_compile_definitions(emugl_base INTERFACE "-DEMUGL_BUILD=1")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(emugl_base INTERFACE "-DEMUGL_DEBUG=1")
endif()
# Compile emugen for the current host.
android_compile_for_host(emugen ${CMAKE_CURRENT_LIST_DIR}/host/tools/emugen
EMUGEN_EXE)
# This will generate the source files by executing the emugen builder.
function(generate_emugen SRC # cmake-format: sortable
NAME)
get_filename_component(DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SRC}" ABSOLUTE)
list(APPEND GENERATED_SRC # cmake-format: sortable
${CMAKE_CURRENT_BINARY_DIR}/${NAME}_dec.cpp)
list(APPEND GENERATED_SRC # cmake-format: sortable
${CMAKE_CURRENT_BINARY_DIR}/${NAME}_dec.h)
list(APPEND GENERATED_SRC # cmake-format: sortable
${CMAKE_CURRENT_BINARY_DIR}/${NAME}_opcodes.h)
list(APPEND GENERATED_SRC # cmake-format: sortable
${CMAKE_CURRENT_BINARY_DIR}/${NAME}_server_context.h)
list(APPEND GENERATED_SRC # cmake-format: sortable
${CMAKE_CURRENT_BINARY_DIR}/${NAME}_server_context.cpp)
add_custom_command(
PRE_BUILD OUTPUT ${GENERATED_SRC}
COMMAND ${EMUGEN_EXE} -D ${CMAKE_CURRENT_BINARY_DIR} -i ${DIR} ${NAME}
DEPENDS ${EMUGEN_EXE})
set(${NAME}-SOURCES ${GENERATED_SRC} PARENT_SCOPE)
endfunction()
# Creates the library by generating the sources.
function(generate_emugen_lib LIBNAME LOCATION NAME SOURCES)
generate_emugen(${LOCATION} ${NAME})
android_add_library(
TARGET ${LIBNAME} LICENSE Apache-2.0 SRC # cmake-format: sortable
${${NAME}-SOURCES} ${SOURCES})
target_include_directories(
${LIBNAME}
PUBLIC ${LOCATION} host/include/OpenGLESDispatch host/include/
host/libs/libGLSnapshot shared/OpenglCodecCommon
${CMAKE_CURRENT_BINARY_DIR})
target_compile_options(${LIBNAME} PRIVATE -fvisibility=hidden)
if(OPTION_GFXSTREAM_BACKEND)
target_link_libraries(${LIBNAME} PUBLIC android-emu-shared GLSnapshot)
else()
target_link_libraries(${LIBNAME} PUBLIC android-emu GLSnapshot)
endif()
target_link_libraries(${LIBNAME} PRIVATE emugl_base)
endfunction()
# Generate the emugen libraries..
generate_emugen_lib(GLESv1_dec host/libs/GLESv1_dec gles1
host/libs/GLESv1_dec/GLESv1Decoder.cpp)
generate_emugen_lib(GLESv2_dec host/libs/GLESv2_dec gles2
host/libs/GLESv2_dec/GLESv2Decoder.cpp)
generate_emugen_lib(renderControl_dec host/libs/renderControl_dec renderControl
"")
add_subdirectory(host/libs/Translator/EGL)
add_subdirectory(host/libs/Translator/GLES_CM)
add_subdirectory(host/libs/Translator/GLES_V2)
add_subdirectory(host/libs/Translator/GLcommon)
add_subdirectory(host/libs/libGLSnapshot)
add_subdirectory(host/libs/libOpenGLESDispatch)
add_subdirectory(host/libs/libOpenglRender)
# TODO(jansene): The libraries included below are autogenerated, and requires
# these:
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_c_flag("-Wno-return-type")
add_c_flag("-Wno-unused-value")
add_c_flag("-Wno-inconsistent-missing-override")
add_c_flag("-Wno-deprecated-declarations")
add_c_flag("-Wno-reorder-init-list")
endif()
add_subdirectory(host/libs/libOpenglRender/vulkan/cereal)
add_subdirectory(shared/OpenglCodecCommon)
add_subdirectory(shared/emugl/common)
if(NOT WINDOWS AND NOT BUILDING_FOR_AARCH64)
add_subdirectory(guest)
add_subdirectory(${ANDROID_QEMU2_TOP_DIR}/../../device/generic/goldfish-opengl
goldfish-opengl)
endif()
add_subdirectory(combined)