set(LLVM_DIR $ENV{HOME}/llvm)

include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(${LLVM_DIR}/bin/clang Clang)
CMAKE_FORCE_CXX_COMPILER(${LLVM_DIR}/bin/clang++ Clang)
set(CMAKE_AR ${LLVM_DIR}/bin/llvm-ar CACHE PATH "llvm archive")
set(CMAKE_RANLIB ${LLVM_DIR}/bin/llvm-ranlib CACHE PATH "llvm ranlib")
set(CMAKE_SIZEOF_VOID_P 8)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(USE_PRECOMPILED_HEADERS ON)
set(LFL_USE_LIBCPP ON)
set(LFL_PIC ON)
set(LFL_ADD_BITCODE_TARGETS ON)

set(ENV{CC} "${LLVM_DIR}/bin/clang")
set(ENV{CXX} "${LLVM_DIR}/bin/clang++")
set(ENV{CPP} "${LLVM_DIR}/bin/clang -E")
set(ENV{CXXCPP} "${LLVM_DIR}/bin/clang++ -E")
set(ENV{AR} "${LLVM_DIR}/bin/llvm-ar")
set(ENV{RANLIB} "${LLVM_DIR}/bin/llvm-ranlib")
set(ENV{CXXFLAGS} "-stdlib=libc++")

#set(ENV{CFLAGS} "-emit-llvm")
#set(CMAKE_C_OUTPUT_EXTENSION ".bc")
#set(CMAKE_STATIC_LIBRARY_SUFFIX ".bca")
#set(CMAKE_C_LINK_EXECUTABLE ${LLVM_DIR}/bin/llvm-ld CACHE PATH "llvm c linker")
#set(CMAKE_CXX_LINK_EXECUTABLE ${LLVM_DIR}/bin/llvm-ld CACHE PATH "llvm c++ linker")
