set(CMAKE_SYSTEM_NAME Generic)

if (DEFINED ENV{SDCC_ROOT})
    message("Using defined SDCC_ROOT")
    file(TO_CMAKE_PATH "$ENV{SDCC_ROOT}" SDCC_ROOT_VAR)

    if (WIN32)
    	set(CMAKE_C_COMPILER "${SDCC_ROOT_VAR}/bin/sdcc.exe")
    else()
    	set(CMAKE_C_COMPILER "${SDCC_ROOT_VAR}/bin/sdcc")
    endif()
    set(CMAKE_FIND_ROOT_PATH "${SDCC_ROOT_VAR}")
else()
    set(CMAKE_C_COMPILER sdcc)
    set(CMAKE_FIND_ROOT_PATH /usr/share/sdcc)
endif()

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
