xiaobai created this revision. xiaobai added reviewers: clayborg, labath, sas. Herald added a subscriber: mgorny.
Currently, the liblldb target is treated as the entire framework when building LLDB.framework with CMake, and treated only as the actual liblldb library otherwise. In this patch I aim to at least partially accomplish 2 things: 1. Create a lldb-framework target that acts as the target that handles generating LLDB.framework. This should make the purpose of the liblldb target the same, framework or not. 2. Centralize framework generation as much as it makes sense to do so. I say "partially accomplish" because there are still parts of CMake that treats liblldb as the framework, and parts of CMake where we can greatly simplify code with an lldb-framework target. I am still working out how I think those should best be handled. I uploaded this patch because I want to get feedback on what I currently have. I also think this is a relatively self-contained change, because the build produces the same thing with and without this change (based on examining the build trees of both). https://reviews.llvm.org/D48060 Files: CMakeLists.txt cmake/modules/LLDBFramework.cmake source/API/CMakeLists.txt
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 $<TARGET_FILE_DIR:liblldb>/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} $<TARGET_FILE_DIR:liblldb>/Resources/Clang - ) - else() - add_custom_command(TARGET liblldb POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers - ) - endif() - -endif() - Index: cmake/modules/LLDBFramework.cmake =================================================================== --- /dev/null +++ cmake/modules/LLDBFramework.cmake @@ -0,0 +1,48 @@ +if (LLDB_BUILD_FRAMEWORK) + add_custom_target(lldb-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} ${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 $<TARGET_FILE_DIR:liblldb>/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} $<TARGET_FILE_DIR:liblldb>/Resources/Clang + ) + else() + add_custom_command(TARGET lldb-framework POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/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-argdumper lldb-server lldb-framework-headers) + add_dependencies(finish_swig lldb-framework) + add_dependencies(lldb lldb-framework) +endif() Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -37,7 +37,14 @@ 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 cannot be generated unless targeting Apple platforms") + endif() set(LLDB_FRAMEWORK_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR}) endif() @@ -178,3 +185,5 @@ COMMENT "Copying Python DLL to LLDB binaries directory.") endif () endif () + +include(LLDBFramework)
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits