How to use a cached variable in a toolchain file?

Hi, I am using a toolchain file for an Arm toolchain. It works fine. However, it specifies a certain compiler path which is true for developers, but incorrect for our CI system. Perhaps I should specify a second toolchain for the CI case, but that would mean I have to have a second set of presets that select the second toolchain. I would like one set of common presets and to use a separate cached variable to specify which compiler path entry in the toolchain file to use. That variable should assume a default value so that the developers don’t have to specify it.

So, in CMakeLists.txt I have:

set(Use_Arm_Dev_Studio_default ON)
option(Use_Arm_Dev_Studio “Use Arm Development Studio installation (ON), use Arm Compiler for Embedded installation (OFF)” “${Use_Arm_Dev_Studio_default}”)

and in the toolchain I have:

if (Use_Arm_Dev_Studio)
# Use Arm Development Studio installation (typically used by developers)
set(ARM_DEV_STUDIO_PATH “C:/Program Files/Arm/Development Studio”)
else ()
# paths for CI case
# snip
endif (Use_Arm_Dev_Studio)

The problem I have is that Use_Arm_Dev_Studio is not initialized in the default (unspecified case). So I have to generate the build files twice.

Can I initialize an option variable before the toolchain is used? Or is there a better way to do this?

In the CI system can you set an environment variable? Then you can use $ENV{var} in the if statement in the toolchain file.

Or you could setup the CI system to run cmake -DCI_settings=ON and use that in the if statement.

CI systems usually set CI or the like in the environment; the toolchain can detect this and do its different logic there.

Thank you both for your help.