SET(OS "@platform_os@")
SET(CPU "@use_cpu@")
SET(PLATFORM "@use_platform@")
IF("${OS}" STREQUAL "linux" OR "${OS}" STREQUAL "android")
SET(CMAKE_SYSTEM_NAME Linux)
ENDIF()

# set special CORE_SYSTEM_NAME
IF("${OS}" STREQUAL "android")
SET(CORE_SYSTEM_NAME android)
ELSEIF("${OS}" STREQUAL "ios")
SET(CORE_SYSTEM_NAME ios)
ELSEIF("${PLATFORM}" STREQUAL "raspberry-pi")
SET(CORE_SYSTEM_NAME rbpi)
ENDIF()

IF("${OS}" STREQUAL "ios" OR "${OS}" STREQUAL "osx")
SET(CMAKE_OSX_SYSROOT @use_sdk_path@)
ENDIF()
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
SET(CMAKE_C_COMPILER   @CC@)
SET(CMAKE_CXX_COMPILER @CXX@)
SET(CMAKE_AR @AR@ CACHE FILEPATH "Archiver")
SET(CMAKE_LINKER @LD@ CACHE FILEPATH "Linker")

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  @prefix@/@deps_dir@ @use_toolchain@ @use_toolchain@/usr @use_sdk_path@ @use_sdk_path@/usr @use_toolchain@/sysroot/usr)
SET(CMAKE_LIBRARY_PATH @prefix@/@deps_dir@/lib:@use_toolchain@/usr/lib/@use_host@:@use_toolchain@/lib/@use_host@)

# add RBPI's firmware directories
IF("${CORE_SYSTEM_NAME}" STREQUAL "rbpi")
  LIST(APPEND CMAKE_FIND_ROOT_PATH @use_firmware@/opt/vc)
  LIST(APPEND CMAKE_LIBRARY_PATH @use_firmware@/opt/vc/lib)
ENDIF()

SET(CMAKE_C_FLAGS "@platform_cflags@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
SET(CMAKE_CXX_FLAGS "@platform_cxxflags@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
SET(CMAKE_CPP_FLAGS "@platform_cflags@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
SET(ENV{CFLAGS} ${CMAKE_C_FLAGS})
SET(ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS})
SET(ENV{CPPFLAGS} ${CMAKE_CPP_FLAGS})
SET(ENV{LDFLAGS} "-L@prefix@/@deps_dir@/lib @platform_ldflags@")
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Binary Addons
IF(NOT OS STREQUAL "linux")
SET(ADDONS_PREFER_STATIC_LIBS ON)
ENDIF()
