[MIPS GlobalISel] Select MSA vector generic and builtin add
[llvm-complete.git] / cmake / modules / CMakeLists.txt
blob9cf22b436fa7367d56e69a1d6c23b8155be956a6
1 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
2 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
4 # First for users who use an installed LLVM, create the LLVMExports.cmake file.
5 set(LLVM_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
6 get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS)
7 export(TARGETS ${LLVM_EXPORTS} FILE ${LLVM_EXPORTS_FILE})
9 # Then for users who want to link against the LLVM build tree, provide the
10 # normal targets and the build tree only targets.
11 set(LLVM_BUILDTREEONLY_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMBuildTreeOnlyTargets.cmake)
12 get_property(LLVM_EXPORTS_BUILDTREE_ONLY GLOBAL PROPERTY LLVM_EXPORTS_BUILDTREE_ONLY)
13 export(TARGETS ${LLVM_EXPORTS_BUILDTREE_ONLY} FILE ${LLVM_BUILDTREEONLY_EXPORTS_FILE})
15 get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
17 foreach(lib ${LLVM_AVAILABLE_LIBS})
18   get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib})
19   set(all_llvm_lib_deps
20     "${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})")
21 endforeach(lib)
23 # CMake requires that all targets expressed as dependencies exist, so we can't
24 # have intrinsics_gen in LLVM_COMMON_DEPENDS when it is written out, otherwise
25 # projects building out of tree will have CMake errors. This only gets hit when
26 # LLVM_ENABLE_MODULES=On. Eventually we should come up with a better solution to
27 # this, but there is no easy solution.
28 if(intrinsics_gen IN_LIST LLVM_COMMON_DEPENDS)
29   list(REMOVE_ITEM LLVM_COMMON_DEPENDS intrinsics_gen)
30 endif()
32 # Generate LLVMConfig.cmake for the build tree.
33 set(LLVM_CONFIG_CODE "
34 # LLVM_BUILD_* values available only from LLVM build tree.
35 set(LLVM_BUILD_BINARY_DIR \"${LLVM_BINARY_DIR}\")
36 set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\")
37 set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\")
38 set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\")
40 set(LLVM_CONFIG_INCLUDE_DIRS
41   "${LLVM_MAIN_INCLUDE_DIR}"
42   "${LLVM_INCLUDE_DIR}"
43   )
44 set(LLVM_CONFIG_INCLUDE_DIR
45   "${LLVM_INCLUDE_DIR}"
46   )
47 set(LLVM_CONFIG_MAIN_INCLUDE_DIR
48   "${LLVM_MAIN_INCLUDE_DIR}"
49   )
50 set(LLVM_CONFIG_LIBRARY_DIRS
51   "${LLVM_LIBRARY_DIR}"
52   )
53 set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
54 set(LLVM_CONFIG_BINARY_DIR "${LLVM_BINARY_DIR}")
55 set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
57 if (LLVM_LINK_LLVM_DYLIB)
58   set(LLVM_CONFIG_LINK_LLVM_DYLIB
59       "set(LLVM_LINK_LLVM_DYLIB ${LLVM_LINK_LLVM_DYLIB})")
60 endif()
62 # We need to use the full path to the LLVM Exports file to make sure we get the
63 # one from the build tree. This is due to our cmake files being split between
64 # this source dir and the binary dir in the build tree configuration and the
65 # LLVM_CONFIG_CMAKE_DIR being the source directory. In contrast in the install
66 # tree, both the generated LLVMExports.cmake file and the rest of the cmake
67 # source files are put in the same cmake directory.
68 set(LLVM_CONFIG_EXPORTS_FILE "${LLVM_EXPORTS_FILE}")
69 set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS};${LLVM_EXPORTS_BUILDTREE_ONLY}")
70 set(llvm_config_include_buildtree_only_exports
71 "include(\"${LLVM_BUILDTREEONLY_EXPORTS_FILE}\")")
72 configure_file(
73   LLVMConfig.cmake.in
74   ${llvm_cmake_builddir}/LLVMConfig.cmake
75   @ONLY)
76 set(llvm_config_include_buildtree_only_exports)
78 # For compatibility with projects that include(LLVMConfig)
79 # via CMAKE_MODULE_PATH, place API modules next to it.
80 # This should be removed in the future.
81 file(COPY .
82   DESTINATION ${llvm_cmake_builddir}
83   FILES_MATCHING PATTERN *.cmake
84   PATTERN .svn EXCLUDE
85   PATTERN CMakeFiles EXCLUDE
86   )
88 # Generate LLVMConfig.cmake for the install tree.
89 set(LLVM_CONFIG_CODE "
90 # Compute the installation prefix from this LLVMConfig.cmake file location.
91 get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
92 # Construct the proper number of get_filename_component(... PATH)
93 # calls to compute the installation prefix.
94 string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
95 foreach(p ${_count})
96   set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
97 get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
98 endforeach(p)
99 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
100 set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
101 set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
102 set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
103 set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
104 set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
105 set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
106 set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
107 set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}")
108 configure_file(
109   LLVMConfig.cmake.in
110   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
111   @ONLY)
113 # Generate LLVMConfigVersion.cmake for build and install tree.
114 configure_file(
115   LLVMConfigVersion.cmake.in
116   ${llvm_cmake_builddir}/LLVMConfigVersion.cmake
117   @ONLY)
119 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
120   get_property(llvm_has_exports GLOBAL PROPERTY LLVM_HAS_EXPORTS)
121   if(llvm_has_exports)
122     install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
123             COMPONENT cmake-exports)
124   endif()
126   install(FILES
127     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
128     ${llvm_cmake_builddir}/LLVMConfigVersion.cmake
129     LLVM-Config.cmake
130     DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
131     COMPONENT cmake-exports)
133   install(DIRECTORY .
134     DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
135     COMPONENT cmake-exports
136     FILES_MATCHING PATTERN *.cmake
137     PATTERN .svn EXCLUDE
138     PATTERN LLVMConfig.cmake EXCLUDE
139     PATTERN LLVMConfigVersion.cmake EXCLUDE
140     PATTERN LLVM-Config.cmake EXCLUDE
141     PATTERN GetHostTriple.cmake EXCLUDE)
143   if (NOT LLVM_ENABLE_IDE)
144     # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
145     add_custom_target(cmake-exports)
146     add_llvm_install_targets(install-cmake-exports
147                              COMPONENT cmake-exports)
148   endif()
149 endif()