# Cannot have per config CTestCustom files

**URL:** https://discourse.cmake.org/t/cannot-have-per-config-ctestcustom-files/11152
**Category:** Usage
**Tags:** gen:ninja, tool:ctest
**Created:** [July 2, 2024, 8:24am UTC](https://discourse.cmake.org/t/cannot-have-per-config-ctestcustom-files/11152 "2024-07-02T08:24:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmet\_Bilgili](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ahmet_bilgili/32/4717_2.png) [@Ahmet\_Bilgili](https://discourse.cmake.org/u/Ahmet_Bilgili)
#### Post date: [July 2, 2024, 8:24am UTC](https://discourse.cmake.org/t/cannot-have-per-config-ctestcustom-files/11152/1 "2024-07-02T08:24:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Ahmet\_Bilgili](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ahmet_bilgili/32/4717_2.png) [@Ahmet\_Bilgili](https://discourse.cmake.org/u/Ahmet_Bilgili)
#### Post date: [July 20, 2024, 1:40pm UTC](https://discourse.cmake.org/t/cannot-have-per-config-ctestcustom-files/11152/2 "2024-07-20T13:40:45Z")

</div>

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)`
