Skip to content

Commit

Permalink
[clang] Add build and install targets for clang libraries
Browse files Browse the repository at this point in the history
This is modeled after the existing llvm-libraries target. It's a
convenient way to include all clang libraries in a distribution.

This differs slightly from the llvm-libraries target in that it adds any
library added via add_clang_library, whereas llvm-libraries only
includes targets added via add_llvm_library that didn't use the MODULE
or BUILDTREE_ONLY arguments. add_clang_library doesn't appear to have
any equivalents of those arguments, so the conditions don't apply.

Differential Revision: https://reviews.llvm.org/D58269

llvm-svn: 354141
  • Loading branch information
smeenai committed Feb 15, 2019
1 parent b4ff1ab commit d705864
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions clang/CMakeLists.txt
Expand Up @@ -543,6 +543,27 @@ if( CLANG_INCLUDE_DOCS )
add_subdirectory(docs)
endif()

# Custom target to install all clang libraries.
add_custom_target(clang-libraries)
set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")

if(NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
endif()

get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
if(CLANG_LIBS)
list(REMOVE_DUPLICATES CLANG_LIBS)
foreach(lib ${CLANG_LIBS})
add_dependencies(clang-libraries ${lib})
if(NOT CMAKE_CONFIGURATION_TYPES)
add_dependencies(install-clang-libraries install-${lib})
endif()
endforeach()
endif()

add_subdirectory(cmake/modules)

if(CLANG_STAGE)
Expand Down
2 changes: 2 additions & 0 deletions clang/cmake/modules/AddClang.cmake
Expand Up @@ -108,6 +108,8 @@ macro(add_clang_library name)
DEPENDS ${name}
COMPONENT ${name})
endif()

set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
endif()
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
else()
Expand Down

0 comments on commit d705864

Please sign in to comment.