[Lldb-commits] [lldb] r289879 - [CMake] Refactor LLDB libraries and tools to be components
Chris Bieneman via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 15 14:01:18 PST 2016
Author: cbieneman
Date: Thu Dec 15 16:01:17 2016
New Revision: 289879
URL: http://llvm.org/viewvc/llvm-project?rev=289879&view=rev
Log:
[CMake] Refactor LLDB libraries and tools to be components
In LLVM's CMake we have a convention that components have both a build and an install target. Making LLDB follow this convention will allow LLDB to take advantage of the LLVM_DISTRIBUTION_COMPONENTS build option from LLVM.
Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/cmake/modules/LLDBConfig.cmake
lldb/trunk/tools/argdumper/CMakeLists.txt
lldb/trunk/tools/darwin-debug/CMakeLists.txt
lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
lldb/trunk/tools/driver/CMakeLists.txt
lldb/trunk/tools/lldb-mi/CMakeLists.txt
lldb/trunk/tools/lldb-server/CMakeLists.txt
Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Thu Dec 15 16:01:17 2016
@@ -17,7 +17,7 @@ function(lldb_link_common_libs name targ
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 $<TARGET_FILE_DIR:liblldb>/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
Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Thu Dec 15 16:01:17 2016
@@ -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"
Modified: lldb/trunk/tools/argdumper/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/argdumper/CMakeLists.txt?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/tools/argdumper/CMakeLists.txt (original)
+++ lldb/trunk/tools/argdumper/CMakeLists.txt Thu Dec 15 16:01:17 2016
@@ -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)
Modified: lldb/trunk/tools/darwin-debug/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/CMakeLists.txt?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/tools/darwin-debug/CMakeLists.txt (original)
+++ lldb/trunk/tools/darwin-debug/CMakeLists.txt Thu Dec 15 16:01:17 2016
@@ -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)
Modified: lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt Thu Dec 15 16:01:17 2016
@@ -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}" STR
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endif()
-
-install(TARGETS debugserver
- RUNTIME DESTINATION bin
- )
Modified: lldb/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/CMakeLists.txt?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/tools/driver/CMakeLists.txt (original)
+++ lldb/trunk/tools/driver/CMakeLists.txt Thu Dec 15 16:01:17 2016
@@ -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)
Modified: lldb/trunk/tools/lldb-mi/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/CMakeLists.txt?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-mi/CMakeLists.txt Thu Dec 15 16:01:17 2016
@@ -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)
Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=289879&r1=289878&r2=289879&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Thu Dec 15 16:01:17 2016
@@ -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_COMP
target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
set_target_properties(lldb-server PROPERTIES VERSION ${LLDB_VERSION})
-
-install(TARGETS lldb-server
- RUNTIME DESTINATION bin)
More information about the lldb-commits
mailing list