[cmake-developers] [CMake 0014729]: Support "custom cmake generator"
Mantis Bug Tracker
mantis at public.kitware.com
Mon Feb 3 00:44:04 EST 2014
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=14729
======================================================================
Reported By: NAKAMURA Takumi
Assigned To:
======================================================================
Project: CMake
Issue ID: 14729
Category: CMake
Reproducibility: N/A
Severity: feature
Priority: normal
Status: new
======================================================================
Date Submitted: 2014-02-03 00:44 EST
Last Modified: 2014-02-03 00:44 EST
======================================================================
Summary: Support "custom cmake generator"
Description:
Experimentally I am writing "Custom generator". This is intended for auto
dependency scanner.
It doesn't work, at least with Ninja Generator.
As far as I see build.ninja, a few issues...
1) "ninja -t clean" removes foo.cmake.
It's Ninja's behavior. To avoid this, another rule should be added for
custom_command that touches generated cmakefiles (included by CMakeLists).
For example,
rule CUSTOM_GENERATOR
command = $COMMAND
description = $DESC
restat = 1
generator = 1
2) foo.cmake is added to phony target list, "A missing CMake input file is not
an error.", although foo.cmake has a rule.
Output of custom_command should be excluded from phony targets even if it were
included from CMakeLists.
3) Also generator-dependent file, for example foobar.c might be put into phony
list, or Ninja could not rebuild build.ninja when foobar.c were disappeared (in
revision walking).
Steps to Reproduce:
cmake_minimum_required(VERSION 2.8)
# It's supposed:
# - Scan dependent file(s).
# - Update when something happened. ;)
# For now, manually update tmpl.txt.
# "touch foobar.c" doesn't trigger regeneration.
# "echo >> tmpl.txt; touch foobar.c" triggers regeneration.
add_custom_command(OUTPUT foo.cmake
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/tmpl.txt
${CMAKE_CURRENT_BINARY_DIR}/foo.cmake
DEPENDS foobar.c
COMMENT "Updating foo.cmake"
)
add_custom_target(theGenerator DEPENDS foo.cmake)
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/tmpl.txt
${CMAKE_CURRENT_BINARY_DIR}/foo.cmake
)
include(${CMAKE_CURRENT_BINARY_DIR}/foo.cmake)
add_executable(foobar foobar.c)
# Almost all targets may depend on theGenerator.
add_dependencies(foobar theGenerator)
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-02-03 00:44 NAKAMURA TakumiNew Issue
======================================================================
More information about the cmake-developers
mailing list