[CMake] LINK_FLAGS directory property

Matthew Keeler mkeeler at tenable.com
Mon May 2 10:20:53 EDT 2016


I am doing that for some things but it gets quite cumbersome as I have to override those for several different configurations. I guess that is the only way to do it currently. 

-- 
Matt Keeler


On May 2, 2016 at 03:48:59, Attila Krasznahorkay (attila.krasznahorkay at gmail.com) wrote:

Hi Matt,  

Have you tried using the  

CMAKE_EXE_LINKER_FLAGS  
CMAKE_SHARED_LINKER_FLAGS  
CMAKE_MODULE_LINKER_FLAGS  

cache variables? These actually set these flags globally, and not just for one directory, but on the directory level they are easy to override. You can just do something like this in a subdirectory:  

string( REPLACE "-Wl,--as-needed" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" )  

Cheers,  
Attila  

> On 27 Apr 2016, at 17:57, Matthew Keeler <mkeeler at tenable.com> wrote:  
>  
> Is there an equivalent directory property for the target level LINK_FLAGS property. I can’t see anything according to the documentation but was hoping there was an oversight and something actually existed.  
>  
> What I am trying to do is pass extra flags to the linker for every target in my project and I didn’t want to have to set it per target. I tried using the link_libraries command but the flags I am adding are msvc specific and start with ‘/‘ and cmake seems to be turning these into ‘\’ when its passed to the linker. Then the linker thinks its trying to link in another file and everything blows up.  
>  
> Also a secondary question is what does the INTERPROCEDURAL_OPTIMIZATIONS property at the directory level do. I assume on Windows it passes /GL to the compiler but will this also add /LCTG to the linker flags and prevent incremental linking. If I turn this property on will it also do it for debug configurations or just optimized configurations?  
>  
> --  
> Matt Keeler  
>  
> --  
>  
> 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  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160502/4dad5b4d/attachment.html>


More information about the CMake mailing list