[CMake] Install target is not called

Eric Noulard eric.noulard at gmail.com
Tue Feb 17 02:52:22 EST 2009

2009/2/17 Pavel Shevaev <pacha.shevaev at gmail.com>:
> Folks, what can be the reason for install target not to be called? I
> have something like this in my CMakeLists.txt:
>  add_executable(foo src1 src2 src3)
>  target_link_libraries(foo ${libs})
>  install(PROGRAMS ${foo_BINARY_DIR}/foo
>           DESTINATION ${foo_SOURCE_DIR}/bin
>          )

If your binary to install is a CMake target (like in your example)
you should use:

install(targets foo
            RUNTIME DESTINATION  ${foo_SOURCE_DIR}/bin)

moreover installing in ${foo_SOURCE_DIR} is a bit strange,
if you want to collect all your compiled executable in
a "bin" directory of the source tree then you may
try to use


if you do


after calling make, all your executable will end up in

finally you usually don't want to put compiled executable in the SOURCE tree
but in the BUILD tree. So one usually do:


More information about the CMake mailing list