Class: Ritsu::SrcFiles::TargetCmakeLists::QtMocTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/ritsu/ext/qt/src_files/target_cmake_lists.rb

Instance Attribute Summary collapse

Attributes included from BlockMixin

#contents, #id, #indent_length, #indent_level, #local_indentation

Instance Method Summary collapse

Methods inherited from Template

#add_content, #add_template, #child_template_with_id, #child_template_with_id_position, #child_templates, #create_block

Methods included from BlockMixin

#add_line, #add_new_line, #block_structure?, #clear_contents, #indent, #initialize_block_mixin, #outdent

Constructor Details

#initialize(target) ⇒ QtMocTemplate

Returns a new instance of QtMocTemplate.



44
45
46
47
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 44

def initialize(target)
  super("TargetCmakeLists -- #{target.name} -- QtMoc")
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



42
43
44
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 42

def target
  @target
end

Instance Method Details

#moc_src_files_var_nameObject



49
50
51
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 49

def moc_src_files_var_name
  "#{target.name.upcase}_MOC_SRC_FILES"
end

#update_block(block, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ritsu/ext/qt/src_files/target_cmake_lists.rb', line 53

def update_block(block, options = {})
  block.clear_contents
  
  header_files = target.src_files.select { |x| x.respond_to?(:qt_header_file?) && x.qt_header_file? }
  if header_files.length == 0
    return
  end
  header_files.sort! {|x,y| x.src_path <=> y.src_path}
  
  block.add_line "QT4_WRAP_CPP(#{moc_src_files_var_name}"
  block.indent
  header_files.each do |header_file|
    block.add_line("${CMAKE_SOURCE_DIR}/#{header_file.src_path}")
  end
  block.outdent
  block.add_line ")"
  block.add_new_line
  block.add_line "SET(#{target.name.upcase}_SRC_FILES ${#{target.name.upcase}_SRC_FILES} ${#{moc_src_files_var_name}})"
end