Let's say I'm using CMake with a simple executable program that takes a string from a file (a resource), and prints it out. The file might be referenced using a line such as:
|
std::ifstream fileReader{ "resources/file.txt" };
|
In this example, there is a
resources
folder inside the
src
folder.
Now, in CMake, when I use the
install
command to install the executable (created by
add_executable
), I usually do it to
bin
(Meaning
CMAKE_INSTALL_DIR/bin
, on Linux this is usually
/usr/local/bin
). However, this leaves me confused about where to put these resource files. Since I obviously cannot change the file path that the
std::ifstream
line above uses, the only option that makes sense to me is to place the
resources
folder in the
bin
folder. However, since each application isn't restricted to its own folder in
bin
, couldn't this cause a possible name conflict, e.g if another application
also has a
resources
folder that it uses? On Windows this isn't a problem, since each application in
C:\Program Files
has its own folder, removing the problem itself. However, on Linux this isn't the case, since applications all share the same folder (AFAIK). Where should I put these resource files so that I can use them in the same way without causing any naming problems? (I hope my post was clear enough)