class Moc < Rscons::Builder def run(target, sources, cache, env, vars) command = %W[moc -o #{target} #{sources.first}] standard_build("Moc #{target}", target, command, sources, env, cache) end end Rscons::Environment.new do |env| env.add_builder(Moc.new) sources = Dir["src/*.cc"] env.build_dir("src", "build") Dir["src/**/*.h"].each do |h_file| moc_fname = env.get_build_fname(h_file, "_moc.cc") env.Moc(moc_fname, h_file) sources << moc_fname end env.parse_flags!("!pkg-config --cflags --libs Qt5Core Qt5Gui Qt5Widgets") env.parse_flags!("-fPIE") env.Program("app", sources) end