Cannot have per config CTestCustom files

I would like to execute some scripts before starting ctest via the CTestCustom file and CTEST_CUSTOM_PRE_TEST. But I cannot differentiate between configurations meaning;

if I do “ctest -C RelWithDebInfo”, I would like to use either a config version of the file or CTEST_CUSTOM_PRE_TEST_ versions of the variables.

Maybe there is a way but I could not figure out.

I have found it, CMAKE_CONFIG_TYPE is set as an environment variable set by ctest executable, thus somebody can use the config based versions of commands. Documentation is a bit obscure, I had to dig in into the ctest source code to find it.

set(CTEST_CUSTOM_PRE_TEST doSomethingCommand_$ENV{CMAKE_CONFIG_TYPE}.py)