0

How can I refer inside a CMake file the install target?

For example I want to do something like

add_custom_target(my-target DEPENDS install COMMAND my-target-command)

If I call

cmake --build . --target help

from CMAKE_CURRENT_BINARY_DIR, in the returned list I can see there is target install.

Trying to

make my-target

with "Unix Makefiles" as generator results in an error

make[2]: *** No rule to make target `CMakeFiles/install.dir/all', needed by `CMakeFiles/my-target.dir/all'.  Stop.
Sogartar
  • 2,035
  • 2
  • 19
  • 35
  • As far as I know, you cannot refer to **install** target within `CMakeLists.txt`, it is internal for CMake. If you want to add actions to performed at *install stage*, use `install(CODE)` or `install(SCRIPT)` flows of [install() command](https://cmake.org/cmake/help/v3.0/command/install.html). – Tsyvarev Sep 19 '16 at 09:31
  • 1
    Possible duplicate of [Postpone making custom target until install](http://stackoverflow.com/questions/8636479/postpone-making-custom-target-until-install) – arrowd Sep 19 '16 at 13:20

0 Answers0