CLion startup/loading new project causes toolchain issues.

Answered

Hi,

Forgive me for not being specific with the question but this has been driving me up the wall now.

Basically i am using CLion as my IDE for multiple different projects.

These are OS/Platform specific so some projects are only for Visual studio toolchain and some require WSL toolchains.

However everytime i start CLion or load a different project that uses a different toolchain via CMakePresets.json

I always get weird errors.

For example:

When loading a project with CmakePresets of “Visual Studio”
It fails to build the project the first time everytime until i manually reload CMake project.

And for a project with the toolchain specified in the vendor of CMakePresets.json to WSL:

I get this:
C:\Users\Alex\AppData\Local\Programs\CLion\bin\cmake\win\x64\bin\cmake.exe --build F:\Projects\Shellcore\Repos\Athena\Athena\build --target athena-kernel --config Debug -j 30
CMake Error: The current CMakeCache.txt directory F:/Projects/Shellcore/Repos/Athena/Athena/build/CMakeCache.txt is different than the directory /mnt/f/Projects/Shellcore/Repos/Athena/Athena/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
no such file or directory
CMake Error: Generator: build tool execution failed, command was: /usr/bin/ninja -j 30 -f build-Debug.ninja athena-kernel

At first i had WSL as the default toolchain in CLion because i was mainly compiling linux elf files but now im using CLion for windows projects too i was getting the same CMakeCache directory error on a windows project.

Forgive me if this is a lot of text but im at my limit of patience now and cannot understand why this happens.

Thanks

0
5 comments

Hello!

You can set a specific CLion toolchain in a configure preset - https://www.jetbrains.com/help/clion/cmake-presets.html#set-toolchain. Does it help?

0

Hi Anna,

 

Unfortunatley not,

 

I have a CMakePreset already for these projects.

 

No matter what happens i always get this error if i try to build when first loading the project.

 

It always requires me to Right click and “Reload CMake project”.

 

My CMakePresets is as follows:

 

For WSL project:

{
    "version": 6,
    "configurePresets": [
        {
            "name": "multi",
            "generator": "Ninja Multi-Config",
            "binaryDir": "${sourceDir}/build",
            "cacheVariables": {
                "CMAKE_CONFIGURATION_TYPES": "Debug;Release",
                "TARGET_FW_VERSION": "900"
            },
            "vendor": {
                "jetbrains.com/clion": {
                    "toolchain": "WSL"
                }
            }
        }
    ],
    "buildPresets": [
        {
            "name": "debug",
            "displayName": "Debug",
            "configurePreset": "multi",
            "configuration": "Debug"
        },
        {
            "name": "release",
            "displayName": "Release",
            "configurePreset": "multi",
            "configuration": "Release"
        }
    ]
}

And for the Visual Studio MSBuild compiled project:

{
  "version": 6,
  "configurePresets": [
    {
      "name": "multi",
      "generator": "Ninja Multi-Config",
      "binaryDir": "build",
      "installDir": "build/install",
      "vendor": {
        "jetbrains.com/clion": {
          "toolchain": "Visual Studio"
        }
      }
    }
  ],
  "buildPresets": [
    {
      "name": "debug",
      "displayName": "Debug",
      "configurePreset": "multi",
      "configuration": "Debug"
    },
    {
      "name": "release",
      "displayName": "Release",
      "configurePreset": "multi",
      "configuration": "RelWithDebInfo"
    }
  ]
}
0

Alexboulton2013, let's start with the WSL project.

  1. When you open the project in CLion, what do you see in the CMake tool window (View | Tool Windows | CMake)? Please provide the entire output from it.
  2. Please provide a screenshot of File | Settings | Build, Execution, Deployment | CMake when this project is opened in CLion.
0

Hi Anna,

Here is the output of the CMake Window:

/usr/bin/cmake --preset multi -S /mnt/f/Projects/Shellcore/Repos/Athena/Athena -B /mnt/f/Projects/Shellcore/Repos/Athena/Athena/build
Preset CMake variables:
 CMAKE_CONFIGURATION_TYPES="Debug;Release"
 TARGET_FW_VERSION="900"
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building for PS4 version: 900
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.3")  
-- /mnt/f/Projects/Shellcore/Repos/Athena/Athena/build
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Treating athena-common as a STATIC library
-- Configuring done (14.5s)
-- Generating done (1.1s)
-- Build files have been written to: /mnt/f/Projects/Shellcore/Repos/Athena/Athena/build
[Previous CMake output restored: 04/02/2026 07:09]

 

And the screenshot of the CMake from Settings:
 

 

When building after opening this is the output i receive:

====================[ Build | athena-kernel | multi - debug ]===================
C:\Users\Alex\AppData\Local\Programs\CLion\bin\cmake\win\x64\bin\cmake.exe --build F:\Projects\Shellcore\Repos\Athena\Athena\build --target athena-kernel --config Debug -j 30
CMake Error: The current CMakeCache.txt directory F:/Projects/Shellcore/Repos/Athena/Athena/build/CMakeCache.txt is different than the directory /mnt/f/Projects/Shellcore/Repos/Athena/Athena/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
no such file or directory
CMake Error: Generator: build tool execution failed, command was: /usr/bin/ninja -j 30 -f build-Debug.ninja athena-kernel

Once i reload cmake project all works perfectly fine.

0

Has anyone managed to replicate this issue?

Im curious if anyone else has thi9s issue as i dont remember it doing it before an update but dont remember when.

0

Please sign in to leave a comment.