lib/autobuild/packages/cmake.rb in autobuild-1.4.9 vs lib/autobuild/packages/cmake.rb in autobuild-1.5.0

- old
+ new

@@ -98,23 +98,24 @@ provides "pkgconfig/#{file}" end end def prepare - super - - all_defines = defines.dup - all_defines['CMAKE_INSTALL_PREFIX'] = prefix - + # A failed initial CMake configuration leaves a CMakeCache.txt file, + # but no Makefile. + # + # Delete the CMakeCache to force reconfiguration if !File.exists?( File.join(builddir, 'Makefile') ) FileUtils.rm_f configurestamp end if File.exists?(configurestamp) + all_defines = defines.dup + all_defines['CMAKE_INSTALL_PREFIX'] = prefix cache = File.read(configurestamp) did_change = all_defines.any? do |name, value| - cache_line = cache.find do |line| + cache_line = cache.each_line.find do |line| line =~ /^#{name}:/ end value = value.to_s old_value = cache_line.split("=")[1].chomp if cache_line @@ -131,32 +132,30 @@ puts "CMake configuration changed, forcing a reconfigure" end FileUtils.rm_f configurestamp end end + + super end # Configure the builddir directory before starting make def configure - if File.exists?(builddir) && !File.directory?(builddir) - raise ConfigException, "#{builddir} already exists but is not a directory" - end - - FileUtils.mkdir_p builddir if !File.directory?(builddir) - Dir.chdir(builddir) do - command = [ "cmake", "-DCMAKE_INSTALL_PREFIX=#{prefix}" ] - defines.each do |name, value| - command << "-D#{name}=#{value}" + super do + Dir.chdir(builddir) do + command = [ "cmake", "-DCMAKE_INSTALL_PREFIX=#{prefix}" ] + defines.each do |name, value| + command << "-D#{name}=#{value}" + end + command << srcdir + + progress "generating and configuring build system for %s" + if full_reconfigures? + FileUtils.rm_f configurestamp + end + Subprocess.run(self, 'configure', *command) end - command << srcdir - - progress "generating and configuring build system for %s" - if full_reconfigures? - FileUtils.rm_f configurestamp - end - Subprocess.run(self, 'configure', *command) - super end end # Do the build in builddir def build @@ -177,10 +176,9 @@ # Install the result in prefix def install Dir.chdir(builddir) do progress "installing %s" Subprocess.run(self, 'build', Autobuild.tool(:make), "-j#{parallel_build_level}", 'install') - Autobuild.update_environment prefix end super end end end