[CMake] Copying files and including them in a CPack archive
Chris Wood
c.c.wood at gmail.com
Fri Jul 12 13:20:25 EDT 2013
install(DIRECTORY...) fixed it - thanks very much - I hadn't spotted
that in the documentation.
Chris
On 6 July 2013 18:45, Eric Noulard <eric.noulard at gmail.com> wrote:
> 2013/7/6 Chris Wood <c.c.wood at gmail.com>:
>> So, there are numerous ways to copy files (and directories) at CMake
>> runtime (file(COPY ...), configure_file(...) and add_custom_command()
>> all work*), but I haven't yet found out how to make a file or
>> directory copied from the source to build directory appear in an
>> archive generated by CPack. I thought that this Stack Overflow answer
>> [1] would fix it, as it actually links the copying to a target which
>> will then have an install linked to it:
>>
>> install(TARGET mytarget DESTINATION bin)
>>
>> whereas I did recognise that the file() and configure_file() commands
>> don't have an obvious way to be added to a target. But, this didn't
>> work. So, given a simple CMakeLists.txt, such as the one below, how do
>> I make all of the files (including the exmaple directory) appear in
>> the archive?!
>
> Did you try something like:
>
> install(DIRECTORY ${PROJECT_SOURCE_DIR}/examplefiles DESTINATION share
> PATTERN "CVS" EXCLUDE)
>
> this will install the directory either with CPack or if you build the
> "install" target.
>
> Another to make it appear only for CPack is to use CPACK_INSTALLED_DIRECTORIES
> set(CPACK_INSTALLED_DIRECTORIES
> "${PROJECT_SOURCE_DIR}/examplefiles;examplefiles")
>
>
>
>>
>> cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
>> enable_language(FORTRAN)
>> add_executable(mytarget ${PROJECT_SOURCE_DIR}/myprog.for)
>> install(TARGETS mytarget DESTINATION bin)
>>
>> add_custom_command(TARGET mytarget PREBUILD
>> COMMAND ${CMAKE_COMMAND} -E copy_directory
>> ${PROJECT_SOURCE_DIR}/examplefiles
>> ${PROJECT_BINARY_DIR}/examplefiles)
>>
>> set(CPACK_GENERATOR "TGZ")
>> include(CPack)
>>
>> * I haven't yet found out which one of these 3 methods is actually
>> (most?) correct - so any advice on this too will be hugely appreciated
>>
>> [1]: http://stackoverflow.com/a/10672739/889604
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>
>
>
> --
> Erk
> L'élection n'est pas la démocratie -- http://www.le-message.org
More information about the CMake
mailing list