cmake_minimum_required(VERSION 3.4.1)

set(SAMPLE_CPP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(COCOS2DX_ROOT_PATH "~/cocos2d-x") #setup to cocos2d-x path

if (NOT "$ENV{HOME}" STREQUAL "")
  set(DEFAULT_COCOS2D_ROOT "$ENV{HOME}/cocos2d-x")
else()
  set(DEFAULT_COCOS2D_ROOT "COCOS2D_ROOT")
endif()

if ("${COCOS2D_ROOT}" STREQUAL "")
  set(COCOS2D_ROOT ${DEFAULT_COCOS2D_ROOT})
endif()

file(GLOB SRC_FILES ${SAMPLE_CPP_DIR}/../../../Classes/*.cpp 
# add v1 -- begin
  ${SAMPLE_CPP_DIR}/../../../v1/Classes/*.cpp
  ${SAMPLE_CPP_DIR}/../../../v1/src/*.cpp
  ${SAMPLE_CPP_DIR}/../../../v1/src/**/*.cpp
#  ${SAMPLE_CPP_DIR}/../../../v1/src/Android/*.cpp
#  ${SAMPLE_CPP_DIR}/../../../v1/src/cocos2d-x/*.cpp
#  ${SAMPLE_CPP_DIR}/../../../v1/src/protection/*.cpp
# add v1 -- end
# add c2s -- begin
  ${SAMPLE_CPP_DIR}/../../../c2s/Classes/*.cpp
  ${SAMPLE_CPP_DIR}/../../../c2s/src/*.c
# add c2s -- end
 )
add_library( 
  # Sets the name of the library.
  MyGame
  # 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_FILES}
  hellocpp/JNISample.cpp
  hellocpp/main.cpp)

include_directories(
  ${SAMPLE_CPP_DIR}/../../../Classes/
# add v1 -- begin
  ${SAMPLE_CPP_DIR}/../../../v1/Classes/
  ${SAMPLE_CPP_DIR}/../../../v1/src/
  ${SAMPLE_CPP_DIR}/hellocpp/
# add v1 -- end
# add c2s -- begin
  ${SAMPLE_CPP_DIR}/../../../c2s/Classes/
  ${SAMPLE_CPP_DIR}/../../../c2s/src/
# add c2s -- end
)
# 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( log-lib log)
# find_library( z-lib 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_link_libraries( 
  # Specifies the target library.
  MyGame
  HIVE_SDK

  # Links the target library to the log library
  # included in the NDK.
  ${log-lib}
#  ${z-lib}
)

#hivesdk library import
add_subdirectory(${SAMPLE_CPP_DIR}/hivesdk)

#cocos library import after add_library( MyGame ... )
add_subdirectory(${COCOS2D_ROOT}/prebuilt/android ${SAMPLE_CPP_DIR}/build/Cocos2d)
use_cocos_prebuilt(${COCOS2D_ROOT} MyGame)


#[[

set(HIVEADKIT_DIR_PATH ${SAMPLE_CPP_DIR}/../../../HIVEAdKit) #setup to HIVEAdKit path
#HIVEAdKit library import after add_library( MyGame ... )
add_subdirectory(${HIVEADKIT_DIR_PATH} ${SAMPLE_CPP_DIR}/build/HIVEAdKit) #HIVEAdKit library & macro load
use_hiveadkit_prebuilt(${HIVEADKIT_DIR_PATH} MyGame) #library import automatic macro to build target

]]
