Class: GTest

Inherits:
CKick::Plugin show all
Defined in:
lib/ckick/plugin/gtest.rb

Constant Summary collapse

LIBS_VARIABLE =
"${GTEST_LIBRARIES}"

Instance Method Summary collapse

Methods inherited from CKick::Plugin

#lib, #name, #run, #to_hash

Constructor Details

#initialize(args = {}) ⇒ GTest

Returns a new instance of GTest.



11
12
13
14
# File 'lib/ckick/plugin/gtest.rb', line 11

def initialize args={}
  @optional = args[:optional] || false
  @resource_file = "build-gtest.cmake"
end

Instance Method Details

#call(project) ⇒ Object



27
28
29
30
31
# File 'lib/ckick/plugin/gtest.rb', line 27

def call(project)
  file = File.new(File.join(project.root, @resource_file), 'w')
  file << File.new(File.join(File.dirname(__FILE__), "resource", @resource_file), 'r').read
  file.close
end

#cmakeObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/ckick/plugin/gtest.rb', line 16

def cmake
  res = ''
  res << %Q(option(BUILD_TESTS OFF "whether to build tests or not")\n) \
      << "if(BUILD_TESTS)\n\t" if @optional

  res << "include(#{@resource_file})"

  res << "\nendif()" if @optional
  res
end

#include(project) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ckick/plugin/gtest.rb', line 33

def include(project)
  res = []
  [
    File.join(project.build_dir, "gtest", "src", "libgtest", "googletest", "include"),
    File.join(project.build_dir, "gtest", "src", "libgtest", "googlemock", "include")
  ].each do |path|
    FileUtils.mkdir_p path
    res << CKick::IncludePath.new(path: path)
  end
  res
end