Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -37,7 +37,15 @@ add_definitions(-DLLDB_USE_OS_LOG) endif() +option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off) if(LLDB_BUILD_FRAMEWORK) + if (CMAKE_VERSION VERSION_LESS 3.7) + message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7") + endif() + if (NOT APPLE) + message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms") + endif() + add_custom_target(lldb-framework) set(LLDB_FRAMEWORK_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR}) endif() @@ -129,6 +137,22 @@ add_subdirectory(utils/lldb-dotest) endif() +# lldb-suite is a dummy target that encompasses all the necessary tools and +# libraries for building a fully-functioning liblldb. +add_custom_target(lldb-suite) +if (LLDB_BUILD_FRAMEWORK) + include(LLDBFramework) + add_dependencies(lldb-suite lldb-framework) +else() + if (LLDB_CAN_USE_LLDB_SERVER) + add_dependencies(lldb-suite lldb-server) + endif() + if (LLDB_CAN_USE_DEBUGSERVER) + add_dependencies(lldb-suite debugserver) + endif() + add_dependencies(lldb-suite liblldb lldb-argdumper) +endif() + if (NOT LLDB_DISABLE_PYTHON) # Add a Post-Build Event to copy over Python files and create the symlink # to liblldb.so for the Python API(hardlink on Windows) @@ -147,8 +171,9 @@ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py COMMENT "Python script sym-linking LLDB Python API") - # We depend on liblldb being built before we can do this step. - add_dependencies(finish_swig liblldb lldb-argdumper) + + # We depend on liblldb and lldb-argdumper being built before we can do this step. + add_dependencies(finish_swig lldb-suite) # If we build the readline module, we depend on that happening # first. @@ -159,8 +184,8 @@ # Ensure we do the python post-build step when building lldb. add_dependencies(lldb finish_swig) - if(LLDB_BUILD_FRAMEWORK) - # The target to install libLLDB needs to depend on finish swig so that the + if (LLDB_BUILD_FRAMEWORK) + # The target to install libLLDB needs to depend on finish_swig so that the # framework build properly copies over the Python files. add_dependencies(install-liblldb finish_swig) endif() Index: cmake/modules/AddLLDB.cmake =================================================================== --- cmake/modules/AddLLDB.cmake +++ cmake/modules/AddLLDB.cmake @@ -101,6 +101,7 @@ if(LLDB_BUILD_FRAMEWORK) if(ARG_INCLUDE_IN_FRAMEWORK) + add_dependencies(lldb-framework ${name}) if(NOT IOS) set(resource_dir "/Resources") set(resource_dots "../") Index: cmake/modules/LLDBFramework.cmake =================================================================== --- /dev/null +++ cmake/modules/LLDBFramework.cmake @@ -0,0 +1,44 @@ +file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) +file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) +file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) +list(REMOVE_ITEM root_public_headers ${root_private_headers}) +foreach(header + ${public_headers} + ${root_public_headers} + ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h) + get_filename_component(basename ${header} NAME) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename} + DEPENDS ${header} + COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) + list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) +endforeach() +add_custom_target(lldb-framework-headers + DEPENDS ${framework_headers} + COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh ${CMAKE_CURRENT_BINARY_DIR} ${LLDB_VERSION}) + +if (NOT IOS) + if (NOT LLDB_BUILT_STANDALONE) + add_dependencies(lldb-framework clang-headers) + endif() + add_custom_command(TARGET lldb-framework POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $/Headers + COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers + COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/Current + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $/Resources/Clang + ) +else() + add_custom_command(TARGET lldb-framework POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $/Headers + ) +endif() + +set_target_properties(liblldb PROPERTIES + OUTPUT_NAME LLDB + FRAMEWORK On + FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR} + PUBLIC_HEADER "${framework_headers}") + +add_dependencies(lldb-framework + liblldb + lldb-framework-headers) Index: source/API/CMakeLists.txt =================================================================== --- source/API/CMakeLists.txt +++ source/API/CMakeLists.txt @@ -2,16 +2,6 @@ add_definitions( -DEXPORT_LIBLLDB ) endif() -option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off) - -if(LLDB_BUILD_FRAMEWORK AND CMAKE_VERSION VERSION_LESS 3.7) - message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7") -endif() - -if (LLDB_BUILD_FRAMEWORK AND NOT APPLE) - message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.") -endif() - get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) add_lldb_library(liblldb SHARED @@ -160,47 +150,3 @@ if (LLDB_WRAP_PYTHON) add_dependencies(liblldb swig_wrapper) endif() - -if(LLDB_BUILD_FRAMEWORK) - file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) - file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) - file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) - list(REMOVE_ITEM root_public_headers ${root_private_headers}) - - foreach(header ${public_headers} ${root_public_headers} ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h) - get_filename_component(basename ${header} NAME) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename} - DEPENDS ${header} - COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) - list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) - endforeach() - - add_custom_target(lldb-framework-headers DEPENDS ${framework_headers} - COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders ${LLDB_VERSION}) - add_dependencies(liblldb lldb-framework-headers) - - set_target_properties(liblldb PROPERTIES - OUTPUT_NAME LLDB - FRAMEWORK On - FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR} - PUBLIC_HEADER "${framework_headers}") - - if(NOT IOS) - if (NOT LLDB_BUILT_STANDALONE) - add_dependencies(liblldb clang-headers) - endif() - add_custom_command(TARGET liblldb POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $/Headers - COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers - COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/Current - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $/Resources/Clang - ) - else() - add_custom_command(TARGET liblldb POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $/Headers - ) - endif() - -endif() - Index: tools/driver/CMakeLists.txt =================================================================== --- tools/driver/CMakeLists.txt +++ tools/driver/CMakeLists.txt @@ -24,12 +24,4 @@ add_definitions( -DIMPORT_LIBLLDB ) endif() -# Add lldb dependency on lldb-server if we can use it. -if ( LLDB_CAN_USE_LLDB_SERVER ) - add_dependencies(lldb lldb-server) -endif() - -# Add lldb dependency on debugserver if we can use it. -if ( LLDB_CAN_USE_DEBUGSERVER ) - add_dependencies(lldb debugserver) -endif() +add_dependencies(lldb lldb-suite)