diff --git a/tests/test_install_deps_policy.py b/tests/test_install_deps_policy.py new file mode 100644 index 0000000..b5b658e --- /dev/null +++ b/tests/test_install_deps_policy.py @@ -0,0 +1,17 @@ +from pathlib import Path + + +def test_install_deps_sets_cmp0207_before_runtime_dependency_scan( + top_level_dir: Path, +): + template = ( + top_level_dir + / "vtk_sdk_python_wheel_helper" + / "install-deps.cmake.in" + ).read_text(encoding="utf-8") + + policy_position = template.index("cmake_policy(SET CMP0207 NEW)") + runtime_deps_position = template.index("file(GET_RUNTIME_DEPENDENCIES") + + assert "if(POLICY CMP0207)" in template + assert policy_position < runtime_deps_position diff --git a/vtk_sdk_python_wheel_helper/install-deps.cmake.in b/vtk_sdk_python_wheel_helper/install-deps.cmake.in index f532b2e..db74ff5 100644 --- a/vtk_sdk_python_wheel_helper/install-deps.cmake.in +++ b/vtk_sdk_python_wheel_helper/install-deps.cmake.in @@ -1,3 +1,7 @@ +if(POLICY CMP0207) + cmake_policy(SET CMP0207 NEW) +endif() + file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR resolved_deps UNRESOLVED_DEPENDENCIES_VAR unresolved_deps