[CMake] Ninja: Avoiding unnecessary rebuilds with generated files
Florian Weimer
fw at deneb.enyo.de
Sun May 5 08:16:59 EDT 2013
I've got a custom command which mangles a text file so that it can be
linked into the program:
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/schema.sql.inc
COMMAND xxd -i < ${PROJECT_SOURCE_DIR}/schema.sql > ${CMAKE_CURRENT_BINARY_DIR}/schema.sql.inc
DEPENDS schema.sql
)
The generated file is then referenced from a library:
add_library (SymbolDB
lib/symboldb/database.cpp
lib/symboldb/download.cpp
... (more *.cpp files)
${CMAKE_CURRENT_BINARY_DIR}/schema.sql.inc
)
Full CMakeLists.txt is here:
<https://github.com/fweimer/symboldb/blob/master/CMakeLists.txt>
With cmake 2.8.10, this triggers a rebuild of all the the *.cpp files
listed above when schema.sql changes. But only
lib/symboldb/database.cpp includes schema.sql.inc and therefore needs
rebuilding.
It seems that these unnecessary rebuilds only happen with the Ninja
generator. I don't see it with the make generator. Could this be a
bug in the Ninja generator?
More information about the CMake
mailing list