@@ -153,55 +153,54 @@ function(absl_cc_library)
153153
154154 # Generate a pkg-config file for every library:
155155 if (ABSL_ENABLE_INSTALL)
156- if (NOT ABSL_CC_LIB_TESTONLY)
157- if (absl_VERSION)
158- set (PC_VERSION "${absl_VERSION} " )
159- else ()
160- set (PC_VERSION "head" )
161- endif ()
162- if (NOT _build_type STREQUAL "dll" )
163- set (LNK_LIB "${LNK_LIB} -labsl_${_NAME} " )
164- endif ()
165- foreach (dep ${ABSL_CC_LIB_DEPS} )
166- if (${dep} MATCHES "^absl::(.*)" )
167- # for DLL builds many libs are not created, but add
168- # the pkgconfigs nevertheless, pointing to the dll.
169- if (_build_type STREQUAL "dll" )
170- # hide this MATCHES in an if-clause so it doesn't overwrite
171- # the CMAKE_MATCH_1 from (${dep} MATCHES "^absl::(.*)")
172- if (NOT PC_DEPS MATCHES "abseil_dll" )
173- # Join deps with commas.
174- if (PC_DEPS)
175- set (PC_DEPS "${PC_DEPS} ," )
176- endif ()
177- # don't duplicate dll-dep if it exists already
178- set (PC_DEPS "${PC_DEPS} abseil_dll = ${PC_VERSION} " )
179- set (LNK_LIB "${LNK_LIB} -labseil_dll" )
180- endif ()
181- else ()
156+ if (absl_VERSION)
157+ set (PC_VERSION "${absl_VERSION} " )
158+ else ()
159+ set (PC_VERSION "head" )
160+ endif ()
161+ if (NOT _build_type STREQUAL "dll" )
162+ set (LNK_LIB "${LNK_LIB} -labsl_${_NAME} " )
163+ endif ()
164+ foreach (dep ${ABSL_CC_LIB_DEPS} )
165+ if (${dep} MATCHES "^absl::(.*)" )
166+ # for DLL builds many libs are not created, but add
167+ # the pkgconfigs nevertheless, pointing to the dll.
168+ if (_build_type STREQUAL "dll" )
169+ # hide this MATCHES in an if-clause so it doesn't overwrite
170+ # the CMAKE_MATCH_1 from (${dep} MATCHES "^absl::(.*)")
171+ if (NOT PC_DEPS MATCHES "abseil_dll" )
182172 # Join deps with commas.
183173 if (PC_DEPS)
184174 set (PC_DEPS "${PC_DEPS} ," )
185175 endif ()
186- set (PC_DEPS "${PC_DEPS} absl_${CMAKE_MATCH_1} = ${PC_VERSION} " )
176+ # don't duplicate dll-dep if it exists already
177+ set (PC_DEPS "${PC_DEPS} abseil_dll = ${PC_VERSION} " )
178+ set (LNK_LIB "${LNK_LIB} -labseil_dll" )
187179 endif ()
188- endif ()
189- endforeach ()
190- foreach (cflag ${ABSL_CC_LIB_COPTS} )
191- if (${cflag} MATCHES "^(-Wno|/wd)" )
192- # These flags are needed to suppress warnings that might fire in our headers.
193- set (PC_CFLAGS "${PC_CFLAGS} ${cflag} " )
194- elseif (${cflag} MATCHES "^(-W|/w[1234eo])" )
195- # Don't impose our warnings on others.
196- elseif (${cflag} MATCHES "^-m" )
197- # Don't impose CPU instruction requirements on others, as
198- # the code performs feature detection on runtime.
199180 else ()
200- set (PC_CFLAGS "${PC_CFLAGS} ${cflag} " )
181+ # Join deps with commas.
182+ if (PC_DEPS)
183+ set (PC_DEPS "${PC_DEPS} ," )
184+ endif ()
185+ set (PC_DEPS "${PC_DEPS} absl_${CMAKE_MATCH_1} = ${PC_VERSION} " )
201186 endif ()
202- endforeach ()
203- string (REPLACE ";" " " PC_LINKOPTS "${ABSL_CC_LIB_LINKOPTS} " )
204- FILE (GENERATE OUTPUT "${CMAKE_BINARY_DIR} /lib/pkgconfig/absl_${_NAME} .pc" CONTENT "\
187+ endif ()
188+ endforeach ()
189+ foreach (cflag ${ABSL_CC_LIB_COPTS} )
190+ if (${cflag} MATCHES "^(-Wno|/wd)" )
191+ # These flags are needed to suppress warnings that might fire in our headers.
192+ set (PC_CFLAGS "${PC_CFLAGS} ${cflag} " )
193+ elseif (${cflag} MATCHES "^(-W|/w[1234eo])" )
194+ # Don't impose our warnings on others.
195+ elseif (${cflag} MATCHES "^-m" )
196+ # Don't impose CPU instruction requirements on others, as
197+ # the code performs feature detection on runtime.
198+ else ()
199+ set (PC_CFLAGS "${PC_CFLAGS} ${cflag} " )
200+ endif ()
201+ endforeach ()
202+ string (REPLACE ";" " " PC_LINKOPTS "${ABSL_CC_LIB_LINKOPTS} " )
203+ FILE (GENERATE OUTPUT "${CMAKE_BINARY_DIR} /lib/pkgconfig/absl_${_NAME} .pc" CONTENT "\
205204prefix=${CMAKE_INSTALL_PREFIX} \n\
206205exec_prefix=\$ {prefix}\n\
207206libdir=${CMAKE_INSTALL_FULL_LIBDIR} \n\
@@ -214,9 +213,8 @@ Version: ${PC_VERSION}\n\
214213Requires:${PC_DEPS} \n\
215214Libs: -L\$ {libdir} ${PC_LINKOPTS} $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE} >>:${LNK_LIB} >\n\
216215Cflags: -I\$ {includedir}${PC_CFLAGS} \n " )
217- INSTALL (FILES "${CMAKE_BINARY_DIR} /lib/pkgconfig/absl_${_NAME} .pc"
218- DESTINATION "${CMAKE_INSTALL_LIBDIR} /pkgconfig" )
219- endif ()
216+ INSTALL (FILES "${CMAKE_BINARY_DIR} /lib/pkgconfig/absl_${_NAME} .pc"
217+ DESTINATION "${CMAKE_INSTALL_LIBDIR} /pkgconfig" )
220218 endif ()
221219
222220 if (NOT ABSL_CC_LIB_IS_INTERFACE)
@@ -346,9 +344,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
346344 endif ()
347345 endif ()
348346
349- # TODO currently we don't install googletest alongside abseil sources, so
350- # installed abseil can't be tested.
351- if (NOT ABSL_CC_LIB_TESTONLY AND ABSL_ENABLE_INSTALL)
347+ if (ABSL_ENABLE_INSTALL)
352348 install (TARGETS ${_NAME} EXPORT ${PROJECT_NAME} Targets
353349 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
354350 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
0 commit comments