In CMake, you can convert relative paths to absolute paths using
get_filename_component(ABSOLUTE_PATH ${RELATIVE_PATH} ABSOLUTE)
However, paths such as ../../other_program/ are based on the source directory (i.e., the directory where the CMakeLists.txt files are located) and not the build directory (i.e. the directory from which cmake is called). This can lead to some confusion if you specify a relative path as a command line parameter.
Is there a way to tell get_filename_component that it should base the relative path on the current binary directory instead of the current source directory?
cmake
Julian Helfferich
source share