1dca9c7cfSJan Korous# Creates the ClangdXPC framework. 2dca9c7cfSJan Korousmacro(create_clangd_xpc_framework target name) 3dca9c7cfSJan Korous set(CLANGD_FRAMEWORK_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${name}.framework") 4dca9c7cfSJan Korous set(CLANGD_FRAMEWORK_OUT_LOCATION "${CLANGD_FRAMEWORK_LOCATION}/Versions/A") 5dca9c7cfSJan Korous 6dca9c7cfSJan Korous # Create the framework info PLIST. 7dca9c7cfSJan Korous set(CLANGD_XPC_FRAMEWORK_NAME "${name}") 8dca9c7cfSJan Korous configure_file( 9dca9c7cfSJan Korous "${CLANGD_XPC_SOURCE_DIR}/cmake/Info.plist.in" 10dca9c7cfSJan Korous "${CLANGD_XPC_BINARY_DIR}/${name}.Info.plist") 11dca9c7cfSJan Korous 12dca9c7cfSJan Korous set(CLANGD_XPC_SERVICE_NAME "clangd") 13dca9c7cfSJan Korous set(CLANGD_XPC_SERVICE_OUT_LOCATION 14dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_OUT_LOCATION}/XPCServices/${CLANGD_XPC_SERVICE_NAME}.xpc/Contents") 15dca9c7cfSJan Korous 16dca9c7cfSJan Korous # Create the XPC service info PLIST. 17dca9c7cfSJan Korous set(CLANGD_XPC_SERVICE_BUNDLE_NAME "org.llvm.${CLANGD_XPC_SERVICE_NAME}") 18dca9c7cfSJan Korous configure_file( 19dca9c7cfSJan Korous "${CLANGD_XPC_SOURCE_DIR}/cmake/XPCServiceInfo.plist.in" 20dca9c7cfSJan Korous "${CLANGD_XPC_BINARY_DIR}/${name}Service.Info.plist") 21dca9c7cfSJan Korous 22dca9c7cfSJan Korous # Create the custom command 23dca9c7cfSJan Korous add_custom_command(OUTPUT ${CLANGD_FRAMEWORK_LOCATION} 24dca9c7cfSJan Korous # Copy the PLIST. 25dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E copy 26dca9c7cfSJan Korous "${CLANGD_XPC_BINARY_DIR}/${name}.Info.plist" 27dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_OUT_LOCATION}/Resources/Info.plist" 28dca9c7cfSJan Korous 29dca9c7cfSJan Korous # Copy the framework binary. 30dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E copy 317b5c8792SJordan Rose "$<TARGET_FILE:${target}>" 32dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_OUT_LOCATION}/${name}" 33dca9c7cfSJan Korous 34dca9c7cfSJan Korous # Copy the XPC Service PLIST. 35dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E copy 36dca9c7cfSJan Korous "${CLANGD_XPC_BINARY_DIR}/${name}Service.Info.plist" 37dca9c7cfSJan Korous "${CLANGD_XPC_SERVICE_OUT_LOCATION}/Info.plist" 38dca9c7cfSJan Korous 39dca9c7cfSJan Korous # Copy the Clangd binary. 40dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E copy 417b5c8792SJordan Rose "$<TARGET_FILE:clangd>" 42dca9c7cfSJan Korous "${CLANGD_XPC_SERVICE_OUT_LOCATION}/MacOS/clangd" 43dca9c7cfSJan Korous 44dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E create_symlink "A" 45dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_LOCATION}/Versions/Current" 46dca9c7cfSJan Korous 47dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E create_symlink 48dca9c7cfSJan Korous "Versions/Current/Resources" 49dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_LOCATION}/Resources" 50dca9c7cfSJan Korous 51dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E create_symlink 52dca9c7cfSJan Korous "Versions/Current/XPCServices" 53dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_LOCATION}/XPCServices" 54dca9c7cfSJan Korous 55dca9c7cfSJan Korous COMMAND ${CMAKE_COMMAND} -E create_symlink 56dca9c7cfSJan Korous "Versions/Current/${name}" 57dca9c7cfSJan Korous "${CLANGD_FRAMEWORK_LOCATION}/${name}" 58dca9c7cfSJan Korous 59dca9c7cfSJan Korous DEPENDS 60dca9c7cfSJan Korous "${CLANGD_XPC_BINARY_DIR}/${name}.Info.plist" 61dca9c7cfSJan Korous "${CLANGD_XPC_BINARY_DIR}/${name}Service.Info.plist" 62dca9c7cfSJan Korous clangd 63dca9c7cfSJan Korous COMMENT "Creating ClangdXPC framework" 64dca9c7cfSJan Korous VERBATIM 65dca9c7cfSJan Korous ) 66dca9c7cfSJan Korous 67dca9c7cfSJan Korous add_custom_target( 68dca9c7cfSJan Korous ClangdXPC 69dca9c7cfSJan Korous DEPENDS 70dca9c7cfSJan Korous ${target} 71dca9c7cfSJan Korous ${CLANGD_FRAMEWORK_LOCATION} 72dca9c7cfSJan Korous ) 73760a9ee6SChris Bieneman 74*b801b607SJan Svoboda set_property( 75*b801b607SJan Svoboda TARGET ClangdXPC 76*b801b607SJan Svoboda APPEND 77*b801b607SJan Svoboda PROPERTY ADDITIONAL_CLEAN_FILES ${CLANGD_FRAMEWORK_LOCATION} 78*b801b607SJan Svoboda ) 79*b801b607SJan Svoboda 80760a9ee6SChris Bieneman # clangd is already signed as a standalone executable, so it must be forced. 81760a9ee6SChris Bieneman llvm_codesign(ClangdXPC BUNDLE_PATH "${CLANGD_FRAMEWORK_OUT_LOCATION}/XPCServices/${CLANGD_XPC_SERVICE_NAME}.xpc/" FORCE) 82760a9ee6SChris Bieneman # ClangdXPC library is already signed as a standalone library, so it must be forced. 83760a9ee6SChris Bieneman llvm_codesign(ClangdXPC BUNDLE_PATH "${CLANGD_FRAMEWORK_LOCATION}" FORCE) 84dca9c7cfSJan Korousendmacro(create_clangd_xpc_framework) 85