Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #14166: Add strip option to cmake.install tool #14167

Merged
merged 4 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conan/tools/cmake/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def install(self, build_type=None, component=None):
arg_list = ["--install", build_folder, build_config, "--prefix", pkg_folder]
if component:
arg_list.extend(["--component", component])

do_strip = self._conanfile.conf.get("tools.cmake.install:strip", check_type=bool)
sagi-ottopia marked this conversation as resolved.
Show resolved Hide resolved
if do_strip:
arg_list.append("--strip")
arg_list = " ".join(filter(None, arg_list))
command = "%s %s" % (self._cmake_program, arg_list)
self._conanfile.output.info("CMake command: %s" % command)
Expand Down
31 changes: 30 additions & 1 deletion conans/test/unittests/tools/cmake/test_cmake_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,38 @@ def test_run_install_component():
conanfile.settings = settings
conanfile.folders.set_base_package(temp_folder())

# Choose generator to match generic setttings
# Choose generator to match generic settings
write_cmake_presets(conanfile, "toolchain", "Visual Studio 14 2015", {})
cmake = CMake(conanfile)
cmake.install(component="foo")

assert "--component foo" in conanfile.command


def test_run_install_strip():
"""
Testing that the install/strip rule is called
Issue related: https://github.com/conan-io/conan/issues/14166
"""

settings = Settings.loads(get_default_settings_yml())
settings.os = "Linux"
settings.arch = "x86_64"
settings.build_type = "Release"
settings.compiler = "gcc"
settings.compiler.version = "11"

conanfile = ConanFileMock()

conanfile.conf = Conf()
conanfile.conf["tools.cmake.install:strip"] = True
sagi-ottopia marked this conversation as resolved.
Show resolved Hide resolved

conanfile.folders.generators = "."
conanfile.folders.set_base_generators(temp_folder())
conanfile.settings = settings
conanfile.folders.set_base_package(temp_folder())

write_cmake_presets(conanfile, "toolchain", "Unix Makefiles", {})
cmake = CMake(conanfile)
cmake.install()
assert "--strip" in conanfile.command