In CMAKE, it defines the following variables to indicate the directories of files:
CMAKE_CURRENT_LIST_DIR
CMAKE_CURRENT_BINARY_DIR
CMAKE_CURRENT_SOURCE_DIR
They are useful when you process CMake scripts. However, none of them can tell you the directory where MACROs or functions are defined. Give the following example CMakeLists.txt to illustrate my question
project(Hello)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/my_macro.cmake)
test_macro()
Then for the my_macro.cmake, we have definitions for test_macro()
:
macro(test_macro)
message("hello")
#?? Can we know the folder of this macro is located?
#?? the macro definition file's location
endmacro()