if(CMAKE_BUILD_TYPE MATCHES "Rel")
    set(ROUSE_DEBUG OFF)
else()
    set(ROUSE_DEBUG ON)
endif()

if(BUILD_WITH_MAGIC)
    set(ROUSE_MAGIC ON)
else()
    set(ROUSE_MAGIC OFF)
endif()

if(BUILD_WITH_GL_CHECKS)
    set(ROUSE_GL_CHECKS ON)
else()
    set(ROUSE_GL_CHECKS OFF)
endif()

if(BUILD_WITH_OPENAL)
    set(ROUSE_AL_ENABLED ON)
    if(BUILD_WITH_AL_CHECKS)
        set(ROUSE_AL_CHECKS ON)
    else()
        set(ROUSE_AL_CHECKS OFF)
    endif()
else()
    set(ROUSE_AL_ENABLED OFF)
    set(ROUSE_AL_CHECKS  OFF)
endif()

if(NOT MAX_STEPS_PER_TICK)
    if(ROUSE_DEBUG)
        set(ROUSE_MAX_STEPS_PER_TICK 1000)
    else()
        set(ROUSE_MAX_STEPS_PER_TICK 0)
    endif()
elseif(MAX_STEPS_PER_TICK GREATER_EQUAL 0)
    set(ROUSE_MAX_STEPS_PER_TICK "${MAX_STEPS_PER_TICK}")
else()
    message(FATAL_ERROR "Invalid MAX_STEPS_PER_TICK value '${MAX_STEPS_PER_TICKS}'")
endif()

message(STATUS "ROUSE_DEBUG is ${ROUSE_DEBUG}")
message(STATUS "ROUSE_MAGIC is ${ROUSE_MAGIC}")
message(STATUS "ROUSE_GL_CHECKS is ${ROUSE_GL_CHECKS}")
message(STATUS "ROUSE_AL_ENABLED is ${ROUSE_AL_ENABLED}")
message(STATUS "ROUSE_AL_CHECKS is ${ROUSE_AL_CHECKS}")
message(STATUS "ROUSE_MAX_STEPS_PER_TICK is ${ROUSE_MAX_STEPS_PER_TICK}")

set(rouse_config_h "${CMAKE_BINARY_DIR}/config/rouse_config.h")
configure_file(cmake/rouse_config.tpl.h "${rouse_config_h}")
