Set CMAKE_* cache variables only when Eigen is a top-level project
What does this implement/fix?
Eigen's main CMakeLists.txt
currently sets CMAKE_*
cache variables without checking whether it is built as a top-level project or not. Setting these variables as a sub-project also sets them in the outer project's scope (if they were not previously set), possibly changing the build process of the outer project. Such behavior seems counter-intuitive and unexpected.
This MR makes Eigen first check if it is a top-level project and set CMAKE_*
cache variables only if it is.