On 17.07.2017 17:13, Deniz Bahadir wrote:
Am 17.07.2017 um 16:47 schrieb Nils Gladitz:
On 7/17/2017 3:52 PM, Deniz Bahadir wrote:
This works just fine. However, now I want to add an additional
build-step after creation of the object-files and before linking the
shared library. (In particular, I want to compress the debug-symbols
in the object-files. But that should be irrelevant for my question.)
My first attempt was to add the following between the two
add_library commands:
```
add_custom_command( TARGET ${PROJECT_NAME}_OBJECTS POST_BUILD
COMMAND objcopy --compress-debug-sections
$<TARGET_OBJECTS:${PROJECT_NAME}_OBJECT>
)
```
But that results in the following error:
```
(add_custom_command):
Target "MyProject_OBJECTS" is an OBJECT library that may not
have PRE_BUILD, PRE_LINK, or POST_BUILD commands.
```
So I tried instead to add the following between the two add_library
commands:
```
add_custom_command( TARGET ${PROJECT_NAME} PRE_LINK
COMMAND objcopy --compress-debug-sections
$<TARGET_OBJECTS:${PROJECT_NAME}_OBJECT>
)
```
This then fails when evaluating the generator-expression:
```
(add_custom_command):
Error evaluating generator expression:
$<TARGET_OBJECTS:MyProject_OBJECTS>
The evaluation of the TARGET_OBJECTS generator expression is only
suitable
for consumption by CMake. It is not suitable for writing out
elsewhere.
```
So I am currently out of ideas (which do not make the CMakeLists.txt
file completely unmaintainable). Therefore my question is:
How can I retrieve the list of generated object-files so that I can
pass it to another program that should be run as additional
build-step before linking?
IMHO, the most comfortable (and syntactically cleanest) way would be
my first attempt. But that is probably more a feature-request than a
simple question.
FWIW this was implemented in the upcoming 3.9:
https://cmake.org/cmake/help/latest/module/CPackIFW.html#command:cpack_ifw_configure_component
Thank you for your answer, Nils, but I do not really see how this
relates.
This command seems to address CPack, while I am still struggling with
CMake building files (that later might be installed by CPack).
So sorry about that.
Must have gotten the wrong link in my clipboard.
The correct link is:
https://cmake.org/cmake/help/latest/release/3.9.html#other
Nils
--
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