require 'kde-build/build_system/base' require 'kde-build/tools/make' module BuildTool module BuildSystem class CMakeConfiguration < BaseConfiguration option( 'options', "Command line options for cmake" ) option( 'cmake-prefix-path', "CMAKE_PREFIX_PATH environment variable" ) def initialize super self.name = "cmake" end end class CMake < BuildSystem::Base def initialize( mod ) super end def self.guess( path ) return File.exist? "#{path}/CMakeLists.txt" end def self.config CMakeConfiguration end # Execute a cmake command in the context of the build directory def cmake( command, wd = build_directory ) myenv = env myenv['CMAKE_PREFIX_PATH'] = cmake_prefix_path self.class.execute "cmake #{command}", wd, env end def cmake_prefix_path @configuration.cmake_prefix_path end def make( command = "", wd = build_directory ) BuildTool::Make.new.make "#{command}", wd end def build( target ) check_build_directory( true ) make target end def reconfigure( clean ) if clean return false if make( "clean" ) != 0 end return false if self.class.execute( "rm #{build_directory}/CMakeCache.txt" ) != 0 configure end def configure check_build_directory( true ) opt = options opt += " -DCMAKE_INSTALL_PREFIX=#{prefix}" if prefix rc = cmake "#{self.source_directory} #{opt}" rc end def configured? File.exist? "#{build_directory}/Makefile" end def info super puts " CMAKE_PREFIX_PATH: #{cmake_prefix_path}" end def name "CMake" end def options @configuration.options end Registry.register( 'CMake', CMake ) end end end