Files
chromebrew/lib/buildsystems/cmake.rb
Satadru Pramanik, DO, MPH, MEng 5b841f51f3 Adjust cmake buildsystem to run verbose tests when run_tests is enabled. (#10651)
Signed-off-by: Satadru Pramanik <satadru@gmail.com>
2024-10-22 15:32:40 -05:00

30 lines
1.2 KiB
Ruby

require 'package'
class CMake < Package
property :cmake_build_extras, :cmake_build_relative_dir, :cmake_install_extras, :cmake_options, :pre_cmake_options
def self.build
@cmake_build_relative_dir ||= '.'
@crew_cmake_options = @no_lto ? CREW_CMAKE_FNO_LTO_OPTIONS : CREW_CMAKE_OPTIONS
puts 'Additional cmake options being used:'.orange
method_list = methods.grep(/cmake_/).delete_if { |i| send(i).blank? }
method_list.each do |method|
puts "#{method}: #{send method}".orange
end
@mold_linker_prefix_cmd = CREW_LINKER == 'mold' ? 'mold -run' : ''
system "#{@pre_cmake_options} #{@mold_linker_prefix_cmd} cmake -S #{@cmake_build_relative_dir} -B #{@cmake_build_relative_dir}/builddir -G Ninja #{@crew_cmake_options} #{@cmake_options}"
system "#{CREW_NINJA} -C #{@cmake_build_relative_dir}/builddir"
@cmake_build_extras&.call
end
def self.install
system "DESTDIR=#{CREW_DEST_DIR} #{CREW_NINJA} -C #{@cmake_build_relative_dir}/builddir install"
@cmake_install_extras&.call
end
def self.check
puts "Testing with #{CREW_NINJA} test.".orange if @run_tests
system "ctest --test-dir #{@cmake_build_relative_dir}/builddir --rerun-failed --output-on-failure" if @run_tests
end
end