I've recently created a library that needs a non-text (but platform agnostic) resource to be used. I basically tell CMake, if this is an install interface, it's in the "${CMAKE_INSTALL_INCLUDEDIR}/resources" directory, otherwise it's in the "${CMAKE_CURRENT_SOURCE_DIR}/../resources" directory. Then I generate a header file with this path embedded into it (excerpt from "file_paths.h")
constexpr std::string_view resource_file_path = std::string_view{ "....some_path/to/resources" }; and include that header in the code that relies on loading said resource.
I thought all was well and good until after I packaged my library up for use in Vcpkg and it claimed
warning: There should be no absolute paths, such as the following, in an installed package: path_to_project\vcpkg\packages\my-package_x64-windows-static path_to_project\cmake-build-debug\vcpkg_installed path_to_project\vcpkg\buildtrees\my-package path_to_project\vcpkg\downloads Absolute paths were found in the following files: path_to_project\vcpkg\packages\my-package_x64-windows-static\include\my-package\file_paths.h What I'm trying to understand is if it's actually alright in my case. In my case, the absolute path only exists after VCPKG runs cmake. This wouldn't be an issue in a regular build, and shouldn't be an issue in VCPKG --download-only offline builds, since it will only generate the absolute path once you actually install the library, allowing for the whole vcpkg directory to move before build like normal. Making the path relative also doesn't change the fact the files are installed in a given location.
Should I be doing something else here or is generating a hardcoded path based on system parameters the correct move here?