Class: MxxRu::Cpp::ExtCMakeProjectTarget

Inherits:
CompositeTarget show all
Defined in:
lib/mxx_ru/cpp/ext_cmake_project.rb

Overview

External CMake project.

Since v.1.6.11

Defined Under Namespace

Classes: BuildingContext

Constant Summary

Constants inherited from Target

Target::Global_obj_placement_info, Target::OPT_LOCAL, Target::OPT_UPSPREAD

Instance Attribute Summary

Attributes inherited from Target

#mxx_c_files, #mxx_cpp_files, #mxx_encoding, #mxx_implib_path, #mxx_mswin_rc_file, #mxx_mswin_res_file, #mxx_obj_files, #mxx_optimization, #mxx_screen_mode, #mxx_sources_root, #mxx_target_ext, #mxx_target_name, #mxx_target_prefix, #mxx_target_root, #vc8_actual_manifest

Attributes inherited from AbstractTarget

#mxx_full_targets_names, #mxx_generators, #mxx_required_prjs

Instance Method Summary collapse

Methods inherited from CompositeTarget

#reset

Methods inherited from Target

#c_source, #cpp_source, #create_full_result_target_file_name, #create_full_src_file_name, #create_full_target_file_name, define_spreadable_option_methods, #global_obj_placement, global_option_methods, #implib_path, initialize_spreadable_option_instance_variables, #mswin_rc_file, #mswin_res_file, #mxx_obj_placement, #mxx_runtime_mode, #obj_file, #obj_placement, #optimization, #reset, #screen_mode, #source_encoding, #sources_root, #target, #target_ext, #target_prefix, #target_root, #toolset, #vc8_source_manifest, #vc8_source_manifest=

Methods inherited from BinaryTarget

check_libraries_types, #lib, #lib_shared, #lib_static, #mxx_add_required_lib, #mxx_add_required_lib_path, #mxx_required_lib_paths, #mxx_required_libs

Methods inherited from AbstractTarget

define_plural_form_method, #generator, #mxx_add_full_target_name, #prj_alias, #required_prj, #reset, run

Constructor Details

#initialize(a_alias, &block) ⇒ ExtCMakeProjectTarget

Returns a new instance of ExtCMakeProjectTarget.



71
72
73
74
75
76
77
78
79
80
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 71

def initialize( a_alias, &block )
  @mxx_cmake_defs = {}
  @mxx_includedir_subfolders = []

  super( a_alias )

  if @mxx_cmakelists_location.nil?
    raise CMakeProjectLocationNotDefined.new( a_alias )
  end
end

Instance Method Details

#buildObject



204
205
206
207
208
209
210
211
212
213
214
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 204

def build
  if nil == @mxx_last_build_result
    super

    # Actual result must be set only after CMake-related build steps.
    @mxx_last_build_result = nil
    @mxx_last_build_result = do_cmake_specific_build
  end

  @mxx_last_build_result
end

#build_dir_name(name) ⇒ Object

Set the name of folder in which cmake-controlled build will be performed. If this name is not specified then name of that folder will be generated automatically (it will be based on toolset name and build mode).

Note: this folder is always created in location defined by obj_placement. Because of that is cannot be absolute path.



125
126
127
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 125

def build_dir_name( name )
  @mxx_cmake_build_dir_name = name
end

#cleanObject



216
217
218
219
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 216

def clean
  do_cmake_specific_clean
  super
end

#includedir_subfolder(name) ⇒ Object

Set a name of includedir subfolder to be added to include path of all dependent targets.

Sometimes a project can have several subfolder in its include directory. Something like that:

some_project
`- include/
   `- subfolder1/
   `- subfolder2/
   `- subfolder3

When cmake install will be performed all these subfolders will be installed into install_includedir. But only install_includedir will be added to include path. It means that header files from these subfolders must be included as:

#include <subfolder1/first_header.hpp>
#include <subfolder2/second_header.hpp>
...

It could be inappropriate. In that case includedir_subfolder can be used:

MxxRu::Cpp::ext_cmake_project {
  where 'soci'

  install_includedir 'soci_headers'
  includedir_subfolder 'soci'
  includedir_subfolder 'soci/postgresql'
  ...
}


179
180
181
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 179

def includedir_subfolder( name )
  @mxx_includedir_subfolders << name
end

#includedir_subfolders(*names) ⇒ Object

Same as includedir_subfolder but allow to specify several folder names at once.

For example:

MxxRu::Cpp::ext_cmake_project {
  where 'soci'

  install_includedir 'soci_headers'
  includedir_subfolders 'soci', 'soci/postgresql'
  ...
}


196
197
198
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 196

def includedir_subfolders( *names )
  @mxx_includedir_subfolders.push( *names )
end

#install_includedir(dir) ⇒ Object

Set name of folder for header files.

This name will be passed to cmake command via -DINCLUDEDIR option.

Usage example:

MxxRu::Cpp::ext_cmake_project {
  where 'soci'

  install_includedir 'soci_headers'
  ...
}


142
143
144
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 142

def install_includedir( dir )
  @mxx_cmake_install_includedir = dir
end

#target_typeObject



200
201
202
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 200

def target_type
  return ExtCMakeProjectTargetType.new
end

#where(location) ⇒ Object

Set the location of external project’s CMakeLists.txt file.

This is mandatory parameter.

NOTE. location must be a relative path.

Usage example:

MxxRu::Cpp::ext_cmake_project {
  where 'soci' # It means that 'soci' must be subfolder of
               # the prject's root folder.
  ...
}


96
97
98
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 96

def where( location )
  @mxx_cmakelists_location = location
end

#with(options) ⇒ Object

Set values to be passes to cmake commands via -D option.

Usage example:

MxxRu::Cpp::ext_cmake_project {
  where 'soci'

  with WITH_BOOST: :ON, WITH_ORACLE: :OFF
  with :SOCI_EMPTY => 'OFF'
  with :SOCI_SHARED => 'ON', :SOCI_STATIC => 'OFF'
  with SOCI_TESTS: :OFF
}


113
114
115
# File 'lib/mxx_ru/cpp/ext_cmake_project.rb', line 113

def with( options )
  @mxx_cmake_defs.merge!( options )
end