Skip to content

Commit 6d3d2cd

Browse files
authored
fix: unused prefix warning (#272)
This warning is showing up, fix by moving the setting into -C. --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 16f8984 commit 6d3d2cd

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

src/scikit_build_core/cmake.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,24 @@ def init_cache(
131131
f.write(f'set({key} [===[{str_value}]===] CACHE PATH "" FORCE)\n')
132132
else:
133133
f.write(f'set({key} [===[{value}]===] CACHE STRING "" FORCE)\n')
134+
135+
if self.module_dirs:
136+
# Convert to CMake's internal path format, otherwise this breaks try_compile on Windows
137+
module_dirs_str = ";".join(map(str, self.module_dirs)).replace(
138+
"\\", "/"
139+
)
140+
f.write(
141+
f'set(CMAKE_MODULE_PATH [===[{module_dirs_str}]===] CACHE PATH "" FORCE)\n'
142+
)
143+
144+
if self.prefix_dirs:
145+
prefix_dirs_str = ";".join(map(str, self.prefix_dirs)).replace(
146+
"\\", "/"
147+
)
148+
f.write(
149+
f'set(CMAKE_PREFIX_PATH [===[{prefix_dirs_str}]===] CACHE PATH "" FORCE)\n'
150+
)
151+
134152
contents = self.init_cache_file.read_text(encoding="utf-8").strip()
135153
logger.debug(
136154
"{}:\n{}",
@@ -148,7 +166,7 @@ def _compute_cmake_args(
148166
yield f"-C{self.init_cache_file}"
149167

150168
if self.single_config and self.build_type:
151-
yield f"-DCMAKE_BUILD_TYPE={self.build_type}"
169+
yield f"-DCMAKE_BUILD_TYPE:STRING={self.build_type}"
152170

153171
for key, value in defines.items():
154172
if isinstance(value, bool):
@@ -160,15 +178,6 @@ def _compute_cmake_args(
160178
else:
161179
yield f"-D{key}={value}"
162180

163-
if self.module_dirs:
164-
# Convert to CMake's internal path format, otherwise this breaks try_compile on Windows
165-
module_dirs_str = ";".join(map(str, self.module_dirs)).replace("\\", "/")
166-
yield f"-DCMAKE_MODULE_PATH:PATH={module_dirs_str}"
167-
168-
if self.prefix_dirs:
169-
prefix_dirs_str = ";".join(map(str, self.prefix_dirs)).replace("\\", "/")
170-
yield f"-DCMAKE_PREFIX_PATH:PATH={prefix_dirs_str}"
171-
172181
def configure(
173182
self,
174183
*,

tests/test_cmake_config.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@ def configure_args(config: CMaker, *, init: bool = False) -> Generator[str, None
2222
yield f"-C{cmake_init}"
2323

2424
if config.single_config:
25-
yield f"-DCMAKE_BUILD_TYPE={config.build_type}"
26-
27-
if config.module_dirs:
28-
yield "-DCMAKE_MODULE_PATH:PATH={}".format(
29-
";".join(str(p).replace("\\", "/") for p in config.module_dirs)
30-
)
31-
32-
if config.prefix_dirs:
33-
yield "-DCMAKE_PREFIX_PATH:PATH={}".format(
34-
";".join(str(p).replace("\\", "/") for p in config.prefix_dirs)
35-
)
25+
yield f"-DCMAKE_BUILD_TYPE:STRING={config.build_type}"
3626

3727

3828
@pytest.mark.configure()

tests/test_custom_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
def test_ep(isolated):
1010
isolated.install("hatchling", "scikit-build-core[pyproject]")
1111
isolated.install(PROJECT_DIR / "extern", isolated=False)
12-
isolated.install(PROJECT_DIR, isolated=False)
12+
isolated.install(PROJECT_DIR, "-v", isolated=False)
1313
# Needs script fix: assert isolated.run("script1") == ""

0 commit comments

Comments
 (0)