if("$ENV{LTO}" STREQUAL "yes")
	find_program(GCC_AR "gcc-ar")
	find_program(GCC_RANLIB "gcc-ranlib")
	if("${GCC_AR}" STREQUAL "GCC_AR-NOTFOUND" OR "${GCC_RANLIB}" STREQUAL "GCC_RANLIB-NOTFOUND")
		message("gcc-ranlib or gcc-ar not found, disabling LTO")
	else("${GCC_AR}" STREQUAL "GCC_AR-NOTFOUND" OR "${GCC_RANLIB}" STREQUAL "GCC_RANLIB-NOTFOUND")
		set(COMPILER_CFLAGS "${COMPILER_CFLAGS} -flto")
		set(COMPILER_CXXCFLAGS "${COMPILER_CFLAGS} -flto")
		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g -flto")
		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g -flto")
		set(CMAKE_AR "${GCC_AR}")
		set(CMAKE_RANLIB "${GCC_RANLIB}")
	endif("${GCC_AR}" STREQUAL "GCC_AR-NOTFOUND" OR "${GCC_RANLIB}" STREQUAL "GCC_RANLIB-NOTFOUND")
endif("$ENV{LTO}" STREQUAL "yes")
