diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index bf2a9aaa91b3..1ca6f3e661bf 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -17,7 +17,7 @@ function(lldb_link_common_libs name targetkind) endif() endfunction(lldb_link_common_libs) -macro(add_lldb_library name) +function(add_lldb_library name) # only supported parameters to this macro are the optional # MODULE;SHARED;STATIC library type and source files cmake_parse_arguments(PARAM @@ -80,14 +80,23 @@ macro(add_lldb_library name) set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) endif() install(TARGETS ${name} + COMPONENT ${name} RUNTIME DESTINATION bin LIBRARY DESTINATION ${out_dir} ARCHIVE DESTINATION ${out_dir}) else() install(TARGETS ${name} + COMPONENT ${name} LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) endif() + if (NOT CMAKE_CONFIGURATION_TYPES) + add_custom_target(install-${name} + DEPENDS ${name} + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_COMPONENT=${name} + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") + endif() endif() endif() @@ -100,14 +109,15 @@ macro(add_lldb_library name) endif() set_target_properties(${name} PROPERTIES FOLDER "lldb libraries") -endmacro(add_lldb_library) +endfunction(add_lldb_library) -macro(add_lldb_executable name) - cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK" "" "" ${ARGN}) +function(add_lldb_executable name) + cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL" "" "" ${ARGN}) add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}) set_target_properties(${name} PROPERTIES FOLDER "lldb executables") + set(install_dir bin) if(LLDB_BUILD_FRAMEWORK) if(ARG_INCLUDE_IN_FRAMEWORK) string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR}) @@ -115,16 +125,34 @@ macro(add_lldb_executable name) RUNTIME_OUTPUT_DIRECTORY $/Resources BUILD_WITH_INSTALL_RPATH On INSTALL_RPATH "@loader_path/../../../../${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}") - - add_llvm_tool_symlink(${name} ${name} ARG_ALWAYS_GENERATE - OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) else() set_target_properties(${name} PROPERTIES BUILD_WITH_INSTALL_RPATH On INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}") + if(ARG_GENERATE_INSTALL) + install(TARGETS ${name} + COMPONENT ${name} + RUNTIME DESTINATION ${install_dir}) + if (NOT CMAKE_CONFIGURATION_TYPES) + add_custom_target(install-${name} + DEPENDS ${name} + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_COMPONENT=${name} + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") + endif() + endif() endif() endif() -endmacro(add_lldb_executable) + + if(ARG_INCLUDE_IN_FRAMEWORK AND LLDB_BUILD_FRAMEWORK) + add_llvm_tool_symlink(${name} ${name} ALWAYS_GENERATE SKIP_INSTALL + OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) + endif() +endfunction(add_lldb_executable) + +function(add_lldb_tool name) + add_lldb_executable(${name} GENERATE_INSTALL ${ARGN}) +endfunction() # Support appending linker flags to an existing target. # This will preserve the existing linker flags on the diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 4be19974ee33..fe2deeb99621 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -275,6 +275,7 @@ include_directories(BEFORE if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/ + COMPONENT lldb_headers DESTINATION include FILES_MATCHING PATTERN "*.h" diff --git a/lldb/tools/argdumper/CMakeLists.txt b/lldb/tools/argdumper/CMakeLists.txt index ce595721eefc..9bf956396b4f 100644 --- a/lldb/tools/argdumper/CMakeLists.txt +++ b/lldb/tools/argdumper/CMakeLists.txt @@ -1,6 +1,6 @@ include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake) -add_lldb_executable(lldb-argdumper INCLUDE_IN_FRAMEWORK +add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK argdumper.cpp ) @@ -11,6 +11,3 @@ else() endif() llvm_config(lldb-argdumper ${LLVM_LINK_COMPONENTS}) - -install(TARGETS lldb-argdumper - RUNTIME DESTINATION bin) diff --git a/lldb/tools/darwin-debug/CMakeLists.txt b/lldb/tools/darwin-debug/CMakeLists.txt index 3861017f0944..2f28eab3a58f 100644 --- a/lldb/tools/darwin-debug/CMakeLists.txt +++ b/lldb/tools/darwin-debug/CMakeLists.txt @@ -1,6 +1,3 @@ -add_lldb_executable(darwin-debug INCLUDE_IN_FRAMEWORK +add_lldb_tool(darwin-debug INCLUDE_IN_FRAMEWORK darwin-debug.cpp ) - -install(TARGETS darwin-debug - RUNTIME DESTINATION bin) diff --git a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt index 492046e2b31e..7b77eb25d554 100644 --- a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt +++ b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt @@ -36,7 +36,7 @@ set(DEBUGSERVER_USED_LIBS lldbDebugserverMacOSX_DarwinLog ) -add_lldb_executable(debugserver INCLUDE_IN_FRAMEWORK +add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK HasAVX.s CFBundle.cpp CFString.cpp @@ -78,7 +78,3 @@ if (NOT ("${LLDB_CODESIGN_IDENTITY}" STREQUAL "")) WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) endif() - -install(TARGETS debugserver - RUNTIME DESTINATION bin - ) diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt index 5d7f79bd87e5..73f065d4357d 100644 --- a/lldb/tools/driver/CMakeLists.txt +++ b/lldb/tools/driver/CMakeLists.txt @@ -1,6 +1,6 @@ include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake) -add_lldb_executable(lldb +add_lldb_tool(lldb Driver.cpp Platform.cpp ) @@ -32,5 +32,3 @@ endif() set_target_properties(lldb PROPERTIES VERSION ${LLDB_VERSION}) -install(TARGETS lldb - RUNTIME DESTINATION bin) diff --git a/lldb/tools/lldb-mi/CMakeLists.txt b/lldb/tools/lldb-mi/CMakeLists.txt index 1e73b8200a82..f7e0581a451d 100644 --- a/lldb/tools/lldb-mi/CMakeLists.txt +++ b/lldb/tools/lldb-mi/CMakeLists.txt @@ -84,7 +84,7 @@ endif () # We need to include the llvm components we depend on manually, as liblldb does # not re-export those. set(LLVM_LINK_COMPONENTS Support) -add_lldb_executable(lldb-mi ${LLDB_MI_SOURCES}) +add_lldb_tool(lldb-mi ${LLDB_MI_SOURCES}) target_link_libraries(lldb-mi liblldb) if (HAVE_LIBPTHREAD) @@ -92,6 +92,3 @@ if (HAVE_LIBPTHREAD) endif () set_target_properties(lldb-mi PROPERTIES VERSION ${LLDB_VERSION}) - -install(TARGETS lldb-mi - RUNTIME DESTINATION bin) diff --git a/lldb/tools/lldb-server/CMakeLists.txt b/lldb/tools/lldb-server/CMakeLists.txt index bc238282ea78..19c3a9bbabb4 100644 --- a/lldb/tools/lldb-server/CMakeLists.txt +++ b/lldb/tools/lldb-server/CMakeLists.txt @@ -165,7 +165,7 @@ set(LLVM_LINK_COMPONENTS target ) -add_lldb_executable(lldb-server INCLUDE_IN_FRAMEWORK +add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK Acceptor.cpp lldb-gdbserver.cpp lldb-platform.cpp @@ -188,6 +188,3 @@ llvm_config(lldb-server ${LLVM_LINK_COMPONENTS}) target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS}) set_target_properties(lldb-server PROPERTIES VERSION ${LLDB_VERSION}) - -install(TARGETS lldb-server - RUNTIME DESTINATION bin)