Is there any way to detect if the current scope has a parent?
I have a project that can either be a standalone project or a sub-project of another. To allow the sub
I think the most robust approach is to use the PARENT_DIRECTORY directory property.
This will yield the correct answer regardless of whether it's called before or after the project
command, and regardless of whether the parent and child both have the same project name.
get_directory_property(hasParent PARENT_DIRECTORY)
if(hasParent)
message(STATUS "Has a parent scope.")
else()
message(STATUS "Doesn't have a parent scope.")
endif()