Home | History | Annotate | Download | only in modules
      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 	  -e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
     56 	  -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
     57 	  -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
     58 	  > $@
     59 
     60 $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
     61 	$(Echo) 'Generating LLVM CMake target exports file'
     62 	$(Verb) ( \
     63 	  echo '# LLVM CMake target exports.  Do not include directly.' && \
     64 	  for lib in $(subst -l,,$(LLVMConfigLibs)); do \
     65 	    echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
     66 	    echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
     67 	  done && \
     68 	  cat "$(LLVMBuildCMakeExportsFrag)" && \
     69 	  echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
     70 	) | grep -v gtest > $@
     71 
     72 all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
     73 
     74 SKIPSRCMODS := \
     75   CheckAtomic.cmake \
     76   GetHostTriple.cmake \
     77   LLVMBuildExports.cmake \
     78   LLVMConfig.cmake \
     79   LLVMConfigVersion.cmake \
     80   LLVMExports.cmake \
     81   VersionFromVCS.cmake
     82 
     83 SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
     84 SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
     85 INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
     86 INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
     87 
     88 $(PROJ_cmake):
     89 	$(Echo) Making install directory: $@
     90 	$(Verb) $(MKDIR) $@
     91 
     92 $(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
     93 	$(Echo) Installing cmake modules: $(notdir $<)
     94 	$(Verb) $(DataInstall) $< $(PROJ_cmake)
     95 
     96 $(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
     97 	$(Echo) Installing cmake modules: $(notdir $<)
     98 	$(Verb) $(DataInstall) $< $(PROJ_cmake)
     99 
    100 install-local:: $(INSTSRCMODS) $(INSTOBJMODS)
    101