mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-26 00:20:06 -06:00
This implements a limited exception mechanism for find_package() via the UNWIND_INCLUDE keyword. When package discovery via find_package(UNWIND_INCLUDE) fails the StateSnapshot is updated to an UNWINDING state. In this state further calls to find_package() and include() are forbidden. While in the UNWINDING state, the include() command immediately calls SetReturnInvoked() whenever it is reached. The UNWINDING state is reset when a parent call to find_package() is reached. Fixes: #26897
21 lines
384 B
CMake
21 lines
384 B
CMake
cmake_policy(SET CMP0140 NEW)
|
|
|
|
function(f)
|
|
find_package(foo UNWIND_INCLUDE)
|
|
endfunction()
|
|
|
|
function(g)
|
|
set(FUNC_CALLED true)
|
|
set(PrimaryUnwind_FOUND false)
|
|
return(PROPAGATE func_called PrimaryUnwind_FOUND)
|
|
endfunction()
|
|
|
|
set(RunCMake_TEST_FAILED "Failed to observe side effects of function() calls during unwind")
|
|
|
|
f()
|
|
g()
|
|
|
|
if(FUNC_CALLED)
|
|
set(RunCMake_TEST_FAILED)
|
|
endif()
|