diff --git a/src/zint/scripts/cmake/find-packages-from-python.cmake b/src/zint/scripts/cmake/find-packages-from-python.cmake index 2212dae6..e18986f6 100644 --- a/src/zint/scripts/cmake/find-packages-from-python.cmake +++ b/src/zint/scripts/cmake/find-packages-from-python.cmake @@ -4,9 +4,17 @@ find_package(Python3 COMPONENTS Interpreter Development REQUIRED) execute_process( COMMAND ${Python3_EXECUTABLE} -m site --user-site OUTPUT_VARIABLE Python3_USERSITELIB - COMMAND_ERROR_IS_FATAL ANY + RESULT_VARIABLE EXIT_CODE ) -string(STRIP "${Python3_USERSITELIB}" Python3_USERSITELIB) +if (EXIT_CODE GREATER_EQUAL 2) + message(FATAL_ERROR "Unknown error getting user site-packages.") +endif() + +if (EXIT_CODE EQUAL 0) + string(STRIP "${Python3_USERSITELIB}" Python3_USERSITELIB) + list(APPEND CMAKE_PREFIX_PATH "${Python3_USERSITELIB}") +endif() + +list(APPEND CMAKE_PREFIX_PATH "${Python3_SITELIB}") message(STATUS "Appended ${Python3_SITELIB} and ${Python3_USERSITELIB} to the list of cmake prefixes") -list(APPEND CMAKE_PREFIX_PATH "${Python3_USERSITELIB}" "${Python3_SITELIB}")