require "mkmf-rice" cmake_path = %x{which cmake}.chomp raise "cmake required" unless $?.success? && !cmake_path.empty? inkcpp_dir = File.join(File.dirname(File.realpath(__FILE__)), "inkcpp") build_dir = File.join(inkcpp_dir, "build") dist_dir = File.join(build_dir, "dist") FileUtils.mkdir_p(dist_dir) FileUtils.mkdir_p(build_dir) succeed = system(%Q{cd #{build_dir} && cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=#{dist_dir} .. && cmake --build . --config Release && cmake --install . --component lib}, out: STDOUT) raise "cmake failed" unless succeed inkcpp_lib_dir = File.join(dist_dir, "lib", "ink") inkcpp_include_dir = File.join(dist_dir, "include") $CXXFLAGS += %Q{ -I#{inkcpp_include_dir}} $LDFLAGS += %Q{ -L#{inkcpp_lib_dir} -linkcpp -linkcpp_compiler} create_makefile "inkcpp_rb/inkcpp_rb"