From 9208c7a7690ec3c79b7dbc2bb1de38cf6878ff00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6lfer?= Date: Wed, 27 Nov 2024 16:56:57 +0100 Subject: [PATCH] Fix uninitialized variable errors in FindPytest.cmake with -Werror=dev CMake reported uninitialized variable errors for `LD_LIBRARY_PATH` and `PYTHONPATH` when using `-Werror=dev --warn-uninitialized`, causing `pytest_discover_tests` to fail. --- cmake/FindPytest.cmake | 12 ++++++++++-- doc/release/release_notes.rst | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cmake/FindPytest.cmake b/cmake/FindPytest.cmake index ec58e35..341d697 100644 --- a/cmake/FindPytest.cmake +++ b/cmake/FindPytest.cmake @@ -71,8 +71,16 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest) endif() # Convert paths to CMake-friendly format. - cmake_path(CONVERT "$ENV{${LIBRARY_ENV_NAME}}" TO_CMAKE_PATH_LIST LIBRARY_PATH) - cmake_path(CONVERT "$ENV{PYTHONPATH}" TO_CMAKE_PATH_LIST PYTHON_PATH) + if(DEFINED ENV{${LIBRARY_ENV_NAME}}) + cmake_path(CONVERT "$ENV{${LIBRARY_ENV_NAME}}" TO_CMAKE_PATH_LIST LIBRARY_PATH) + else() + set(LIBRARY_PATH "") + endif() + if(DEFINED ENV{PYTHONPATH}) + cmake_path(CONVERT "$ENV{PYTHONPATH}" TO_CMAKE_PATH_LIST PYTHON_PATH) + else() + set(PYTHON_PATH "") + endif() # Prepend specified paths to the library and Python paths. if (_LIBRARY_PATH_PREPEND) diff --git a/doc/release/release_notes.rst b/doc/release/release_notes.rst index abc458a..391616f 100644 --- a/doc/release/release_notes.rst +++ b/doc/release/release_notes.rst @@ -4,6 +4,16 @@ Release Notes ************* +.. release:: Upcoming + + .. change:: fixed + + Updated scripts to prevent uninitialized variable errors when using `-Werror=dev + `_ + and `--warn-uninitialized + `_ + options. Thanks :github_user:`corrodedHash`! + .. release:: 0.11.3 :date: 2025-01-19