Skip to content

Commit 0aca2f9

Browse files
committed
Update Chore
1 parent ece534c commit 0aca2f9

File tree

7 files changed

+161
-140
lines changed

7 files changed

+161
-140
lines changed

cppython/plugins/cmake/builder.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ def __init__(self) -> None:
1919

2020
@staticmethod
2121
def generate_cppython_preset(
22-
cppython_preset_directory: Path, provider_preset_file: Path, provider_data: CMakeSyncData
22+
cppython_preset_directory: Path,
23+
provider_preset_file: Path,
24+
provider_data: CMakeSyncData,
25+
project_root: Path,
2326
) -> CMakePresets:
2427
"""Generates the cppython preset which inherits from the provider presets
2528
2629
Args:
2730
cppython_preset_directory: The tool directory
2831
provider_preset_file: Path to the provider's preset file
2932
provider_data: The provider's synchronization data
33+
project_root: The project root directory (where CMakeLists.txt is located)
3034
3135
Returns:
3236
A CMakePresets object
@@ -43,7 +47,8 @@ def generate_cppython_preset(
4347
)
4448

4549
if provider_data.toolchain_file:
46-
default_configure.toolchainFile = provider_data.toolchain_file.as_posix()
50+
relative_toolchain = provider_data.toolchain_file.relative_to(project_root, walk_up=True)
51+
default_configure.toolchainFile = relative_toolchain.as_posix()
4752

4853
configure_presets.append(default_configure)
4954

@@ -55,20 +60,24 @@ def generate_cppython_preset(
5560

5661
@staticmethod
5762
def write_cppython_preset(
58-
cppython_preset_directory: Path, provider_preset_file: Path, provider_data: CMakeSyncData
63+
cppython_preset_directory: Path,
64+
provider_preset_file: Path,
65+
provider_data: CMakeSyncData,
66+
project_root: Path,
5967
) -> Path:
6068
"""Write the cppython presets which inherit from the provider presets
6169
6270
Args:
6371
cppython_preset_directory: The tool directory
6472
provider_preset_file: Path to the provider's preset file
6573
provider_data: The provider's synchronization data
74+
project_root: The project root directory (where CMakeLists.txt is located)
6675
6776
Returns:
6877
A file path to the written data
6978
"""
7079
generated_preset = Builder.generate_cppython_preset(
71-
cppython_preset_directory, provider_preset_file, provider_data
80+
cppython_preset_directory, provider_preset_file, provider_data, project_root
7281
)
7382
cppython_preset_file = cppython_preset_directory / 'cppython.json'
7483

cppython/plugins/cmake/plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ def sync(self, sync_data: SyncData) -> None:
6666

6767
cppython_preset_file = self._cppython_preset_directory / 'CPPython.json'
6868

69+
project_root = self.core_data.project_data.project_root
70+
6971
cppython_preset_file = self.builder.write_cppython_preset(
70-
self._cppython_preset_directory, cppython_preset_file, sync_data
72+
self._cppython_preset_directory, cppython_preset_file, sync_data, project_root
7173
)
7274

7375
self.builder.write_root_presets(

cppython/plugins/conan/builder.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(self) -> None:
124124
def _create_conanfile(conan_file: Path, dependencies: list[ConanDependency], name: str, version: str) -> None:
125125
"""Creates a conanfile.py file with the necessary content."""
126126
template_string = """
127+
import os
127128
from conan import ConanFile
128129
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
129130
from conan.tools.files import copy
@@ -154,7 +155,10 @@ def package(self):
154155
cmake.install()
155156
156157
def package_info(self):
157-
self.cpp_info.libs = ["${name}"]
158+
# Use native CMake config files to preserve FILE_SET information for C++ modules
159+
# This tells CMakeDeps to skip generating files and use the package's native config
160+
self.cpp_info.set_property("cmake_find_mode", "none")
161+
self.cpp_info.builddirs = ["."]
158162
159163
def export_sources(self):
160164
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)

examples/conan_cmake/library/test_package/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
cmake_minimum_required(VERSION 4.0)
22

3+
# Enable std module support for MSVC - MUST be before project()
4+
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
5+
36
project(MathUtilsConsumer LANGUAGES CXX)
47

58
set(CMAKE_CXX_STANDARD 23)
69
set(CMAKE_CXX_STANDARD_REQUIRED ON)
10+
set(CMAKE_CXX_MODULE_STD ON)
711

812
find_package(mathutils REQUIRED)
913

0 commit comments

Comments
 (0)