MantisBT - CMake
View Issue Details
0004222CMakeCMakepublic2006-12-16 21:112016-06-10 14:30
Gonzalo Garramuno 
Bill Hoffman 
normalfeaturealways
closedmoved 
 
 
0004222: ADD_LIBRARY should support simultaneous STATIC | SHARED builds
Currently, CMake defaults to have ADD_LIBRARY support either a static or a shared library build.
Unfortunately, these statements/switches are exclusive from each other.

This is somewhat wrong and more limiting than autoconf. ADD_LIBRARY() should support creating both static and shared built libraries, so that the result (on Unix, for example, is):

libZZZ.so
libZZZ.a

Currently, cmake forces you to create two builds for obtaining a similar behavior (and it is problematic for large projects that may need to mix some libraries being created static, some both and some shared).
No tags attached.
related to 0014539closed Kitware Robot Multiple output configurations 
has duplicate 0010216closed Bill Hoffman Add a CMake way to create a static and shared library at the same time 
has duplicate 0014979closed Stephen Kelly build both static and dynamic with cmake arguments 
Issue History
2008-10-31 06:43Daniel SantosNote Added: 0013995
2008-11-03 06:45Rolf Eike BeerNote Added: 0014015
2008-12-04 03:07Philip LowmanNote Added: 0014283
2013-11-02 10:24Stephen KellyRelationship addedhas duplicate 0010216
2015-04-13 13:53Stephen KellyRelationship addedhas duplicate 0014979
2015-04-13 13:55Stephen KellyNote Added: 0038504
2015-04-13 13:55Stephen KellyRelationship addedrelated to 0014539
2016-06-10 14:27Kitware RobotNote Added: 0041338
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0013995)
Daniel Santos   
2008-10-31 06:43   
bump, cmake really needs this
(0014015)
Rolf Eike Beer   
2008-11-03 06:45   
I would like to see this, too. But when this goes in we need a way to specify to which version another target links.
(0014283)
Philip Lowman   
2008-12-04 03:07   
For those interested this can be worked around with some CMake wrapping macros.

We use a global variable that includes either STATIC, SHARED, or both in a list, and then wrap ADD_EXECUTABLE and ADD_LIBRARY to create targets with "-shared" and "-static" suffixes. Then we wrap TARGET_LINK_LIBRARIES for our own libraries to do the same. The net effect is with a few macros you can create both shared and static simultaneously.

See:
http://www.mail-archive.com/cmake@cmake.org/msg07864.html [^]
(0038504)
Stephen Kelly   
2015-04-13 13:55   
CMake might also need to either provide a way to generate multiple IMPORTED targets on export(), or generate IMPORTED targets with multiple LOCATION_FOO properties.
(0041338)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.