We have Build Presets that use a Docker Toolchain to build Linux code on a Mac. When opening the project the first time, it runs cmake in the docker container and then when you build the projects, it executes:
/usr/bin/cmake --build ..... (correctly in the docker container)
If you close CLion, start it again and open the project, make a change and compile, then instead of calling cmake in the docker, it calls the local version. In the build view, you can see the following:
====================[ Build | TestingEngine | Linux Clang Debug ]===============
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/...../build/linux-clang-debug --target TestingEngine
CMake Error: The current CMakeCache.txt directory /Users/...../build/linux-clang-debug/CMakeCache.txt is different than the directory /tmp/..../build/linux-clang-debug 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: execution of make failed. Make command was: /usr/bin/ninja TestingEngine &&
If you reload CMake in the CMake Tool Window, this solves the problem, but you have to recompile everything.
I found a workaround that needs less time. You can go to the Preferences->Build->CMake and enable or disable another profile without disabling the profile that uses the docker toolchain. After turning back CMake reruns as well, but it does not have to compile everything again. The object files don't seem to be deleted like if you reload the CMake settings in the CMake Tool Window.
When testing the same with a small hello world project, it works perfectly. Is this a bug or do we have a misconfiguration somewhere?