MantisBT - CMake
View Issue Details
0014932CMakeCMakepublic2014-05-23 16:552014-11-03 08:38
Saad 
 
normalminoralways
closedno change required 
PCWindows7
CMake 2.8.12.2 
 
0014932: Cannot set library linker flags for each configuration individually
Issue is related to: 0012295(http://www.cmake.org/Bug/view.php?id=12295 [^])

We already have CMAKE_EXE_LINKER_FLAGS_RELEASE for specifying executable linker flags (as well as MODULE and SHARED) but no variable for STATIC libraries. STATIC_LIBRARY_FLAGS does not work because it sets the flag(s) for all configurations. A variable such as CMAKE_STATIC_LINKER_FLAGS_RELEASE (and CMAKE_STATIC_LINKER_FLAGS_DEBUG etc.) that sets the flags for the VC++ librarian would be ideal.
c++, msvc
7z StaticLibLTCG.7z (317) 2014-05-27 16:04
https://public.kitware.com/Bug/file/5154/*
Issue History
2014-05-23 16:55SaadNew Issue
2014-05-23 16:56SaadTag Attached: c++
2014-05-23 16:56SaadTag Attached: msvc
2014-05-27 08:48Brad KingNote Added: 0035940
2014-05-27 16:04SaadNote Added: 0035945
2014-05-27 16:04SaadFile Added: StaticLibLTCG.7z
2014-05-27 16:18Brad KingNote Added: 0035946
2014-05-27 16:23SaadNote Added: 0035947
2014-05-27 16:24Brad KingNote Added: 0035948
2014-05-27 16:24Brad KingStatusnew => resolved
2014-05-27 16:24Brad KingResolutionopen => no change required
2014-11-03 08:38Robert MaynardNote Added: 0037143
2014-11-03 08:38Robert MaynardStatusresolved => closed

Notes
(0035940)
Brad King   
2014-05-27 08:48   
We already have the requested variables:

http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_STATIC_LINKER_FLAGS.html [^]
http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.html [^]

One can see the implementation here:

http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v2.8.12.2#l1530 [^]
(0035945)
Saad   
2014-05-27 16:04   
It does not seem to be working (see StaticLibLTCG.7z) - tested with VC++ 2010 and 2013.

Perhaps I am not using it properly?
(0035946)
Brad King   
2014-05-27 16:18   
You can't set the CMAKE_STATIC_LINKER_FLAGS_RELEASE variable before the project() command. The toolchain initialization done by that command creates the cache entry of the same name, and that unsets the local variable. The cache entry is supposed to be something that the local user can modify. If you want to add something beyond the user-specified value you can do

 set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -my-flag")

after the project() command.
(0035947)
Saad   
2014-05-27 16:23   
Thanks Brad, that worked.
(0035948)
Brad King   
2014-05-27 16:24   
Great, thanks for reporting back.
(0037143)
Robert Maynard   
2014-11-03 08:38   
Closing resolved issues that have not been updated in more than 4 months.