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 LINK_COMPONENTS := all
14 include $(LEVEL)/Makefile.common
16 PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
18 OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
20 # TODO: Teach LLVM-Config.cmake to work without explicit terminfo libs.
21 TERMINFO_LIBS := tinfo terminfo curses ncurses ncursesw
22 TERMINFO_LIBS := $(filter $(TERMINFO_LIBS),$(subst -l,,$(LIBS)))
24 $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
25 $(Echo) 'Generating LLVM CMake package config file'
28 -e 's/@LLVM_CONFIG_CODE@/set(LLVM_INSTALL_PREFIX "'"$(subst /,\/,$(PROJ_prefix))"'")/' \
29 -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
30 -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
31 -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
32 -e 's/@LLVM_COMMON_DEPENDS@//' \
33 -e 's/"@llvm_libs@"/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
34 -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
35 -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
36 -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
37 -e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \
38 -e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \
39 -e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \
40 -e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
41 -e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
42 -e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
43 -e 's/@HAVE_TERMINFO@/'"$(HAVE_TERMINFO)"'/' \
44 -e 's/@TERMINFO_LIBS@/'"$(TERMINFO_LIBS)"'/' \
45 -e 's/@HAVE_LIBDL@/'"$(HAVE_DLOPEN)"'/' \
46 -e 's/@HAVE_LIBPTHREAD@/'"$(HAVE_PTHREAD)"'/' \
47 -e 's/@HAVE_LIBZ@/'"$(HAVE_LIBZ)"'/' \
48 -e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
49 -e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
50 -e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \
51 -e 's/@LLVM_CONFIG_LIBRARY_DIRS@/'"$(subst /,\/,$(PROJ_libdir))"'/' \
52 -e 's/@LLVM_CONFIG_CMAKE_DIR@/'"$(subst /,\/,$(PROJ_cmake))"'/' \
53 -e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \
54 -e 's/@all_llvm_lib_deps@//' \
56 grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" \
59 $(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in
60 $(Echo) 'Generating LLVM CMake package version file'
61 $(Verb) cat $< | sed \
62 -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
65 $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
66 $(Echo) 'Generating LLVM CMake target exports file'
68 echo '# LLVM CMake target exports. Do not include directly.' && \
69 for lib in $(subst -l,,$(LLVMConfigLibs)); do \
70 echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
71 echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
73 cat "$(LLVMBuildCMakeExportsFrag)" \
74 ) | grep -v gtest > $@
76 all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
81 LLVMBuildExports.cmake \
83 LLVMConfigVersion.cmake \
87 SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
88 SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
89 INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
90 INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
93 $(Echo) Making install directory: $@
96 $(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
97 $(Echo) Installing cmake modules: $(notdir $<)
98 $(Verb) $(DataInstall) $< $(PROJ_cmake)
100 $(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
101 $(Echo) Installing cmake modules: $(notdir $<)
102 $(Verb) $(DataInstall) $< $(PROJ_cmake)
104 install-local:: $(INSTSRCMODS) $(INSTOBJMODS)