diff options
author | Steven Koo <steven.koo@ni.com> | 2022-04-15 11:57:55 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-04-19 09:38:47 -0700 |
commit | 9a15dcb61db8a6c9bcde51cf4929f0b5a6c4ee8f (patch) | |
tree | eecf703713bcadfb50153aabeb319c260902211b | |
parent | 2c8272079f0236bfa028d7cabae16704c5d176fb (diff) | |
download | uhd-9a15dcb61db8a6c9bcde51cf4929f0b5a6c4ee8f.tar.gz uhd-9a15dcb61db8a6c9bcde51cf4929f0b5a6c4ee8f.tar.bz2 uhd-9a15dcb61db8a6c9bcde51cf4929f0b5a6c4ee8f.zip |
utils: Check install-prefix for images
On some installs, pkg-path and install-prefix aren't equivalent. Since
uhd_images_downloader defaults to installing into
$CMAKE_INSTALL_PREFIX/share/uhd/images, we should look there too.
Signed-off-by: Steven Koo <steven.koo@ni.com>
-rw-r--r-- | host/lib/utils/paths.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 802dd5e5a..73b4cc25a 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -5,6 +5,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later // +#include <uhd/build_info.hpp> #include <uhd/config.hpp> #include <uhd/exception.hpp> #include <uhd/utils/log.hpp> @@ -290,7 +291,7 @@ std::string uhd::get_pkg_path(void) std::string uhd::get_lib_path(void) { fs::path runtime_libfile_path = boost::dll::this_line_location(); - //Normalize before decomposing path so result is reliable + // Normalize before decomposing path so result is reliable fs::path lib_path = runtime_libfile_path.lexically_normal().parent_path(); return lib_path.string(); } @@ -464,14 +465,16 @@ std::string uhd::get_images_dir(const std::string& search_paths) } } - /* Finally, check for the default UHD images installation path. */ - fs::path pkg_path = fs::path(uhd::get_pkg_path()) / "share" / "uhd" / "images"; - if (fs::is_directory(pkg_path)) { - return pkg_path.string(); - } else { - /* No luck. Return an empty string. */ - return std::string(""); + /* Finally, check for the default UHD images installation paths */ + for (auto& prefix : {uhd::get_pkg_path(), uhd::build_info::install_prefix()}) { + fs::path default_images_path = fs::path(prefix) / "share" / "uhd" / "images"; + if (fs::is_directory(default_images_path)) { + return default_images_path.string(); + } } + + /* No luck. Return an empty string. */ + return std::string(""); } std::string uhd::find_image_path( |