What I want to do is to create a CMakeLists.txt
that defines a convenience macro to use in parent scope. I can use the macro just fine. However, I used the ${
You have to transfer CMAKE_CURRENT_LIST_DIR outside the macro into another variable or - in your case - a user defined global property:
set_property(GLOBAL PROPERTY DoStuffPath "${CMAKE_CURRENT_LIST_DIR}")
macro(do_stuff)
get_property(_my_marcros_file GLOBAL PROPERTY DoStuffPath)
message("This CMakeLists.txt file is in ${_my_marcros_file}")
endmacro()
That also works when the macros are defined in a file added with include().
References
Use CMAKE_SOURCE_DIR to get a path to outermost parent CMakeLists.txt.