include_guard(GLOBAL)

# can be load multiple times and in different paths
if(NOT DEFINED __TARGET_OPTION_LOADED)
  set(__TARGET_OPTION_LOADED 1)
  include(GNUInstallDirs)
  # add CMAKE_INSTALL_*, CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_INCLUDEDIR and etc.

  if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
  endif()

  if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
  endif()

  if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
  endif()

  link_directories(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
endif()

if(NOT PROJECT_PREBUILT_PLATFORM_NAME)
  if(ANDROID_ABI)
    string(TOLOWER "${CMAKE_SYSTEM_NAME}-${ANDROID_ABI}-${CMAKE_CXX_COMPILER_ID}" PROJECT_PREBUILT_PLATFORM_NAME)
  elseif(CMAKE_OSX_ARCHITECTURES)
    string(TOLOWER "${CMAKE_SYSTEM_NAME}-${CMAKE_OSX_ARCHITECTURES}-${CMAKE_CXX_COMPILER_ID}"
                   PROJECT_PREBUILT_PLATFORM_NAME)
  else()
    string(TOLOWER "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_CXX_COMPILER_ID}"
                   PROJECT_PREBUILT_PLATFORM_NAME)
  endif()
endif()
if(NOT PROJECT_PREBUILT_HOST_PLATFORM_NAME)
  string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_CXX_COMPILER_ID}"
                 PROJECT_PREBUILT_HOST_PLATFORM_NAME)
endif()
