Hello,
is there any option perhaps to set a DEFER
CALL
in the scope of the
directory that will be added with add_subdirectory()
? Or if there is any other
way to “inject” some CMake module or code into the scope of the
add_subdirectory()
?
Because, I’m adding a various number of project extensions with
add_subdirectory()
and trying to do as little code repeating inside the
extension’s CMakeLists.txt
:
function(foo_deferred_call)
message(
STATUS
"This should be called in the extension scope: ${CMAKE_CURRENT_SOURCE_DIR}"
)
configure_file(config.h.in config.h)
endfunction()
foreach(extension ${extensions})
cmake_language(DEFER DIRECTORY ${extension} CALL foo_deferred_call)
add_subdirectory(${extension})
endforeach()
Issue is that for the DEFER
CALL
the directory must be known to CMake
otherwise the error pops up:
cmake_language DEFER DIRECTORY
/path/to/ext/extension_name...
is not known. It may not have been processed yet.
Thank you for any possible hints or tips.