use cmake_file_api::{objects, query, reply};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let source_dir = std::path::Path::new(".");
let build_dir = std::path::Path::new(".");
query::Writer::default()
.request_object::<objects::CodeModelV2>()
.write_stateless(build_dir)?;
assert!(std::process::Command::new("cmake")
.arg("-S")
.arg(source_dir)
.arg("-B")
.arg(build_dir)
.status()?
.success());
let reader = reply::Reader::from_build_dir(build_dir)?;
let codemodel: objects::CodeModelV2 = reader.read_object()?;
codemodel.configurations.iter().for_each(|config| {
config.targets.iter().for_each(|target| {
println!("{}", target.name);
println!("{:#?}", target.sources);
});
});
Ok(())
}