From 4c56efbd441d17b61f3e29ee2372e6e460d5a185 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sun, 9 Feb 2014 16:37:02 +0000 Subject: Provide CMake package modules in install tree Teach the Makefile build system to generate and install CMake modules LLVMConfig.cmake and LLVMConfigVersion.cmake so that applications that build with CMake can use 'find_package(LLVM)' even when LLVM is not built with CMake. These modules tell such applications about available LLVM libraries and their dependencies. Run llvm-config to generate the list of libraries and use the results of llvm-build to generate the library dependencies. Use sed to perform substitutions in the LLVMConfig.cmake.in and LLVMConfigVersion.cmake.in sources that our CMake build system uses. Teach the Makefile build system to generate the LLVMExports.cmake file with content similar to that produced by the CMake install(EXPORT) command. Extend llvm-build with an option to generate the library dependencies fragment for this file. Contributed by Brad King. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201053 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/llvm-build/llvmbuild/main.py | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'utils') diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py index eacefdf60b..2a10247743 100644 --- a/utils/llvm-build/llvmbuild/main.py +++ b/utils/llvm-build/llvmbuild/main.py @@ -573,6 +573,40 @@ set_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_%s %s)\n""" % ( f.close() + def write_cmake_exports_fragment(self, output_path): + """ + write_cmake_exports_fragment(output_path) -> None + + Generate a CMake fragment which includes LLVMBuild library + dependencies expressed similarly to how CMake would write + them via install(EXPORT). + """ + + dependencies = list(self.get_fragment_dependencies()) + + # Write out the CMake exports fragment. + make_install_dir(os.path.dirname(output_path)) + f = open(output_path, 'w') + + f.write("""\ +# Explicit library dependency information. +# +# The following property assignments tell CMake about link +# dependencies of libraries imported from LLVM. +""") + for ci in self.ordered_component_infos: + # We only write the information for libraries currently. + if ci.type_name != 'Library': + continue + + f.write("""\ +set_property(TARGET %s PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES %s)\n""" % ( + ci.get_prefixed_library_name(), " ".join(sorted( + dep.get_prefixed_library_name() + for dep in self.get_required_libraries_for_component(ci))))) + + f.close() + def write_make_fragment(self, output_path): """ write_make_fragment(output_path) -> None @@ -780,6 +814,10 @@ def main(): dest="write_cmake_fragment", metavar="PATH", help="Write the CMake project information to PATH", action="store", default=None) + group.add_option("", "--write-cmake-exports-fragment", + dest="write_cmake_exports_fragment", metavar="PATH", + help="Write the CMake exports information to PATH", + action="store", default=None) group.add_option("", "--write-make-fragment", dest="write_make_fragment", metavar="PATH", help="Write the Makefile project information to PATH", @@ -861,6 +899,8 @@ given by --build-root) at the same SUBPATH""", # Write out the cmake fragment, if requested. if opts.write_cmake_fragment: project_info.write_cmake_fragment(opts.write_cmake_fragment) + if opts.write_cmake_exports_fragment: + project_info.write_cmake_exports_fragment(opts.write_cmake_exports_fragment) # Configure target definition files, if requested. if opts.configure_target_def_files: -- cgit v1.2.3