Skip to content

Commit 87f1910

Browse files
ldionnecopybara-github
authored andcommitted
[runtimes] Always define cxx_shared, cxx_static & other targets (#80007)
This patch always defines the cxx_shared, cxx_static & other top-level targets. However, they are marked as EXCLUDE_FROM_ALL when we don't want to build them. Simply declaring the targets should be of no harm, and it allows other projects to mention these targets regardless of whether they end up being built or not. This patch basically moves the definition of e.g. cxx_shared out of the `if (LIBCXX_ENABLE_SHARED)` and instead marks it as EXCLUDE_FROM_ALL conditionally on whether LIBCXX_ENABLE_SHARED is passed. It then does the same for libunwind and libc++abi targets. I purposefully avoided to reformat the files (which now has inconsistent indentation) because I wanted to keep the diff minimal, and I know this is an area of the code where folks may have downstream diffs. I will re-indent the code separately once this patch lands. This is a reapplication of 79ee0342dbf0, which was reverted in a3539090884c because it broke the TSAN and the Fuchsia builds. Resolves #77654 Differential Revision: https://reviews.llvm.org/D134221 NOKEYCHECK=True GitOrigin-RevId: 917ada35cd937ad4104dff89c48398bd796ba6b7
1 parent 71735e8 commit 87f1910

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,23 @@ if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CO
153153
set_target_properties(unwind_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) # must set manually because it's an object library
154154
endif()
155155

156-
if (LIBUNWIND_ENABLE_SHARED)
157156
add_library(unwind_shared SHARED)
158157
target_link_libraries(unwind_shared PUBLIC unwind_shared_objects)
159158
set_target_properties(unwind_shared
160159
PROPERTIES
160+
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_SHARED}>,FALSE,TRUE>"
161161
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
162162
LINKER_LANGUAGE C
163163
OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}"
164164
VERSION "${LIBUNWIND_LIBRARY_VERSION}"
165165
SOVERSION "1"
166166
)
167167

168+
if (LIBUNWIND_ENABLE_SHARED)
168169
list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared")
169-
if (LIBUNWIND_INSTALL_SHARED_LIBRARY)
170-
list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared")
171-
endif()
170+
endif()
171+
if (LIBUNWIND_INSTALL_SHARED_LIBRARY)
172+
list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared")
172173
endif()
173174

174175
# Build the static library.
@@ -199,20 +200,21 @@ if(LIBUNWIND_HIDE_SYMBOLS)
199200
target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
200201
endif()
201202

202-
if (LIBUNWIND_ENABLE_STATIC)
203203
add_library(unwind_static STATIC)
204204
target_link_libraries(unwind_static PUBLIC unwind_static_objects)
205205
set_target_properties(unwind_static
206206
PROPERTIES
207+
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_STATIC}>,FALSE,TRUE>"
207208
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
208209
LINKER_LANGUAGE C
209210
OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}"
210211
)
211212

213+
if (LIBUNWIND_ENABLE_STATIC)
212214
list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static")
213-
if (LIBUNWIND_INSTALL_STATIC_LIBRARY)
214-
list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static")
215-
endif()
215+
endif()
216+
if (LIBUNWIND_INSTALL_STATIC_LIBRARY)
217+
list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static")
216218
endif()
217219

218220
# Add a meta-target for both libraries.

0 commit comments

Comments
 (0)