As explained in the documentation of the CPack module, the binary installers created by CPack contain everything installed via CMake's INSTALL
command. Thus the executable mytarget
in your example will be included in the CPack archive, because you use the install
command to copy it to the bin
folder.
To also have CPack include the example
folder in the generated archive, you can use the DIRECTORY
variant of the install command in the following way:
install(DIRECTORY "${PROJECT_SOURCE_DIR}/examplefiles/" DESTINATION "example")
The file(COPY ...)
and configure_file(...)
do not have an effect on what is installed by CPack. Both command are usually used to copy files from the source tree to the binary tree upon configuring the CMake project.
Using add_custom_command
with ${CMAKE_COMMAND} -E copy_directory ...
will postpone the actual copying of files to the build time of the project. It will however not trigger the inclusion of the copied files in the CPack archive, either.