CLion IDE macro for CMake
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.
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:
![code completion for environment variables in cmake files code completion for environment variables in cmake files](https://resources.jetbrains.com/help/img/idea/2024.2/cl_cmakeinvoke_completion.png)
Last modified: 26 May 2024