@@ -70,7 +70,7 @@ function(add_module lib)
7070endfunction ()
7171
7272function (install_module lib)
73-   if (ENABLE_SHARED )
73+   if (TARGET   ${lib} _shared )
7474    set_target_properties (${lib} _shared PROPERTIES
7575      VERSION  ${SOVERSION} 
7676      SOVERSION  ${SOVERSION_MAJOR} 
@@ -80,7 +80,7 @@ function(install_module lib)
8080      LIBRARY DESTINATION  ${CMAKE_INSTALL_LIBDIR} 
8181      ARCHIVE DESTINATION  ${CMAKE_INSTALL_LIBDIR} )
8282  endif ()
83-   if (ENABLE_STATIC )
83+   if (TARGET   ${lib} _static )
8484    install (TARGETS ${lib} _static
8585      RUNTIME DESTINATION  ${CMAKE_INSTALL_BINDIR} 
8686      LIBRARY DESTINATION  ${CMAKE_INSTALL_LIBDIR} 
@@ -113,59 +113,3 @@ function(install_module lib)
113113    install (FILES  ${header}  ${ARGN} )
114114  endforeach ()
115115endfunction ()
116- 
117- function (target_link_modules target )
118-   # If the target we're adding dependencies to is a shared library, add it to 
119-   # the set of targets. 
120-   if (TARGET  ${target} _shared)
121-     set (_targets ${_targets}  ${target} _shared)
122-     # Shared libraries should first try to link against other shared libraries. 
123-     set (${target} _shared_primary shared)
124-     # If that fails (because the shared target doesn't exist), try linking 
125-     # against the static library. This requires the static library's objects to 
126-     # be PIC. 
127-     set (${target} _shared_secondary static )
128-   endif ()
129-   # It can also be a static library at the same time. 
130-   if (TARGET  ${target} _static)
131-     set (_targets ${_targets}  ${target} _static)
132-     # Static libraries aren't actually linked, but their dependencies are 
133-     # recorded by "linking" them. If we link an executable to a static library, 
134-     # we want to also link statically against its transitive dependencies. 
135-     set (${target} _static_primary static )
136-     # If a dependency doesn't exist as static library, we link against the 
137-     # shared one. 
138-     set (${target} _static_secondary shared)
139-   endif ()
140-   # If it's neither, then it's an executable. 
141-   if (NOT  _targets)
142-     set (_targets ${_targets}  ${target} )
143-     # Executables preferably link against static libraries, so they are 
144-     # standalone and can be shipped without any external dependencies. As a 
145-     # frame of reference: tests become roughly 600-800K binaries instead of 
146-     # 50-100K on x86_64 Linux. 
147-     set (${target} _primary static )
148-     set (${target} _secondary shared)
149-   endif ()
150- 
151-   foreach (dep ${ARGN} )
152-     foreach (_target ${_targets} )
153-       if (TARGET  ${dep} _${${_target} _primary})
154-         target_link_libraries (${_target}  PRIVATE  ${dep} _${${_target} _primary})
155-       elseif (TARGET  ${dep} _${${_target} _secondary})
156-         target_link_libraries (${_target}  PRIVATE  ${dep} _${${_target} _secondary})
157-       else ()
158-         # We record the modules linked to this target, so that we can collect 
159-         # them later when linking a composed module. 
160-         list (FIND  LINK_MODULES ${dep}  _index)
161-         if (_index EQUAL  -1)
162-           set (LINK_MODULES ${LINK_MODULES}  ${dep} )
163-         endif ()
164- 
165-         target_link_libraries (${_target}  PRIVATE  ${dep} )
166-       endif ()
167-     endforeach ()
168-   endforeach ()
169- 
170-   set (${target} _LINK_MODULES ${${target} _LINK_MODULES} ${LINK_MODULES}  PARENT_SCOPE)
171- endfunction ()
0 commit comments