Re: [CMake] extending CMAKE__LINK_EXECUTABLE

2019-10-08 Thread Fred Baksik

On Tue, Oct 8, 2019, at 9:08 AM, Setzer Sebastian (CM-CI2/ECS2) via CMake wrote:
> Dear list,

> I need to run a tool after building an executable, which will modify the 
> executable itself.

> I intend to extend the toolchain for this, because it shall be done for every 
> executable on this particular operating system.

> 

> I think for this purpose, I need to change the rule 
> CMAKE__LINK_EXECUTABLE.

> And I think I can’t put multiple commands into that rule, so I need to write 
> a wrapper which will be called instead of the normal linker, and the calls 
> the normal linker and then that special tool.

> 

> Right, so far?

> 

> Now I’d like to pass a few additional parameters to this tool, which I’d like 
> to get from a special target property.

> 

> The rule currently looks like this:

> set(CMAKE_C_LINK_EXECUTABLE "   
>   -o  ")

> 

> And I wonder what these placeholders in angle brackets mean, and if there are 
> more placeholders available. The manual doesn’t say anything about this, 
> unfortunately:

> https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_LINK_EXECUTABLE.html

> 

> Is there, for example, a way to access arbitrary target properties?

> Or do I need to hide my special parameters somewhere in the LINK_OPTIONS 
> property?

> 

> Regards,

> Sebastian

> -- 
> 

I don't see how running arbitrary commands is possible in this way.

If you want to avoid the boilerplate of adding a post-build custom command use 
a macro that performs the add_executable() and add_custom_command(). Then use 
the macro for each of the executable.

Those markers aren't specified because it is part of implementation details of 
the Makefile (and Ninja?) generator and these items tend not to be documented 
for that reason (at least that is what I have come to understand from comments 
made on gitlab and developers mailing list).

--
Fred-- 

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:
https://cmake.org/mailman/listinfo/cmake


[CMake] extending CMAKE__LINK_EXECUTABLE

2019-10-08 Thread Setzer Sebastian (CM-CI2/ECS2) via CMake
Dear list,
I need to run a tool after building an executable, which will modify the 
executable itself.
I intend to extend the toolchain for this, because it shall be done for every 
executable on this particular operating system.

I think for this purpose, I need to change the rule 
CMAKE__LINK_EXECUTABLE.
And I think I can't put multiple commands into that rule, so I need to write a 
wrapper which will be called instead of the normal linker, and the calls the 
normal linker and then that special tool.

Right, so far?

Now I'd like to pass a few additional parameters to this tool, which I'd like 
to get from a special target property.

The rule currently looks like this:
set(CMAKE_C_LINK_EXECUTABLE"  
   -o  ")

And I wonder what these placeholders in angle brackets mean, and if there are 
more placeholders available. The manual doesn't say anything about this, 
unfortunately:
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_LINK_EXECUTABLE.html

Is there, for example, a way to access arbitrary target properties?
Or do I need to hide my special parameters somewhere in the LINK_OPTIONS 
property?

Regards,
Sebastian
-- 

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:
https://cmake.org/mailman/listinfo/cmake