I'm striving to understand how to create / modify a global variable (whose prefix is not <PACKAGE>_
) from within a Find<package>.cmake
file, so that it can be shared among different modules and reused by the global CMakeLists.txt
.
Let's say I have a FindMyModule.cmake
file:
set (MyModule_include_dirs "...") # <-- This is visible from CMakeLists.txt caller
set (LIBS_INCLUDE_DIRS "${LIBS_INCLUDE_DIRS} ${MyModule_include_dirs}") <-- This is not
In CMakeLists.txt
find_package(MyModule)
message("My Module include dirs: "${MyModule_include_dirs}) # <-- Prints "My Module include dirs: ..."
message("Libs include dirs: " ${LIBS_INCLUDE_DIRS}) # <-- Prints "Libs include dirs: "
Googling and so-ing around, I've tried CACHE
, INTERNAL
and PARENT_SCOPE
but no successful result so far.