[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

CMAKE_RUNTIME_OUTPUT_DIRECTORY

if you do

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)

after calling make, all your executable will end up in
${PROJECT_SOURCE_DIR}/bin

finally you usually don't want to put compiled executable in the SOURCE tree
but in the BUILD tree. So one usually do:
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)


-- 
Erk


More information about the CMake mailing list