if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
 set (SLIB_ARM YES)
 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  set (SLIB_ARM64 YES)
 endif()
endif()
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^x86" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i[3456]86")
 set (SLIB_X86 YES)
 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  set (SLIB_X86_64 YES)
 endif()
endif()

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
# generates no debug information
if (CMAKE_BUILD_TYPE MATCHES Release)
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -fvisibility=hidden")
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g0 -fvisibility=hidden")
endif()
if (SLIB_ARM AND NOT SLIB_ARM64)
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -mfpu=neon")
 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm -mfpu=neon")
 set (CMAKE_ASM_FLAGS, "${CMAKE_ASM_FLAGS} -marm -mfpu=neon")
endif()

set (SLIB_LIB_PATH "${SLIB_PATH}/lib/CMake/${CMAKE_BUILD_TYPE}-${CMAKE_SYSTEM_PROCESSOR}")
set (SLIB_BIN_PATH "${SLIB_PATH}/bin/CMake/${CMAKE_SYSTEM_PROCESSOR}")
if (ANDROID)
 set (SLIB_LIB_PATH "${SLIB_PATH}/lib/Android/${CMAKE_BUILD_TYPE}-${ANDROID_ABI}")
 set (SLIB_BIN_PATH "${SLIB_PATH}/bin/Android/${ANDROID_ABI}")
endif()
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
 set (SLIB_LIB_PATH "${SLIB_PATH}/lib/Linux/${CMAKE_BUILD_TYPE}-${CMAKE_SYSTEM_PROCESSOR}")
 set (SLIB_BIN_PATH "${SLIB_PATH}/bin/Linux/${CMAKE_SYSTEM_PROCESSOR}")
endif()

if (CMAKE_SYSTEM_NAME STREQUAL Linux)
 set (SLIB_LINK_WRAP_FLAGS "-Wl,--wrap=memcpy -Wl,--wrap=powf -Wl,--wrap=logf -Wl,--wrap=expf -Wl,--wrap=fcntl64")
 set (SLIB_LINK_STATIC_GCC_FLAGS "${SLIB_LINK_WRAP_FLAGS} -static-libgcc")
 set (SLIB_LINK_STATIC_FLAGS "${SLIB_LINK_STATIC_GCC_FLAGS} -static-libstdc++")
endif()
