817f911ea7c8760cbcfd23791bdaa7a0af1a69bc
[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 $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
21         $(Echo) 'Generating LLVM CMake package config file'
22         $(Verb) ( \
23          cat $< | sed \
24           -e 's/@LLVM_CONFIG_CODE@/set(LLVM_INSTALL_PREFIX "'"$(subst /,\/,$(PROJ_prefix))"'")/' \
25           -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
26           -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
27           -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
28           -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
29           -e 's/@LLVM_COMMON_DEPENDS@//' \
30           -e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
31           -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
32           -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
33           -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
34           -e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \
35           -e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \
36           -e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \
37           -e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
38           -e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
39           -e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
40           -e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
41           -e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
42           -e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \
43           -e 's/@LLVM_CONFIG_LIBRARY_DIRS@/'"$(subst /,\/,$(PROJ_libdir))"'/' \
44           -e 's/@LLVM_CONFIG_CMAKE_DIR@/'"$(subst /,\/,$(PROJ_cmake))"'/' \
45           -e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \
46           -e 's/@all_llvm_lib_deps@//' \
47          && \
48          grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" \
49         ) > $@
50
51 $(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in
52         $(Echo) 'Generating LLVM CMake package version file'
53         $(Verb) cat $< | sed \
54           -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
55           > $@
56
57 $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
58         $(Echo) 'Generating LLVM CMake target exports file'
59         $(Verb) ( \
60           echo '# LLVM CMake target exports.  Do not include directly.' && \
61           for lib in $(subst -l,,$(LLVMConfigLibs)); do \
62             echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
63             echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
64           done && \
65           cat "$(LLVMBuildCMakeExportsFrag)" && \
66           echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
67         ) | grep -v gtest > $@
68
69 all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
70
71 SKIPSRCMODS := \
72   CheckAtomic.cmake \
73   GetHostTriple.cmake \
74   LLVMBuildExports.cmake \
75   LLVMConfig.cmake \
76   LLVMConfigVersion.cmake \
77   LLVMExports.cmake \
78   VersionFromVCS.cmake
79
80 SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
81 SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
82 INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
83 INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
84
85 $(PROJ_cmake):
86         $(Echo) Making install directory: $@
87         $(Verb) $(MKDIR) $@
88
89 $(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
90         $(Echo) Installing cmake modules: $(notdir $<)
91         $(Verb) $(DataInstall) $< $(PROJ_cmake)
92
93 $(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
94         $(Echo) Installing cmake modules: $(notdir $<)
95         $(Verb) $(DataInstall) $< $(PROJ_cmake)
96
97 install-local:: $(INSTSRCMODS) $(INSTOBJMODS)