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

Add tool configuration to specify CMake executable path (#12701) #13940

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion conan/tools/cmake/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, conanfile):
self._toolchain_file = configure_preset.get("toolchainFile")
self._cache_variables = configure_preset["cacheVariables"]

self._cmake_program = "cmake" # Path to CMake should be handled by environment
self._cmake_program = conanfile.conf.get("tools.cmake:cmake_program", default="cmake")

def configure(self, variables=None, build_script_folder=None, cli_args=None):
"""
Expand Down
1 change: 1 addition & 0 deletions conans/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"tools.cmake.cmaketoolchain:system_processor": "Define CMAKE_SYSTEM_PROCESSOR in CMakeToolchain",
"tools.cmake.cmaketoolchain:toolset_arch": "Toolset architecture to be used as part of CMAKE_GENERATOR_TOOLSET in CMakeToolchain",
"tools.cmake.cmake_layout:build_folder_vars": "Settings and Options that will produce a different build folder and different CMake presets names",
"tools.cmake:cmake_program": "Path to CMake executable",
"tools.files.download:retry": "Number of retries in case of failure when downloading",
"tools.files.download:retry_wait": "Seconds to wait between download attempts",
"tools.gnu:make_program": "Indicate path to make program",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def conanfile():
return c


def test_cmake_cmake_program(conanfile):
mycmake = "C:\\mycmake.exe"
conanfile.conf.define("tools.cmake:cmake_program", mycmake)

with mock.patch("platform.system", mock.MagicMock(return_value='Windows')):
write_cmake_presets(conanfile, "the_toolchain.cmake", "MinGW Makefiles", {})

cmake = CMake(conanfile)
assert cmake._cmake_program == mycmake


def test_cmake_make_program(conanfile):
def run(command):
assert '-DCMAKE_MAKE_PROGRAM="C:/mymake.exe"' in command
Expand All @@ -42,4 +53,3 @@ def run(command):

cmake = CMake(conanfile)
cmake.configure()