class MiniPortileCMake

Public Class Methods

new(name, version, **kwargs) click to toggle source
Calls superclass method MiniPortile::new
# File lib/mini_portile2/mini_portile_cmake.rb, line 9
def initialize(name, version, **kwargs)
  super(name, version, **kwargs)
  @cmake_command = kwargs[:cmake_command]
end

Public Instance Methods

cmake_cmd() click to toggle source
# File lib/mini_portile2/mini_portile_cmake.rb, line 49
def cmake_cmd
  (ENV["CMAKE"] || @cmake_command || "cmake").dup
end
configure() click to toggle source
# File lib/mini_portile2/mini_portile_cmake.rb, line 24
def configure
  return if configured?

  cache_file = File.join(tmp_path, 'configure.options_cache')
  File.open(cache_file, "w") { |f| f.write computed_options.to_s }

  execute('configure', [cmake_cmd] + computed_options + ["."])
end
configure_defaults() click to toggle source
# File lib/mini_portile2/mini_portile_cmake.rb, line 14
def configure_defaults
  if MiniPortile.mswin? && generator_available?('NMake')
    ['-G', 'NMake Makefiles']
  elsif MiniPortile.mingw? && generator_available?('MSYS')
    ['-G', 'MSYS Makefiles']
  else
    []
  end
end
configure_prefix() click to toggle source
# File lib/mini_portile2/mini_portile_cmake.rb, line 5
def configure_prefix
  "-DCMAKE_INSTALL_PREFIX=#{File.expand_path(port_path)}"
end
configured?() click to toggle source
# File lib/mini_portile2/mini_portile_cmake.rb, line 33
def configured?
  configure = File.join(work_path, 'configure')
  makefile  = File.join(work_path, 'CMakefile')
  cache_file  = File.join(tmp_path, 'configure.options_cache')

  stored_options  = File.exist?(cache_file) ? File.read(cache_file) : ""
  current_options = computed_options.to_s

  (current_options == stored_options) && newer?(makefile, configure)
end
make_cmd() click to toggle source
Calls superclass method MiniPortile#make_cmd
# File lib/mini_portile2/mini_portile_cmake.rb, line 44
def make_cmd
  return "nmake" if MiniPortile.mswin?
  super
end

Private Instance Methods

generator_available?(generator_type) click to toggle source
# File lib/mini_portile2/mini_portile_cmake.rb, line 55
def generator_available?(generator_type)
  stdout_str, status = Open3.capture2("#{cmake_cmd} --help")

  raise 'Unable to determine whether CMake supports #{generator_type} Makefile generator' unless status.success?

  stdout_str.include?("#{generator_type} Makefiles")
end