Skip to content

Commit

Permalink
Filter libraries that are not installed out of CMake exports (currently
Browse files Browse the repository at this point in the history
gtest and gtest_main) when generating ``Makefile.llvmbuild``.

Libraries that are not installed should not be exported because they
won't be available from an install tree.  Rather than filtering out the
gtest libraries in cmake/modules/Makefile, simply teach llvm-build to
filter out libraries that will not be installed from its generated list
of exported libraries.

Note that LLVMBUILD_LIB_DEPS_* are used during our own CMake build
process so we cannot filter LLVMBUILD_LIB_DEPS_gtest* out in llvm-build.
We must leave this gtest filter logic in cmake/modules/Makefile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245718 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
delcypher committed Aug 21, 2015
1 parent fe112c2 commit 299db16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 1 addition & 5 deletions cmake/modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ else
LLVM_ENABLE_RTTI := 0
endif

# Strip out gtest and gtest_main from LLVM_LIBS_TO_EXPORT, these are not
# installed and won't be available from the install tree.
LLVM_LIBS_TO_EXPORT := $(filter-out gtest gtest_main,$(LLVM_LIBS_TO_EXPORT))

ifndef LLVM_LIBS_TO_EXPORT
$(error LLVM_LIBS_TO_EXPORT cannot be empty)
endif
Expand Down Expand Up @@ -122,7 +118,7 @@ $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag) Makefile
done && \
cat "$(LLVMBuildCMakeExportsFrag)" && \
echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
) | grep -v gtest > $@
) > $@

all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))

Expand Down
17 changes: 12 additions & 5 deletions utils/llvm-build/llvmbuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def get_fragment_dependencies(self):

def foreach_cmake_library(self, f,
enabled_optional_components,
skip_disabled):
skip_disabled,
skip_not_installed):
for ci in self.ordered_component_infos:
# Skip optional components which are not enabled.
if ci.type_name == 'OptionalLibrary' \
Expand All @@ -520,6 +521,10 @@ def foreach_cmake_library(self, f,
if tg and not tg.enabled:
continue

# Skip targets that will not be installed
if skip_not_installed and not ci.installed:
continue

f(ci)


Expand Down Expand Up @@ -600,7 +605,8 @@ def write_cmake_fragment(self, output_path, enabled_optional_components):
for dep in self.get_required_libraries_for_component(ci)))))
,
enabled_optional_components,
skip_disabled = False
skip_disabled = False,
skip_not_installed = False # Dependency info must be emitted for internals libs too
)

f.close()
Expand Down Expand Up @@ -635,7 +641,8 @@ def write_cmake_exports_fragment(self, output_path, enabled_optional_components)
for dep in self.get_required_libraries_for_component(ci)))))
,
enabled_optional_components,
skip_disabled = True
skip_disabled = True,
skip_not_installed = True # Do not export internal libraries like gtest
)

f.close()
Expand Down Expand Up @@ -715,10 +722,10 @@ def write_make_fragment(self, output_path, enabled_optional_components):
f.write(' \\\n %s' % ci.get_prefixed_library_name())
,
enabled_optional_components,
skip_disabled = True
skip_disabled = True,
skip_not_installed = True # Do not export internal libraries like gtest
)
f.write('\n')

f.close()

def add_magic_target_components(parser, project, opts):
Expand Down

0 comments on commit 299db16

Please sign in to comment.