mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00

Define `PROJECT_IS_TOP_LEVEL` and `<PROJECT-NAME>_IS_TOP_LEVEL`. The latter is a STATIC cache entry just like other `<PROJECT-NAME>_*` variables so that it is globally scoped. Issue: #20310 Fixes: #21961
15 lines
677 B
CMake
15 lines
677 B
CMake
# only one project() call, includer already calls project(${RunCMake_TEST} NONE)
|
|
project(IsTopLevel NONE)
|
|
if(NOT DEFINED PROJECT_IS_TOP_LEVEL)
|
|
message(FATAL_ERROR "PROJECT_IS_TOP_LEVEL is not defined")
|
|
endif()
|
|
if(NOT DEFINED "CACHE{${RunCMake_TEST}_IS_TOP_LEVEL}")
|
|
message(FATAL_ERROR "${RunCMake_TEST}_IS_TOP_LEVEL is not defined")
|
|
endif()
|
|
if(NOT DEFINED CACHE{IsTopLevel_IS_TOP_LEVEL})
|
|
message(FATAL_ERROR "IsTopLevel_IS_TOP_LEVEL is not defined")
|
|
endif()
|
|
message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}")
|
|
message(STATUS "${RunCMake_TEST}_IS_TOP_LEVEL=${${RunCMake_TEST}_IS_TOP_LEVEL}")
|
|
message(STATUS "IsTopLevel_IS_TOP_LEVEL=${IsTopLevel_IS_TOP_LEVEL}")
|