View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014979CMake(No Category)public2014-06-17 20:002015-11-02 09:13
ReporterNico Schlömer 
Assigned ToStephen Kelly 
PrioritylowSeverityfeatureReproducibilityhave not tried
StatusclosedResolutionduplicate 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0014979: build both static and dynamic with cmake arguments
DescriptionRight now, to build both the static and the dynamic version of a library, two `add_library` calls have to be present in the respective CMakeLists.txt file, e.g.,
```
add_library(MyLib SHARED source1.c source2.c)
add_library(MyLibStatic STATIC source1.c source2.c)
```
To control this from the command line, one has the switch `BUILD_SHARED_LIBS` which is set to either on or off.

In Debian -- and possibly other distributors too --, you would like to build *both* shared and dynamic versions of all libraries, and that without modifying the software sources. The first option (patch the software to contain both `add_library(... SHARED ...)` and `add_library(... STATIC ...)`) is hence not an option.

It seems that configuring the software twice, with BUILD_SHARED_LIBS set to ON and OFF, respectively, is the only option.

Is this what CMake developers would recommend, too, or would there be a smarter way of handling things?
TagsNo tags attached.
Attached Files

 Relationships
duplicate of 0004222closedBill Hoffman ADD_LIBRARY should support simultaneous STATIC | SHARED builds 

  Notes
(0036225)
Brad King (manager)
2014-06-19 11:51

Switching on BUILD_SHARED_LIBS is the only general-purpose option. Even that will only work if the project code was written without explicit SHARED or STATIC options to its add_library calls. Otherwise there is no way to do this except with support from the project code.
(0036230)
Nico Schlömer (reporter)
2014-06-19 16:17

Hm right; BUILD_SHARED_LIBS is only meaningful if SHARED or STATIC aren't explicitly set. I suppose the rationale behind this is:
```
The code author, not the builder (distributor) decides if shared and/or static make sense for the project.
```
Is this correct? If so, could you give a little more background on this?
(0036232)
Brad King (manager)
2014-06-23 10:16

Re 0014979:0036230: That is correct.

Some projects support BUILD_SHARED_LIBS. Some explicitly specify the type of every library. Some only support one type. Some add both types themselves. CMake does not mandate any convention.
(0039768)
Robert Maynard (manager)
2015-11-02 09:13

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-06-17 20:00 Nico Schlömer New Issue
2014-06-19 11:51 Brad King Note Added: 0036225
2014-06-19 16:17 Nico Schlömer Note Added: 0036230
2014-06-23 10:16 Brad King Note Added: 0036232
2015-04-13 13:53 Stephen Kelly Relationship added duplicate of 0004222
2015-04-13 13:53 Stephen Kelly Status new => resolved
2015-04-13 13:53 Stephen Kelly Resolution open => duplicate
2015-04-13 13:53 Stephen Kelly Assigned To => Stephen Kelly
2015-11-02 09:13 Robert Maynard Note Added: 0039768
2015-11-02 09:13 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team