Issue
If my project has the following folder structure:
Project
├───build
├───images
├───include
├───Apps
├───Models
├───source
└───tests
what is the best way to make the folder "images" accessable to all .cpp files inside build, tests, apps and src without using the absolute path. So every image created inside this project should be saved to the "images" folder.
I am building with Cmake if this is important(started using CMake last week so no deep knowledge). Main CmakeLists.txt file is the the root folder. Tests, Apps and source each have their own CMakeLists.txt files and executables.
Every image will be created with the same class so I think I could use std::filesystem::current_path()
with a wrapper function inside the class which would generate and set the desired path but there should be another way.
I will also load files from the folder Models in the future, so the same problem.
Solution
If I am understanding your question correctly you want to access the images from the "images" folder, right? You should be thinking about the path from the point of the final executable and not the source files.
If the executable will be in the build directory then you simply need to write "../images", the 2 dots mean that you are going back 1 directory.
Answered By - badProgrammer0123456