if (NOT DEFINED ENV{Y_HOST_PREFIX})
    message(FATAL_ERROR "Y_HOST_PREFIX=... must be specified.")
endif()

set(CROSS_TOOLCHAIN_PREFIX "$ENV{Y_HOST_PREFIX}")

set(CMAKE_SYSTEM_NAME yggdrasil)
set(CMAKE_C_COMPILER "${CROSS_TOOLCHAIN_PREFIX}/bin/clang")
set(CMAKE_CXX_COMPILER "${CROSS_TOOLCHAIN_PREFIX}/bin/clang++")

# Specify the target triple for your custom OS.
set(CMAKE_C_COMPILER_TARGET "x86_64-unknown-yggdrasil")
set(CMAKE_ASM_COMPILER_TARGET "x86_64-unknown-yggdrasil")

# Disable default system libraries
# set(CMAKE_EXE_LINKER_FLAGS "-nostdlib")
# set(CMAKE_SHARED_LINKER_FLAGS "-v")

set(CMAKE_C_FLAGS "--target=x86_64-unknown-yggdrasil -fPIC")
set(CMAKE_CXX_FLAGS "--target=x86_64-unknown-yggdrasil -fPIC -D_LIBCPP_HAS_NO_TREE_BARRIER")
