1

I am using CMake with Unix Makefile generator. When I use add_custom_target it generates the make target only in the CMAKE_CURRENT_BINARY_DIR and the CMAKE_BINARY_DIR.
I found it out by testing it with different layouts of sub-directories.

Is this somewhere documented? Is there a way to create a custom target that works in every target, similar to built-in make clean?

The rationale behind the question: I have a bunch of unit tests in several unittest folders. I don't build them with target all as compiling the tests takes much longer compared to the actual library. With the target unittest I can build them. I would like to be able to call this from every unittest subfolder. Preferably it would only build the unit tests located in the current directory and recursively in its sub-directories.

usr1234567
  • 21,601
  • 16
  • 108
  • 128
  • I am not clearly undestand what you want: `add_custom_command` is used for create files in the current (binary) dir, for create global targets `add_custom_target` should be used. – Tsyvarev Nov 03 '15 at 17:12
  • @Tsyvarev I mixed the two terms up, I only wanted to talk about `add_custom_command` – usr1234567 Nov 04 '15 at 07:15
  • @usr1234567 I've seen you already came across [add_custom_command is not generating a target](http://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target). Can you please describe a little more your use case? E.g. do you want a post build step command for all your executables? – Florian Nov 07 '15 at 19:27
  • @Florian: I added this to my question. Thanks for sharing the link, espescially your answer seems related. I dislike the workaround as it seems to work against CMake. I am hoping CMake has a more natural behavior for Makefiles. – usr1234567 Nov 09 '15 at 06:31

0 Answers0