In some cases, you may want a CMake script to detect whether it is being called from CLion or another instance like console. For this, use the special environment variable CLION_IDE. This variable is platform-independent and is only TRUE when CMake generation or build is invoked from CLion.
tip
There is also a preprocessor macro __CLION_IDE__ that helps avoid IDE freezes during the parsing of some intricate preprocessor code blocks. With this macro, you can eliminate such problematic definitions or includes from your code and replace them with dummy ones.
__CLION_IDE__ macro affects parsing only.
Using the CLION_IDE variable, you can set specific paths (for example, customize build directories), execute additional scripts, or add extra logging.
Placing this variable into your CMake code is easy with the environment variables completion available for CMakeLists.txt files: