find_program(LLVM_CONFIG NAMES llvm-config DOC "llvm-config executable")


if (NOT ${LLVM_CONFIG} STREQUAL "LLVM_CONFIG-NOTFOUND")

	execute_process(
		COMMAND ${LLVM_CONFIG} --cppflags
		OUTPUT_VARIABLE LLVM_CXX_FLAGS
		OUTPUT_STRIP_TRAILING_WHITESPACE
	)

	execute_process(
		COMMAND ${LLVM_CONFIG} --ldflags
		OUTPUT_VARIABLE LLVM_LINKER_FLAGS
		OUTPUT_STRIP_TRAILING_WHITESPACE
	)
	execute_process(
		COMMAND ${LLVM_CONFIG} --libs all
		OUTPUT_VARIABLE LLVM_ALL_LIBS
		OUTPUT_STRIP_TRAILING_WHITESPACE
	)

	SET(LLVM_FOUND TRUE)

endif()
