Skip to content

Commit 161472d

Browse files
committed
f
1 parent 411cdae commit 161472d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cppython/plugins/conan/plugin.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,25 @@ def _create_cmake_sync_data(self) -> CMakeSyncData:
283283
Returns:
284284
CMakeSyncData configured for Conan integration
285285
"""
286-
# With cmake_layout, Conan creates a subfolder for each build type.
287-
# Use the first build type for the toolchain path.
286+
# With tools.cmake.cmake_layout:build_folder=. and --output-folder=build_path,
287+
# generators are placed in build_path/generators/ for multi-config generators (Windows)
288+
# or build_path/<build_type>/generators/ for single-config generators (Linux/Mac).
289+
# We check which path exists to handle both cases.
288290
build_type = self.data.build_types[0] if self.data.build_types else 'Release'
289-
conan_toolchain_path = (
291+
292+
# Try multi-config path first (Windows with Visual Studio)
293+
multiconfig_path = self.core_data.cppython_data.build_path / 'generators' / 'conan_toolchain.cmake'
294+
# Single-config path (Linux/Mac with Make/Ninja)
295+
singleconfig_path = (
290296
self.core_data.cppython_data.build_path / build_type / 'generators' / 'conan_toolchain.cmake'
291297
)
292298

299+
# Use whichever path exists, defaulting to multi-config for sync (before install runs)
300+
if singleconfig_path.exists():
301+
conan_toolchain_path = singleconfig_path
302+
else:
303+
conan_toolchain_path = multiconfig_path
304+
293305
return CMakeSyncData(
294306
provider_name=TypeName('conan'),
295307
toolchain_file=conan_toolchain_path,

tests/integration/examples/test_conan_cmake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _run_cmake_configure(cmake_binary: str) -> None:
5353
Args:
5454
cmake_binary: Path or command name for the CMake binary to use
5555
"""
56-
result = subprocess.run([cmake_binary, '--preset=default-release'], capture_output=True, text=True, check=False)
56+
result = subprocess.run([cmake_binary, '--preset=default'], capture_output=True, text=True, check=False)
5757
assert result.returncode == 0, f'CMake configuration failed: {result.stderr}'
5858

5959
@staticmethod

0 commit comments

Comments
 (0)