cmake_minimum_required(VERSION 3.0)
project(kawaii-rs)

include(ExternalProject)

if (MEASURE)
	set(CARGO_FEATURES "${CARGO_FEATURES} measure")
endif (MEASURE)

if (CARGO_FEATURES)
	set(CARGO_ARGUMENTS --features "${CARGO_FEATURES}")
endif(CARGO_FEATURES)

file(GLOB RUST_SOURCE_FILES "${PROJECT_SOURCE_DIR}/src" *.rs)
add_custom_target(${PROJECT_NAME}
		COMMAND cargo build --color=never ${CARGO_ARGUMENTS}
		COMMAND cargo build --color=never ${CARGO_ARGUMENTS} --release
		DEPENDS ${RUST_SOURCE_FILES}
		BYPRODUCTS target/debug/libkawaii.a target/release/libkawaii.a
		WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
		SOURCES ${RUST_SOURCE_FILES})