find_package(Corrade REQUIRED Main)
find_package(Magnum REQUIRED
  GL
  MeshTools
  Primitives
  SceneGraph
  Shaders)
find_package(Qt5 REQUIRED COMPONENTS 
  Core 
  Quick)

if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES)
  find_package(Magnum REQUIRED EglContext)
elseif(CORRADE_TARGET_WINDOWS)
  find_package(Magnum REQUIRED WglContext)
elseif(CORRADE_TARGET_APPLE)
  find_package(Magnum REQUIRED CglContext)
elseif(CORRADE_TARGET_UNIX)
  find_package(Magnum REQUIRED GlxContext)
else()
  message(FATAL_ERROR "Magnum context creation is not supported on this platform")
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

if(ANDROID)
  add_library(MyApplication SHARED
    arc_ball.cpp
    magnum_render.cpp
    magnum_item.cpp
    qml/main.qrc
    main.cpp)
else()
  add_executable(MyApplication
    arc_ball.cpp
    magnum_render.cpp
    magnum_item.cpp
    qml/main.qrc
    main.cpp)
endif()

# set_property(SOURCE usr/include/Magnum/GL/Attribute.h PROPERTY SKIP_AUTOMOC ON)

target_compile_definitions(MyApplication
  PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(MyApplication PRIVATE
  Corrade::Main
  Magnum::GL
  Magnum::GLContext
  Magnum::Magnum
  Magnum::MeshTools
  Magnum::Primitives
  Magnum::SceneGraph
  Magnum::Shaders
  Qt5::Core
  Qt5::Quick)

