Class: CKick::Library

Inherits:
Target
  • Object
show all
Defined in:
lib/ckick/library.rb

Overview

represents an library target (in respect to CMake add_library() command)

Instance Method Summary collapse

Methods inherited from Target

#create_structure, #paths, #to_s

Methods included from Hashable

#to_no_empty_value_hash

Constructor Details

#initialize(args = {}) ⇒ Library

  • args - Target hash (directly a CKickfile library target element’s hash parsed with keys as Symbol), must be a Hash

CKick::Library specific input hash keys (in addition of CKick::Target ones)
  • :shared - whether or not this library should be a dynamic library (shared object) or a static library (archive)



15
16
17
18
19
# File 'lib/ckick/library.rb', line 15

def initialize args={}
  super args

  @shared = args[:shared] || false
end

Instance Method Details

#cmakeObject

CMakeLists content of the target



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ckick/library.rb', line 31

def cmake
  res = []

  res << "add_library(#{@name}#{@shared ? " SHARED " : " "}#{@source.join(' ')})"

  unless @libs.empty?
    res << "target_link_libraries(#{@name} #{@libs.join(' ')})"
  end

  res.join("\n")
end

#to_hashObject

converts to Hash (for CKickfile)



22
23
24
25
26
27
28
# File 'lib/ckick/library.rb', line 22

def to_hash
  if @shared
    return super
  else
    return super.without(:shared)
  end
end