# Sets the minimum version of CMake required to build the native
# library. You should either keep the default value or only pass a
# value of 3.4.0 or lower.

cmake_minimum_required(VERSION 3.4.1)

SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DDEBUG -D_DEBUG -frtti -fexceptions")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -frtti -fexceptions")
message("CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}")
message("CMAKE_CXX_FLAGS_RELEASE is ${CMAKE_CXX_FLAGS_RELEASE}")
message("CMAKE_CXX_FLAGS_RELWITHDEBINFO is ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
message("Build type: ${CMAKE_BUILD_TYPE}")

macro( add_recursive dir retVal )
    file( GLOB_RECURSE ${retVal} ${dir}/*.h ${dir}/*.cpp ${dir}/*.c )
endmacro()

#add_recursive( src/main/cpp/SamplesCommon/ SAMPLES_COMMON_FILES )
#add_recursive( src/main/cpp/CustomRenderable/ CUSTOM_RENDERABLE_FILES )
#add_recursive( src/main/cpp/PbsMaterials/ PBS_MATERIALS_FILES )

SET(OGRE_ANDROID_BUILD_INCLUDE_PATH C:/Sebi2/projects/ogre_build_android2)
SET(OGRE_WIN32_BUILD_INCLUDE_PATH c:/Sebi/projects/ogre_build5)
SET(OGRE_ZZIPLIB_PATH C:/Sebi2/projects/ogredeps/src)
SET(OGRE_INCLUDE_PATH c:/Sebi/projects/ogre)
SET(OGREDEPS_BUILD_INCLUDE_PATH C:/Sebi2/projects/ogre/Dependencies_android)
SET(SRC_PATH ../android/src/main/jni)

include_directories(
#${OGRE_ANDROID_BUILD_INCLUDE_PATH}/include
${OGRE_WIN32_BUILD_INCLUDE_PATH}/include
${OGRE_ZZIPLIB_PATH}/zziplib/
${OGRE_INCLUDE_PATH}/OgreMain/include/
${OGRE_INCLUDE_PATH}/OgreMain/include/Android
${OGRE_INCLUDE_PATH}/OgreMain/include/Math/Array
${OGRE_INCLUDE_PATH}/Components/Hlms/Common/include/
${OGRE_INCLUDE_PATH}/Components/Hlms/Pbs/include/
${OGRE_INCLUDE_PATH}/Components/Hlms/Unlit/include/
${OGRE_INCLUDE_PATH}/Components/Hlms/PbsMobile/include/
${OGRE_INCLUDE_PATH}/Components/Hlms/UnlitMobile/include/
${OGRE_INCLUDE_PATH}/Components/MeshLodGenerator/include/
${OGRE_INCLUDE_PATH}/Components/Overlay/include/
${OGRE_INCLUDE_PATH}/PlugIns/ParticleFX/include/
${OGRE_INCLUDE_PATH}/RenderSystems/Direct3D11/include
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EAGL
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EGL
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EGL/Android
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EGL/GLES3
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EGL/KHR
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EGL/Vao
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/include/EGL/WIN32
${OGRE_INCLUDE_PATH}/RenderSystems/NULL/include

${OGRE_INCLUDE_PATH}/OgreMain/src/
${OGRE_INCLUDE_PATH}/OgreMain/src/Android
${OGRE_INCLUDE_PATH}/Components/Hlms/Common/src/
${OGRE_INCLUDE_PATH}/Components/Hlms/Pbs/src/
${OGRE_INCLUDE_PATH}/Components/Hlms/Unlit/src/
${OGRE_INCLUDE_PATH}/Components/Hlms/PbsMobile/src/
${OGRE_INCLUDE_PATH}/Components/Hlms/UnlitMobile/src/
${OGRE_INCLUDE_PATH}/Components/MeshLodGenerator/src/
${OGRE_INCLUDE_PATH}/Components/Overlay/src/
${OGRE_INCLUDE_PATH}/PlugIns/ParticleFX/src/
${OGRE_INCLUDE_PATH}/RenderSystems/Direct3D11/src
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EAGL
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EGL
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EGL/Android
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EGL/GLES3
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EGL/KHR
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EGL/Vao
${OGRE_INCLUDE_PATH}/RenderSystems/GLES3/src/EGL/WIN32
${OGRE_INCLUDE_PATH}/RenderSystems/NULL/src

${OGREDEPS_BUILD_INCLUDE_PATH}/include/
C:/Program\ Files/Java/jdk1.8.0_261/include
C:/Program\ Files/Java/jdk1.8.0_261/include/win32/
#"src/main/cpp/SamplesCommon/"
#"src/main/cpp/CustomRenderable/"
#"src/main/cpp/PbsMaterials/"
)

# build native_app_glue as a static lib
#add_library(app-glue STATIC
#            ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds it for you.
# Gradle automatically packages shared libraries with your APK.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

add_library( # Sets the name of the library.
             native-client-lib
             #native-server-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             # Associated headers in the same location as their source
             # file are automatically included.
             ${SRC_PATH}/blackholedarksunmain.cpp
             ${SRC_PATH}/HotshotGorillaGUI.cpp
             ${SRC_PATH}/HotshotGorillaGUISprite.cpp
             ${SRC_PATH}/HotshotGorillaGUINinePatch.cpp
             ${SRC_PATH}/HotshotGorillaGUIScreenRenderable.cpp
             ${SRC_PATH}/HotshotGorillaGUIScreen.cpp
             ${SRC_PATH}/HotshotVector.cpp
             ${SRC_PATH}/HotshotLoadingScreen.cpp
			 ${SRC_PATH}/JniCommon.cpp
             ${SRC_PATH}/RayQueryExecuteFrameEndListenerExecutor.cpp
             ${SRC_PATH}/CommandBufferUtility.cpp
             ${SRC_PATH}/DynamicOverlayBox.cpp
             ${SRC_PATH}/DynamicOverlayElement.cpp
             ${SRC_PATH}/HotshotTiledAnimation.cpp
             ${SRC_PATH}/HotshotTiledAnimationFrameEndListener.cpp
             ${SRC_PATH}/HotshotSceneCompositor.cpp
             ${SRC_PATH}/HotshotFullQuadAnimationController.cpp
             ${SRC_PATH}/HotshotCommon.cpp
             #${SRC_PATH}/GameViewControllerImpl.cpp
             #${SRC_PATH}/MetalViewCallbacksImpl.cpp
             #${SAMPLES_COMMON_FILES}
             #${CUSTOM_RENDERABLE_FILES}
             #${PBS_MATERIALS_FILES}
)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because system libraries are included in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

#find_library( # Sets the name of the path variable.
#              log-lib
#
#              # Specifies the name of the NDK library that
#              # you want CMake to locate.
#              log )
#find_library( # Sets the name of the path variable.
#              gles2-lib
#
#              # Specifies the name of the NDK library that
#              # you want CMake to locate.
#              GLESv2 )
#find_library( # Sets the name of the path variable.
#              egl-lib
#
#              # Specifies the name of the NDK library that
#              # you want CMake to locate.
#              EGL )
#find_library( # Sets the name of the path variable.
#              android-lib
#
#              # Specifies the name of the NDK library that
#              # you want CMake to locate.
#              android )
#find_library( # Sets the name of the path variable.
#              zlib-lib
#
#              # Specifies the name of the NDK library that
#              # you want CMake to locate.
#              z )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in the
# build script, prebuilt third-party libraries, or system libraries.

#target_include_directories(native-lib PRIVATE
#                           ${ANDROID_NDK}/sources/android/native_app_glue)
                           
#SET(OGRE_LIB_PATH d:/Sebi/projects/ogre_build_android2/lib)
#SET(OGRE_DEPS_LIB_PATH d:/Sebi/projects/ogre/Dependencies_android/lib)
SET(OGRE_LIB_PATH c:/Sebi/projects/ogre_build5/lib/Debug)
SET(OGRE_DEPS_LIB_PATH C:/Sebi/projects/ogre_dependencies_build/ogredeps/lib/Debug)

target_link_libraries( # Specifies the target library.
                       native-client-lib
                       #native-server-lib

                       # Links the target library to the log library
                       # included in the NDK.

                       #reenable these for android build
                       #${log-lib}
                       #${gles2-lib}
                       #${egl-lib}
                       #${android-lib}
                       #${zlib-lib}
                       #reenable until here
                       #app-glue

                       #For android
                       #${OGRE_LIB_PATH}/libOgreOverlayStatic_d.a
                       #${OGRE_LIB_PATH}/libOgreHlmsPbsStatic_d.a
                       #${OGRE_LIB_PATH}/libOgreHlmsUnlitStatic_d.a
                       #{OGRE_LIB_PATH}/libOgreMeshLodGeneratorStatic_d.a
                       #${OGRE_LIB_PATH}/libPlugin_ParticleFXStatic_d.a
                       #${OGRE_LIB_PATH}/libRenderSystem_GLES3Static_d.a
                       #${OGRE_LIB_PATH}/libOgreMainStatic_d.a
                       #${OGRE_LIB_PATH}/libRenderSystem_GLES3Static_d.a
                       #${OGRE_DEPS_LIB_PATH}/libfreetype.a
                       #${OGRE_DEPS_LIB_PATH}/libzziplib.a
                       #${OGRE_DEPS_LIB_PATH}/libFreeImage.a

                       #For win32
                          ${OGRE_LIB_PATH}/OgreOverlayStatic_d.lib
                          ${OGRE_LIB_PATH}/OgreHlmsPbsStatic_d.lib
                          ${OGRE_LIB_PATH}/OgreHlmsUnlitStatic_d.lib
                          ${OGRE_LIB_PATH}/OgreMeshLodGeneratorStatic_d.lib
                          ${OGRE_LIB_PATH}/Plugin_ParticleFXStatic_d.lib
                          #${OGRE_LIB_PATH}/RenderSystem_GLES3Static_d.lib
						  #${OGRE_LIB_PATH}/RenderSystem_GL3PlusStatic_d.lib
						  ${OGRE_LIB_PATH}/RenderSystem_Direct3D11Static_d.lib
                          #${OGRE_LIB_PATH}/RenderSystem_NULLStatic_d.lib
                          ${OGRE_LIB_PATH}/OgreMainStatic_d.lib
                          #${OGRE_LIB_PATH}/RenderSystem_GLES3Static_d.lib
						  #${OGRE_LIB_PATH}/RenderSystem_GL3PlusStatic_d.lib
						  ${OGRE_LIB_PATH}/RenderSystem_Direct3D11Static_d.lib
                          #${OGRE_LIB_PATH}/RenderSystem_NULLStatic_d.lib
						  #c:/glew-2.0.0/lib/Release/Win32/glew32.lib
						  #c:/glew-2.0.0/lib/Release/Win32/glew32s.lib
						  glu32.lib
						  opengl32.lib
						  d3d11.lib
						  #windowscodecs.lib
						  dxguid.lib
						  d3dcompiler.lib
						  dxgi.lib
                          ${OGRE_DEPS_LIB_PATH}/Freetype_d.lib
                          ${OGRE_DEPS_LIB_PATH}/zziplib_d.lib
                          ${OGRE_DEPS_LIB_PATH}/FreeImage_d.lib
						  c:/gleslibs/libEGL.lib
						  c:/gleslibs/libGLESv2.lib
)
