LLVMExports.cmake: Exclude gtest since they are not installed.
[oota-llvm.git] / cmake / modules / Makefile
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
10 LEVEL = ../..
11
12 LINK_COMPONENTS := all
13
14 include $(LEVEL)/Makefile.common
15
16 PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
17
18 OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
19
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)))
23
24 $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
25         $(Echo) 'Generating LLVM CMake package config file'
26         $(Verb) ( \
27          cat $< | sed \
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@//' \
55          && \
56          grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" \
57         ) > $@
58
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)"'/' \
63           > $@
64
65 $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
66         $(Echo) 'Generating LLVM CMake target exports file'
67         $(Verb) ( \
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"'")' ; \
72           done && \
73           cat "$(LLVMBuildCMakeExportsFrag)" \
74         ) | grep -v gtest > $@
75
76 all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
77
78 SKIPSRCMODS := \
79   CheckAtomic.cmake \
80   GetHostTriple.cmake \
81   LLVMBuildExports.cmake \
82   LLVMConfig.cmake \
83   LLVMConfigVersion.cmake \
84   LLVMExports.cmake \
85   VersionFromVCS.cmake
86
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))
91
92 $(PROJ_cmake):
93         $(Echo) Making install directory: $@
94         $(Verb) $(MKDIR) $@
95
96 $(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
97         $(Echo) Installing cmake modules: $(notdir $<)
98         $(Verb) $(DataInstall) $< $(PROJ_cmake)
99
100 $(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
101         $(Echo) Installing cmake modules: $(notdir $<)
102         $(Verb) $(DataInstall) $< $(PROJ_cmake)
103
104 install-local:: $(INSTSRCMODS) $(INSTOBJMODS)