# This file specifies the options used for building the various LLVM runtime libraries

set(CMAKE_BUILD_TYPE Release CACHE STRING "")

set(LLVM_ENABLE_RUNTIMES "libcxx;libcxxabi;libunwind" CACHE STRING "")

set(target_triple ${GELASSENHEIT_TOOLCHAIN_ARCH}-pc-gelassenheit)

set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
set(LLVM_ENABLE_BINDINGS OFF CACHE BOOL "")
set(LLVM_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
set(LLVM_BUILD_UTILS OFF CACHE BOOL "")
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(LLVM_BUILD_LLVM_DYLIB ON CACHE BOOL "")
set(LLVM_LINK_LLVM_DYLIB ON CACHE BOOL "")
set(LLVM_INSTALL_UTILS OFF CACHE BOOL "")
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
set(LLVM_INSTALL_BINUTILS_SYMLINKS OFF CACHE BOOL "")
set(LLVM_DEFAULT_TARGET_TRIPLE ${target_triple} CACHE STRING "")
set(LLVM_BINARY_DIR "${GELASSENHEIT_TOOLCHAIN_ROOT}" CACHE PATH "")

set(CMAKE_SYSROOT "${GELASSENHEIT_BUILD_DIR}/Root" CACHE PATH "")
set(compiler_flags "-nostdlib -nostdlib++")

set(CMAKE_C_COMPILER "${GELASSENHEIT_TOOLCHAIN_ROOT}/bin/clang" CACHE PATH "")
set(CMAKE_C_COMPILER_WORKS ON CACHE BOOL "")
set(CMAKE_CXX_COMPILER "${GELASSENHEIT_TOOLCHAIN_ROOT}/bin/clang++" CACHE PATH "")
set(CMAKE_CXX_COMPILER_WORKS ON CACHE BOOL "")
set(CMAKE_ASM_COMPILER "${GELASSENHEIT_TOOLCHAIN_ROOT}/bin/clang" CACHE PATH "")
set(CMAKE_ASM_COMPILER_WORKS ON CACHE BOOL "")
set(CMAKE_LINKER "${GELASSENHEIT_TOOLCHAIN_ROOT}/bin/ld.lld" CACHE PATH "")
foreach(tool ranlib;nm;objdump;objcopy;strip)
    string(TOUPPER tool Tool)
    set(CMAKE_${Tool} "${GELASSENHEIT_TOOLCHAIN_ROOT}/bin/llvm-${tool}" CACHE PATH "")
endforeach()

set(CMAKE_C_COMPILER_TARGET ${target_triple} CACHE STRING "")
set(CMAKE_CXX_COMPILER_TARGET ${target_triple} CACHE STRING "")
set(CMAKE_ASM_COMPILER_TARGET ${target_triple} CACHE STRING "")

set(CMAKE_C_FLAGS ${compiler_flags} CACHE STRING "")
set(CMAKE_CXX_FLAGS ${compiler_flags} CACHE STRING "")

set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
if (NOT "${GELASSENHEIT_TOOLCHAIN_ARCH}" STREQUAL "aarch64")
    set(LIBCXX_HAS_M_LIB ON CACHE BOOL "")
endif()
set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
