From c68977cffadf47d072e1c90903d5aee9a39541f9 Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Wed, 26 Aug 2020 12:20:42 -0500 Subject: cmake: Use relative path to Python lib location for Windows installer --- host/python/CMakeLists.txt | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'host/python') diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index 04e637f2e..dfe049b87 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -98,11 +98,23 @@ else() # Otherwise, use distutils to determine the correct relative path for Python # packages, and install to our prefix if(NOT DEFINED UHD_PYTHON_DIR) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "from distutils import sysconfig;\ - print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'));" - OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE - ) + if(WIN32) + # CPack with NSIS generates an error when using install() + # with a DESTINATION that is an absolute path. Thus, specify + # a blank prefix, which returns only the Python library relative + # path, and use that in the install step below. + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "from distutils import sysconfig;\ + print(sysconfig.get_python_lib(plat_specific=True, prefix=''));" + OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE + ) + else() + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "from distutils import sysconfig;\ + print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'));" + OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif(WIN32) endif(NOT DEFINED UHD_PYTHON_DIR) file(TO_CMAKE_PATH ${UHD_PYTHON_DIR} UHD_PYTHON_DIR) -- cgit v1.2.3