Skip to content

Commit

Permalink
Add tool configuration to specify CMake executable path (#12701) (#13940
Browse files Browse the repository at this point in the history
)

Also, add a unit test for the new configuration item.
  • Loading branch information
iskunk authored May 24, 2023
1 parent c6c50e1 commit 1e4c4d9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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()

0 comments on commit 1e4c4d9

Please sign in to comment.