lib/autobuild/packages/cmake.rb in autobuild-1.9.2 vs lib/autobuild/packages/cmake.rb in autobuild-1.9.3.b1

- old
+ new

@@ -26,17 +26,28 @@ # if the generator creates makefiles # # It can be overriden on a per-package basis with CMake.generator= attr_accessor :generator + attr_reader :prefix_path attr_reader :module_path end + @prefix_path = [] @module_path = [] @full_reconfigures = true # a key => value association of defines for CMake attr_reader :defines + # The list of all -D options that should be passed on to CMake + def all_defines + additional_defines = Hash[ + "CMAKE_INSTALL_PREFIX" => prefix, + "CMAKE_MODULE_PATH" => module_path.join(";"), + "CMAKE_PREFIX_PATH" => prefix_path.join(";")] + self.class.defines.merge(additional_defines).merge(defines) + end + # If true, always run cmake before make during the build attr_accessor :always_reconfigure # If true, we always remove the CMake cache before reconfiguring. # # See #full_reconfigures? for more details @@ -277,10 +288,29 @@ file = File.basename(file, ".pc.in") provides "pkgconfig/#{file}" end end + def module_path + CMake.module_path + end + + def prefix_path + seen = Set.new + result = Array.new + + raw = (dependencies.map { |pkg_name| Autobuild::Package[pkg_name].prefix } + + CMake.prefix_path) + raw.each do |path| + if !seen.include?(path) + seen << path + result << path + end + end + result + end + def prepare # A failed initial CMake configuration leaves a CMakeCache.txt file, # but no Makefile. # # Delete the CMakeCache to force reconfiguration @@ -289,13 +319,11 @@ end doc_utility.source_ref_dir = builddir if File.exist?(cmake_cache) - all_defines = self.class.defines.merge(defines) - all_defines['CMAKE_INSTALL_PREFIX'] = prefix - all_defines['CMAKE_MODULE_PATH'] = "#{CMake.module_path.join(";")}" + all_defines = self.all_defines cache = File.read(cmake_cache) did_change = all_defines.any? do |name, value| cache_line = cache.each_line.find do |line| line =~ /^#{name}:/ end @@ -332,17 +360,17 @@ in_dir(builddir) do if !File.file?(File.join(srcdir, 'CMakeLists.txt')) raise ConfigException.new(self, 'configure'), "#{srcdir} contains no CMakeLists.txt file" end - command = [ "cmake", "-DCMAKE_INSTALL_PREFIX=#{prefix}", "-DCMAKE_MODULE_PATH=#{CMake.module_path.join(";")}" ] + command = [ "cmake" ] if Autobuild.windows? command << '-G' command << "MSYS Makefiles" end - - self.class.defines.merge(defines).each do |name, value| + + all_defines.each do |name, value| command << "-D#{name}=#{value}" end if generator command << "-G#{generator}" end