1##===- cmake/modules/Makefile ------------------------------*- Makefile -*-===## 2# 3# The LLVM Compiler Infrastructure 4# 5# This file is distributed under the University of Illinois Open Source 6# License. See LICENSE.TXT for details. 7# 8##===----------------------------------------------------------------------===## 9 10LEVEL = ../.. 11 12LINK_COMPONENTS := all 13 14include $(LEVEL)/Makefile.common 15 16PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake 17 18ifeq ($(DISABLE_ASSERTIONS),1) 19 LLVM_ENABLE_ASSERTIONS := 0 20else 21 LLVM_ENABLE_ASSERTIONS := 1 22endif 23 24ifeq ($(ENABLE_ABI_BREAKING_CHECKS),1) 25 LLVM_ABI_BREAKING_CHECKS := FORCE_ON 26else 27 LLVM_ABI_BREAKING_CHECKS := FORCE_OFF 28endif 29 30ifeq ($(REQUIRES_EH),1) 31 LLVM_ENABLE_EH := 1 32else 33 LLVM_ENABLE_EH := 0 34endif 35 36ifeq ($(REQUIRES_RTTI),1) 37 LLVM_ENABLE_RTTI := 1 38else 39 LLVM_ENABLE_RTTI := 0 40endif 41 42# Don't try to run llvm-config during clean because it won't be available 43ifneq ($(MAKECMDGOALS),clean) 44LLVM_LIBS_TO_EXPORT := $(subst -l,,$(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)) 45 46ifeq ($(LLVM_LIBS_TO_EXPORT),Error) 47$(error llvm-config --libs failed) 48endif 49 50ifndef LLVM_LIBS_TO_EXPORT 51$(error LLVM_LIBS_TO_EXPORT cannot be empty) 52endif 53endif 54 55OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake 56 57$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in Makefile $(LLVMBuildCMakeFrag) 58 $(Echo) 'Generating LLVM CMake package config file' 59 $(Verb) ( \ 60 cat $< | sed \ 61 -e 's/@LLVM_CONFIG_CODE@/set(LLVM_INSTALL_PREFIX "'"$(subst /,\/,$(PROJ_prefix))"'")/' \ 62 -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \ 63 -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \ 64 -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \ 65 -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \ 66 -e 's/@LLVM_COMMON_DEPENDS@//' \ 67 -e 's/@LLVM_AVAILABLE_LIBS@/'"$(LLVM_LIBS_TO_EXPORT)"'/' \ 68 -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \ 69 -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \ 70 -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \ 71 -e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \ 72 -e 's/@LLVM_ABI_BREAKING_CHECKS@/'"$(LLVM_ABI_BREAKING_CHECKS)"'/' \ 73 -e 's/@LLVM_ENABLE_ASSERTIONS@/'"$(LLVM_ENABLE_ASSERTIONS)"'/' \ 74 -e 's/@LLVM_ENABLE_EH@/'"$(LLVM_ENABLE_EH)"'/' \ 75 -e 's/@LLVM_ENABLE_RTTI@/'"$(LLVM_ENABLE_RTTI)"'/' \ 76 -e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \ 77 -e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \ 78 -e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \ 79 -e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \ 80 -e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \ 81 -e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \ 82 -e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \ 83 -e 's/@LLVM_LIBDIR_SUFFIX@//' \ 84 -e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \ 85 -e 's/@LLVM_CONFIG_LIBRARY_DIRS@/'"$(subst /,\/,$(PROJ_libdir))"'/' \ 86 -e 's/@LLVM_CONFIG_CMAKE_DIR@/'"$(subst /,\/,$(PROJ_cmake))"'/' \ 87 -e 's/@LLVM_CONFIG_TOOLS_BINARY_DIR@/'"$(subst /,\/,$(PROJ_bindir))"'/' \ 88 -e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \ 89 -e 's/@all_llvm_lib_deps@//' \ 90 && \ 91 grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" \ 92 ) > $@ 93 94$(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in 95 $(Echo) 'Generating LLVM CMake package version file' 96 $(Verb) cat $< | sed \ 97 -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \ 98 -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \ 99 -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \ 100 -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \ 101 > $@ 102 103$(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag) 104 $(Echo) 'Generating LLVM CMake target exports file' 105 $(Verb) ( \ 106 echo '# LLVM CMake target exports. Do not include directly.' && \ 107 for lib in $(LLVM_LIBS_TO_EXPORT); do \ 108 echo 'add_library('"$$lib"' STATIC IMPORTED)' && \ 109 echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \ 110 done && \ 111 cat "$(LLVMBuildCMakeExportsFrag)" && \ 112 echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \ 113 ) | grep -v gtest > $@ 114 115all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS)) 116 117SKIPSRCMODS := \ 118 CheckAtomic.cmake \ 119 GetHostTriple.cmake \ 120 LLVMBuildExports.cmake \ 121 LLVMConfig.cmake \ 122 LLVMConfigVersion.cmake \ 123 LLVMExports.cmake \ 124 VersionFromVCS.cmake 125 126SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake)) 127SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS)) 128INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS)) 129INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS)) 130 131$(PROJ_cmake): 132 $(Echo) Making install directory: $@ 133 $(Verb) $(MKDIR) $@ 134 135$(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake) 136 $(Echo) Installing cmake modules: $(notdir $<) 137 $(Verb) $(DataInstall) $< $(PROJ_cmake) 138 139$(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake) 140 $(Echo) Installing cmake modules: $(notdir $<) 141 $(Verb) $(DataInstall) $< $(PROJ_cmake) 142 143install-local:: $(INSTSRCMODS) $(INSTOBJMODS) 144