Waschk,Kolja wrote: > Hi Brad, > >> You need the custom command to run every time the build starts: > ... >> copy-if-different check. The key is then to make the library depend >> on this rule at a *target* level, but only on version.h at a *file* >> level. > > Because such a custom target is "always considered out of date", the > library that depends on it is also considered out of date and would > be rebuilt,
That's why the key is to avoid the *file* level dependency. The *target* level dependency only determines the order in which the build system evaluates targets. Within each target the file-level dependencies are separately evaluated. This code: add_custom_target(update_version COMMAND echo updating) add_library(mylib version.c) add_dependencies(mylib update_version) causes "updating" to print every time you type "make", but it will build mylib only when sources change. It works in the VS IDE too. -Brad _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake