Skip to content

Instantly share code, notes, and snippets.

@tibaes
Last active September 16, 2015 21:23
Show Gist options
  • Save tibaes/0d9077e509b8309c35e0 to your computer and use it in GitHub Desktop.
Save tibaes/0d9077e509b8309c35e0 to your computer and use it in GitHub Desktop.
OpenCV Rakefile
require 'rake'
require 'rake/clean'
targetname = "a.out"
cc = "g++ -Wall -Wno-overloaded-virtual -std=c++11 -O2"
paths = "/usr/local/opt/opencv3/lib/pkgconfig/opencv.pc"
libs = `#{"pkg-config --libs " + paths}`
flags = `#{"pkg-config --cflags " + paths}`
sourcefiles = Rake::FileList["**/*.cpp"]
task :default => 'build:all'
namespace :build do
multitask :obj => sourcefiles.ext(".o")
task :target do
sh "#{cc} -o #{targetname} #{sourcefiles.ext(".o")} #{libs}"
CLEAN.include(sourcefiles.ext(".o"))
end
task :all => [:obj, :target]
end
rule ".o" => ".cpp" do |t|
sh "#{cc} #{t.source} -c -o #{t.name} #{flags}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment