diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2022-09-19 16:17:02 -0400 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2022-10-12 09:36:29 -0400 |
commit | 79ee0342dbf025bc70f237bdfe9ccb4e10a592ce (patch) | |
tree | e0d18a4af06beadd99098956a41496835aa7a6b8 /libunwind | |
parent | ec2640bf3a5221a3ac58f25b34976be6264e8e21 (diff) | |
download | llvm-79ee0342dbf025bc70f237bdfe9ccb4e10a592ce.tar.gz |
[runtimes] Always define cxx_shared, cxx_static & other targets
However, mark them 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.
While the diff may not make that obvious, 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.
Differential Revision: https://reviews.llvm.org/D134221
Diffstat (limited to 'libunwind')
-rw-r--r-- | libunwind/src/CMakeLists.txt | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index df32e53d69e6..c33180360d41 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -135,7 +135,9 @@ set_property(SOURCE ${LIBUNWIND_C_SOURCES} # ease, but does not rely on C++ at runtime. set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") +# # Build the shared library. +# add_library(unwind_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) if(CMAKE_C_COMPILER_ID STREQUAL MSVC) target_compile_options(unwind_shared_objects PRIVATE /GR-) @@ -154,25 +156,27 @@ if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CO set_target_properties(unwind_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) # must set manually because it's an object library endif() -if (LIBUNWIND_ENABLE_SHARED) - add_library(unwind_shared SHARED) - target_link_libraries(unwind_shared PUBLIC unwind_shared_objects) - set_target_properties(unwind_shared - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" - LINKER_LANGUAGE C - OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}" - VERSION "1.0" - SOVERSION "1" - ) +add_library(unwind_shared SHARED $<$<NOT:$<BOOL:LIBUNWIND_ENABLE_SHARED>>:EXCLUDE_FROM_ALL>) +target_link_libraries(unwind_shared PUBLIC unwind_shared_objects) +set_target_properties(unwind_shared + PROPERTIES + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + LINKER_LANGUAGE C + OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}" + VERSION "1.0" + SOVERSION "1" +) +if (LIBUNWIND_ENABLE_SHARED) list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared") - if (LIBUNWIND_INSTALL_SHARED_LIBRARY) - list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared") - endif() +endif() +if (LIBUNWIND_INSTALL_SHARED_LIBRARY) + list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared") endif() +# # Build the static library. +# add_library(unwind_static_objects OBJECT EXCLUDE_FROM_ALL ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) if(CMAKE_C_COMPILER_ID STREQUAL MSVC) target_compile_options(unwind_static_objects PRIVATE /GR-) @@ -194,20 +198,20 @@ if(LIBUNWIND_HIDE_SYMBOLS) target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS) endif() -if (LIBUNWIND_ENABLE_STATIC) - add_library(unwind_static STATIC) - target_link_libraries(unwind_static PUBLIC unwind_static_objects) - set_target_properties(unwind_static - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" - LINKER_LANGUAGE C - OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}" - ) +add_library(unwind_static STATIC $<$<NOT:$<BOOL:LIBUNWIND_ENABLE_STATIC>>:EXCLUDE_FROM_ALL>) +target_link_libraries(unwind_static PUBLIC unwind_static_objects) +set_target_properties(unwind_static + PROPERTIES + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + LINKER_LANGUAGE C + OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}" +) +if (LIBUNWIND_ENABLE_STATIC) list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static") - if (LIBUNWIND_INSTALL_STATIC_LIBRARY) - list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static") - endif() +endif() +if (LIBUNWIND_INSTALL_STATIC_LIBRARY) + list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static") endif() # Add a meta-target for both libraries. |