I'm looking at replacing a configure/make style build process with CMake. CMake performs well on the complicated stuff, but it is more verbose on simple things. For instance the GNU Make file:
hello: echo "hello world" >$@
In CMake it would be:
add_custom_command(OUTPUT hello COMMAND echo "hello world" > hello) add_custom_target(all ALL DEPENDS hello)
See also Adding a custom command with the file name as a target.
Which is actually more like:
hello: echo "hello world" >hello all: hello
With more complex builds the absence of automatic variables is very noticeable.
After much routing around (it seems to be hard to search for $@) I found:
Which suggests using wrapper functions and
which suggests using generator expressions that are close to automatic variables, but not close enough.
I have several related questions:
1a) Has CMake itself or best practice for doing this moved on since that question was asked?
1b) Is it likely CMake will ever provide an equivalent to automatic variables? If not, why not?
Individual problems are quite well covered on Stack Overflow and elsewhere on the Internet, but:
2a) Are there any good guides or cheat sheets to help with migrating from using GNU make directly.
2b) Are they any good best practice guides for CMake?
That is beyond the suggestions in Makefile equivalent in CMake. I am gradually evolving my own style, but I would like to avoid horseless carriage type mistakes and needless complexity.