Copying target output file to another directory

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Copying target output file to another directory

Robert Dailey-2
So I need to copy the output *.so from a target to an arbitrary
directory outside the CMAKE_BINARY_DIR. I tried doing this as a post
build event using generator expressions:

add_custom_command(
    TARGET ${target} POST_BUILD VERBATIM
    COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${target}>" ${dir}
)

This fails because I'm running it outside of the directory where
${target} is defined:

CMake Error at Core/CMake/third-party.cmake:86 (add_custom_command):
  TARGET 'MagickCore' was not created in this directory.


How can I do this without moving my add_custom_command() to the same
directory that created the target? I need to add all the custom
commands at the end of generation because it depends on certain global
properties which are not completely done being set until the very end.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copying target output file to another directory

Robert Maynard
Question: Is there a specific reason why you don't want to do this as
part of the install step?

If this can't be done at install time, you can look at using
add_custom_command Generating File signature with a target dependency
on ${target}

On Tue, Jul 18, 2017 at 10:44 AM, Robert Dailey
<[hidden email]> wrote:

> So I need to copy the output *.so from a target to an arbitrary
> directory outside the CMAKE_BINARY_DIR. I tried doing this as a post
> build event using generator expressions:
>
> add_custom_command(
>     TARGET ${target} POST_BUILD VERBATIM
>     COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${target}>" ${dir}
> )
>
> This fails because I'm running it outside of the directory where
> ${target} is defined:
>
> CMake Error at Core/CMake/third-party.cmake:86 (add_custom_command):
>   TARGET 'MagickCore' was not created in this directory.
>
>
> How can I do this without moving my add_custom_command() to the same
> directory that created the target? I need to add all the custom
> commands at the end of generation because it depends on certain global
> properties which are not completely done being set until the very end.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copying target output file to another directory

Robert Dailey-2
This is part of a lot of complex logic to integrate ANT into CMake as
transparently as possible to assist in integrating Android support
(building Java and APK). So I do not use INSTALL targets. This is an
implementation detail since the libs are required in a specific
directory so that ANT can package them into the APK for distribution
to Android devices.

On Tue, Jul 18, 2017 at 10:54 AM, Robert Maynard
<[hidden email]> wrote:

> Question: Is there a specific reason why you don't want to do this as
> part of the install step?
>
> If this can't be done at install time, you can look at using
> add_custom_command Generating File signature with a target dependency
> on ${target}
>
> On Tue, Jul 18, 2017 at 10:44 AM, Robert Dailey
> <[hidden email]> wrote:
>> So I need to copy the output *.so from a target to an arbitrary
>> directory outside the CMAKE_BINARY_DIR. I tried doing this as a post
>> build event using generator expressions:
>>
>> add_custom_command(
>>     TARGET ${target} POST_BUILD VERBATIM
>>     COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${target}>" ${dir}
>> )
>>
>> This fails because I'm running it outside of the directory where
>> ${target} is defined:
>>
>> CMake Error at Core/CMake/third-party.cmake:86 (add_custom_command):
>>   TARGET 'MagickCore' was not created in this directory.
>>
>>
>> How can I do this without moving my add_custom_command() to the same
>> directory that created the target? I need to add all the custom
>> commands at the end of generation because it depends on certain global
>> properties which are not completely done being set until the very end.
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...