How to get errors from 'install' command?

I want to copy a directory tree full of web files. It sounds as simple as

install(DIRECTORY mydir/ DESTINATION dir/elsewhere)

but it just not create a directory, copy any files or give an error or warning. How do I get a failed result?

When do you want this copying to happen? If it’s at the time CMake is running, you want file(COPY), not install(). The commands install() create rules for installing the project, which happens later at build time, when you run make install (or equivalent for other generators).

1 Like

Also, when using install([FILES|DIRECTORY|TARGETS|etc.] ...), be aware that DESTINATION arguments are relative to the path specified in the CMAKE_INSTALL_PREFIX variable, not the current directory.


defaults to /usr/local on UNIX and c:/Program Files/${PROJECT_NAME} on Windows.