CMAKE_CURRENT_SOURCE_DIR (or a better option is usually CMAKE_CURRENT_LIST_DIR) refers to the current directory being processed - for CMAKE_CURRENT_LIST_DIR it will always refer to the directory containing that CMakeLists.txt file, whereas CMAKE_CURRENT_SOURCE_DIR may refer to a different location if you are using include(…)It seems CMAKE_CURRENT_SOURCE_DIR vs CMAKE_SOURCE_DIR is a matter of preference since you can add a relative path to either. It seems like it is somewhat personal preference. Correct me if I'm wrong.
CMAKE_SOURCE_DIR refers to the top level source directory passed to CMake - for example when running “cmake ..” it will be the “..” directory. This will differ from CMAKE_CURRENT_SOURCE_DIR in projects with subdirectories.
Generally I’d recommend using CMAKE_CURRENT_LIST_DIR to avoid confusion, as it’s guaranteed to always refer to the directory containing that CMakeLists.txt file
Statistics: Posted by will-v-pi — Thu Sep 12, 2024 7:53 am