How to get the path to the currently included cmake file in a function?

Viewed 1592

suppose I have this:

#root/CMakeLists.txt
include(folder/file.cmake)
foo()

and

#root/folder/file.cmake
function(foo)
    message(${SOME_SPECIAL_CMAKE_VARIABLE})
endfunction()

And I want to get path/to/root/folder printed. I tried these 2 but they don't get me what I want: CMAKE_CURRENT_LIST_DIR or CMAKE_CURRENT_SOURCE_DIR.

So is there a cmake variable that will get me what I want?

Or is there a way to get the full path to file.cmake so I can atleast get it's path that way?

1 Answers
Related