set( CMAKE_SYSTEM_NAME Generic )

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

if(IS_ABSOLUTE ${HUC_PATH})
    set(HUC_TOOLCHAIN_PATH ${HUC_PATH})
else()
    get_filename_component(HUC_TOOLCHAIN_PATH "${CMAKE_BINARY_DIR}/${HUC_PATH}" REALPATH)
endif()

find_file(HUC_EXE NAMES huc huc.exe HINTS ${HUC_TOOLCHAIN_PATH} NO_DEFAULT_PATH)
find_file(PCEAS_EXE NAMES pceas pceas.exe HINTS ${HUC_TOOLCHAIN_PATH} NO_DEFAULT_PATH)
message(STATUS ${PCEAS_EXE})
message(STATUS ${HUC_EXE})
set(CMAKE_C_COMPILER_WORKS 1)

set( CMAKE_C_COMPILER ${HUC_EXE})
set( CMAKE_C_COMPILER_ID huc )

set( CMAKE_C_COMPILER_ID_RUN TRUE )
set( CMAKE_C_COMPILER_ID_WORKS TRUE )
set( CMAKE_C_COMPILER_ID_FORCED TRUE )

set( CMAKE_ASM_COMPILER ${PCEAS_EXE})
set( CMAKE_ASM_COMPILER_ID pceas )

set( CMAKE_ASM_COMPILER_ID_RUN TRUE )
set( CMAKE_ASM_COMPILER_ID_WORKS TRUE )
set( CMAKE_ASM_COMPILER_ID_FORCED TRUE )

set(CMAKE_C_COMPILE_OBJECT  "<CMAKE_C_COMPILER> -S <DEFINES> <FLAGS> -o<OBJECT> <SOURCE>")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_ASM_COMPILER> -o <TARGET> -raw <OBJECTS>")
set(CMAKE_C_CREATE_STATIC_LIBRARY "")
set(CMAKE_C_CREATE_SHARED_LIBRARY "")
set(CMAKE_C_CREATE_MODULE_LIBRARY "")
