set(SINGLE_HEADER_TARGET_DIR "." CACHE STRING "Directory where the blazer headers are located.")
message("Generating blazert_single_header.h in ${SINGLE_HEADER_TARGET_DIR}.")

file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/defines.h 		defines)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/datatypes.h 		datatypes)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/ray.h 			ray)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/scene.h 			scene)

file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/primitives/trimesh.h 	prim_trimesh)

file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/node.h 		bvh_node)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/options.h 		bvh_options)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/statistics.h 		bvh_statistics)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/bbox.h 		bvh_bbox)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/intersect.h 		bvh_intersect)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/accel.h 		bvh_accel)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/binbuffer.h 		bvh_binbuffer)
file(READ ${SINGLE_HEADER_TARGET_DIR}/blazert/bvh/builder.h 		bvh_builder)

# TODO: Include the embree tracing

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "// ** DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO-GENERATED BY CMAKE! **\n")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "#ifndef BLAZERT_SINGLE_HEADER\n")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "#define BLAZERT_SINGLE_HEADER\n")

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${defines}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${datatypes}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${ray}")

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${prim_trimesh}")

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_node}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_options}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_statistics}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_bbox}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_intersect}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_accel}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_binbuffer}")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${bvh_builder}")

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\n${scene}")

# TODO: Filter out embree_scene and blazert_scene

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "\nnamespace blazert {\n")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "template<typename T>\n")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "using Scene = blazert::BlazertScene<T>;\n")
file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "}\n")

file(APPEND ${SINGLE_HEADER_TARGET_DIR}/blazert/blazert_single_header.h "#endif // BLAZERT_SINGLE_HEADER\n")
