1 ##===- cmake/modules/Makefile ------------------------------*- Makefile -*-===##
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 ##===----------------------------------------------------------------------===##
12 include $(LEVEL)/Makefile.common
14 PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
16 ifeq ($(DISABLE_ASSERTIONS),1)
17 LLVM_ENABLE_ASSERTIONS := 0
19 LLVM_ENABLE_ASSERTIONS := 1
22 ifeq ($(ENABLE_ABI_BREAKING_CHECKS),1)
23 LLVM_ABI_BREAKING_CHECKS := FORCE_ON
25 LLVM_ABI_BREAKING_CHECKS := FORCE_OFF
28 ifeq ($(REQUIRES_EH),1)
34 ifeq ($(REQUIRES_RTTI),1)
40 ifndef LLVM_LIBS_TO_EXPORT
41 $(error LLVM_LIBS_TO_EXPORT cannot be empty)
44 OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
47 \# Compute the CMake directory from the LLVMConfig.cmake file location.\n\
48 get_filename_component(_LLVM_CMAKE_DIR "$${CMAKE_CURRENT_LIST_FILE}" PATH)\n\
49 \# Compute the installation prefix from the LLVMConfig.cmake file location.\n\
50 get_filename_component(LLVM_INSTALL_PREFIX "$${CMAKE_CURRENT_LIST_FILE}" PATH)\n
52 # Compute number of levels (typically 3 - ``share/llvm/cmake/``) to PROJ_prefix
53 # from PROJ_cmake, then emit the appropriate number of calls to
54 # get_filename_components(). Note this assumes there are no spaces in the
55 # cmake_path_suffix variable.
56 cmake_path_suffix := $(subst $(PROJ_prefix),,$(subst $(DESTDIR),,$(PROJ_cmake)))
57 cmake_path_dirs := $(subst /, ,$(cmake_path_suffix))
58 LLVM_CONFIG_CODE += $(foreach __not_used,$(cmake_path_dirs),get_filename_component(LLVM_INSTALL_PREFIX "$${LLVM_INSTALL_PREFIX}" PATH)\n)
60 LLVM_CONFIG_CODE += set(_LLVM_LIBRARY_DIR "$${LLVM_INSTALL_PREFIX}\/lib")
62 $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in Makefile $(LLVMBuildCMakeFrag)
63 $(Echo) 'Generating LLVM CMake package config file'
66 -e 's/@LLVM_CONFIG_CODE@/$(LLVM_CONFIG_CODE)/' \
67 -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
68 -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
69 -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
70 -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
71 -e 's/@LLVM_COMMON_DEPENDS@//' \
72 -e 's/@LLVM_AVAILABLE_LIBS@/'"$(LLVM_LIBS_TO_EXPORT)"'/' \
73 -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
74 -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
75 -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
76 -e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \
77 -e 's/@LLVM_ABI_BREAKING_CHECKS@/'"$(LLVM_ABI_BREAKING_CHECKS)"'/' \
78 -e 's/@LLVM_ENABLE_ASSERTIONS@/'"$(LLVM_ENABLE_ASSERTIONS)"'/' \
79 -e 's/@LLVM_ENABLE_EH@/'"$(LLVM_ENABLE_EH)"'/' \
80 -e 's/@LLVM_ENABLE_RTTI@/'"$(LLVM_ENABLE_RTTI)"'/' \
81 -e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \
82 -e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \
83 -e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
84 -e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
85 -e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
86 -e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
87 -e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
88 -e 's/@LLVM_LIBDIR_SUFFIX@//' \
89 -e 's#@LLVM_CONFIG_INCLUDE_DIRS@#$${LLVM_INSTALL_PREFIX}/include#' \
90 -e 's#@LLVM_CONFIG_LIBRARY_DIRS@#$${_LLVM_LIBRARY_DIR}#' \
91 -e 's#@LLVM_CONFIG_CMAKE_DIR@#$${_LLVM_CMAKE_DIR}#' \
92 -e 's#@LLVM_CONFIG_TOOLS_BINARY_DIR@#$${LLVM_INSTALL_PREFIX}/bin#' \
93 -e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \
94 -e 's/@all_llvm_lib_deps@//' \
96 ( grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" | \
97 grep -v LLVMBUILD_LIB_DEPS_gtest ) && \
98 echo 'unset(_LLVM_CMAKE_DIR)' && \
99 echo 'unset(_LLVM_LIBRARY_DIR)' \
102 $(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in Makefile
103 $(Echo) 'Generating LLVM CMake package version file'
104 $(Verb) cat $< | sed \
105 -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
106 -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
107 -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
108 -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
111 $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag) Makefile
112 $(Echo) 'Generating LLVM CMake target exports file'
114 echo '# LLVM CMake target exports. Do not include directly.' && \
115 for lib in $(LLVM_LIBS_TO_EXPORT); do \
116 echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
117 echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "$${_LLVM_LIBRARY_DIR}/'lib$$lib.a'")' ; \
119 cat "$(LLVMBuildCMakeExportsFrag)" && \
120 echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
123 all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
127 GetHostTriple.cmake \
128 LLVMBuildExports.cmake \
130 LLVMConfigVersion.cmake \
134 SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
135 SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
136 INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
137 INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
140 $(Echo) Making install directory: $@
143 $(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
144 $(Echo) Installing cmake modules: $(notdir $<)
145 $(Verb) $(DataInstall) $< $(PROJ_cmake)
147 $(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
148 $(Echo) Installing cmake modules: $(notdir $<)
149 $(Verb) $(DataInstall) $< $(PROJ_cmake)
151 install-local:: $(INSTSRCMODS) $(INSTOBJMODS)