113 EndOfConfigurationHook

This is a hack to ensure cedaRunXcppOnWorkspace() is called exactly at the end of the configure step. It involves watching the variable CMAKE_BACKWARDS_COMPATIBILITY which happens to be accessed at this time.

It is a little fragile, it is important to be sure nothing else accesses CMAKE_BACKWARDS_COMPATIBILITY.

See Execute command or macro in CMake as the last step before the 'configure' step finishes on stackoverflow.

Towards the end of the configuring process, after all commands in the CMakeLists.txt file have been processed, CMake checks the value of CMAKE_BACKWARDS_COMPATIBILITY. If this variable is being watched via the variable_watch command, then it will be triggered here.


set_property(GLOBAL PROPERTY GP_CEDA_HAS_CONFIGURED_XCPP FALSE)

function(EndOfConfigurationHook Variable Access)
    if(${Variable} STREQUAL CMAKE_BACKWARDS_COMPATIBILITY AND (${Access} STREQUAL UNKNOWN_READ_ACCESS OR ${Access} STREQUAL READ_ACCESS))
        get_property(v GLOBAL PROPERTY GP_CEDA_HAS_CONFIGURED_XCPP)
        if (NOT ${v})
            cedaRunXcppOnWorkspace()
            set_property(GLOBAL PROPERTY GP_CEDA_HAS_CONFIGURED_XCPP TRUE)
        endif()
    endif()
endfunction()

variable_watch(CMAKE_BACKWARDS_COMPATIBILITY EndOfConfigurationHook)

This hack doesn't work in CMake 3.17 onwards

There was a dependency bug when using cmake 3.17 onwards, so for a while we were stuck using cmake 3.16, but this is now fixed, by not using this hack.