Class: BuildTool::BuildSystem::CMake
- Includes:
- MJ::Tools::SubProcess
- Defined in:
- lib/build-tool/build-system/cmake.rb
Direct Known Subclasses
Defined Under Namespace
Classes: CMakeError
Instance Attribute Summary
Attributes inherited from Base
#defaults, #feature, #module, #out_of_source
Instance Method Summary collapse
-
#cmake(command, wd = build_directory) ⇒ Object
Execute a cmake command in the context of the build directory.
- #configure ⇒ Object
-
#configured? ⇒ Boolean
Check if the module is configured.
-
#initialize(*args) ⇒ CMake
constructor
A new instance of CMake.
- #install(fast) ⇒ Object
- #install_fast_supported? ⇒ Boolean
- #make(target = nil) ⇒ Object
- #name ⇒ Object
- #option_string ⇒ Object
- #progressbar(title, &block) ⇒ Object
-
#reconfigure ⇒ Object
Configure the module.
Methods inherited from Base
#[], #[]=, #active?, #after_rebase, #append, #build_directory, #check_build_directory, #check_install_prefix, #dup, #env, #install_prefix, #option_hash, #option_names, #option_set?, #parent, #prepare_for_installation, #prepend, #recipe, #remove_build_directory, #remove_source_directory, #set, #source_directory, #to_s
Constructor Details
#initialize(*args) ⇒ CMake
Returns a new instance of CMake.
34 35 36 37 38 39 40 41 |
# File 'lib/build-tool/build-system/cmake.rb', line 34 def initialize( *args ) super( *args ) << 'CMAKE_BUILD_TYPE' << 'CMAKE_CXXFLAGS' << 'CMAKE_VERBOSE_MAKEFILE' << 'LIB_SUFFIX' end |
Instance Method Details
#cmake(command, wd = build_directory) ⇒ Object
Execute a cmake command in the context of the build directory
69 70 71 72 73 74 75 |
# File 'lib/build-tool/build-system/cmake.rb', line 69 def cmake( command, wd = build_directory ) rc = self.class.execute "cmake #{command}", wd, env if rc != 0 raise CMakeError, "cmake failed with error #{rc}!" end rc end |
#configure ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/build-tool/build-system/cmake.rb', line 77 def configure check_build_directory( true ) opt = option_string opt += " -DCMAKE_INSTALL_PREFIX=#{install_prefix.to_s}" if install_prefix rc = cmake "#{source_directory} #{opt}" rc end |
#configured? ⇒ Boolean
Check if the module is configured
48 49 50 |
# File 'lib/build-tool/build-system/cmake.rb', line 48 def configured? Pathname.new( build_directory ).join( 'Makefile' ).exist? end |
#install(fast) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/build-tool/build-system/cmake.rb', line 85 def install( fast ) if fast make( "install/fast" ) else make( "install" ) end end |
#install_fast_supported? ⇒ Boolean
93 94 95 |
# File 'lib/build-tool/build-system/cmake.rb', line 93 def install_fast_supported? true end |
#make(target = nil) ⇒ Object
97 98 99 |
# File 'lib/build-tool/build-system/cmake.rb', line 97 def make( target = nil ) Make.make( "#{target ? target : "" }", build_directory, self.module.environment.values ) end |
#name ⇒ Object
52 53 54 |
# File 'lib/build-tool/build-system/cmake.rb', line 52 def name "cmake" end |
#option_string ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/build-tool/build-system/cmake.rb', line 101 def option_string arr = [] option_names.each do |var| val = self[var] if var.start_with? 'D' arr << "-#{var}='#{val}'" else arr << "-#{var}'#{val}'" end end arr.join(" ") end |
#progressbar(title, &block) ⇒ Object
114 115 116 117 118 |
# File 'lib/build-tool/build-system/cmake.rb', line 114 def ( title, &block ) .new( title ) do yield end end |
#reconfigure ⇒ Object
Configure the module
61 62 63 64 65 66 |
# File 'lib/build-tool/build-system/cmake.rb', line 61 def reconfigure() if File.exist?( "#{build_directory}/CMakeCache.txt" ) return false if self.class.execute( "rm -f #{build_directory}/CMakeCache.txt" ) != 0 end configure end |