Skip to content

Commit aba296c

Browse files
committed
Update plugin.py
1 parent 161472d commit aba296c

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

cppython/plugins/conan/plugin.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ def _run_conan_install(self, conanfile_path: Path, update: bool, build_type: str
165165
output_folder = self.core_data.cppython_data.build_path
166166
command_args.extend(['--output-folder', str(output_folder)])
167167

168-
# Override cmake_layout's default 'build' subfolder to normalize path structure
168+
# Normalize cmake_layout behavior across all platforms/generators:
169+
# - build_folder=. puts build output directly in output_folder (no 'build' subfolder)
170+
# - build_folder_vars=[] prevents build_type subfolders (Release/Debug)
171+
# This ensures generators always end up in output_folder/generators/ consistently
169172
command_args.extend(['-c', 'tools.cmake.cmake_layout:build_folder=.'])
173+
command_args.extend(['-c', 'tools.cmake.cmake_layout:build_folder_vars=[]'])
170174

171175
# Add build missing flag
172176
command_args.extend(['--build', 'missing'])
@@ -283,24 +287,9 @@ def _create_cmake_sync_data(self) -> CMakeSyncData:
283287
Returns:
284288
CMakeSyncData configured for Conan integration
285289
"""
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.
290-
build_type = self.data.build_types[0] if self.data.build_types else 'Release'
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 = (
296-
self.core_data.cppython_data.build_path / build_type / 'generators' / 'conan_toolchain.cmake'
297-
)
298-
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
290+
# With cmake_layout config overrides (build_folder=. and build_folder_vars=[]),
291+
# generators are always placed in build_path/generators/ regardless of platform/generator
292+
conan_toolchain_path = self.core_data.cppython_data.build_path / 'generators' / 'conan_toolchain.cmake'
304293

305294
return CMakeSyncData(
306295
provider_name=TypeName('conan'),

0 commit comments

Comments
 (0)