@@ -45,6 +45,9 @@ def __init__(
4545
4646 self ._ensure_default_profiles ()
4747
48+ # Initialize cmake_binary with system default. It may be overridden during sync.
49+ self ._cmake_binary = 'cmake'
50+
4851 @staticmethod
4952 def features (directory : Path ) -> SupportedFeatures :
5053 """Queries conan support
@@ -149,8 +152,11 @@ def _run_conan_install(self, conanfile_path: Path, update: bool, build_type: str
149152 if build_type :
150153 command_args .extend (['-s' , f'build_type={ build_type } ' ])
151154
152- # Log the command being executed
153- logger .info ('Executing conan command: conan %s' , ' ' .join (command_args ))
155+ # Add cmake binary configuration if specified
156+ if self ._cmake_binary and self ._cmake_binary != 'cmake' :
157+ # Quote the path if it contains spaces
158+ cmake_path = f'"{ self ._cmake_binary } "' if ' ' in self ._cmake_binary else self ._cmake_binary
159+ command_args .extend (['-c' , f'tools.cmake:cmake_program={ cmake_path } ' ])
154160
155161 try :
156162 # Use reusable Conan API instance instead of subprocess
@@ -200,10 +206,28 @@ def sync_data(self, consumer: SyncConsumer) -> SyncData:
200206 """
201207 for sync_type in consumer .sync_types ():
202208 if sync_type == CMakeSyncData :
203- return self ._create_cmake_sync_data ( )
209+ return self ._sync_with_cmake ( consumer )
204210
205211 raise NotSupportedError (f'Unsupported sync types: { consumer .sync_types ()} ' )
206212
213+ def _sync_with_cmake (self , consumer : SyncConsumer ) -> CMakeSyncData :
214+ """Synchronize with CMake generator and create sync data.
215+
216+ Args:
217+ consumer: The CMake generator consumer
218+
219+ Returns:
220+ CMakeSyncData configured for Conan integration
221+ """
222+ # Extract cmake_binary from CMakeGenerator if available
223+ if isinstance (consumer , CMakeGenerator ) and not os .environ .get ('CMAKE_BINARY' ):
224+ # Only override if not already set from environment variable
225+ # Convert Path to string, or use 'cmake' if None
226+ cmake_path = consumer .data .cmake_binary
227+ self ._cmake_binary = str (cmake_path ) if cmake_path else 'cmake'
228+
229+ return self ._create_cmake_sync_data ()
230+
207231 def _create_cmake_sync_data (self ) -> CMakeSyncData :
208232 """Creates CMake synchronization data with Conan toolchain configuration.
209233
@@ -243,8 +267,11 @@ def publish(self) -> None:
243267 # Add build mode (build everything for publishing)
244268 command_args .extend (['--build' , 'missing' ])
245269
246- # Log the command being executed
247- logger .info ('Executing conan create command: conan %s' , ' ' .join (command_args ))
270+ # Add cmake binary configuration if specified
271+ if self ._cmake_binary and self ._cmake_binary != 'cmake' :
272+ # Quote the path if it contains spaces
273+ cmake_path = f'"{ self ._cmake_binary } "' if ' ' in self ._cmake_binary else self ._cmake_binary
274+ command_args .extend (['-c' , f'tools.cmake:cmake_program={ cmake_path } ' ])
248275
249276 # Run conan create using reusable Conan API instance
250277 # Change to project directory since Conan API might not handle cwd like subprocess
0 commit comments