[CMake] LINK_FLAGS directory property

Attila Krasznahorkay attila.krasznahorkay at gmail.com
Mon May 2 03:48:57 EDT 2016


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



More information about the CMake mailing list