How does the hash being computed when generating CLion/CMake build directory path

I get something like this for the generated build directory path: ~/.clion10/system/cmake/generated/abeb208d/abeb208d. The generated build dir is predetermined by CLion and cannot be modified by user (which is wrong to my opinion but that's another issue). My question is how does this "abeb208d" is being computed? I believe it is a hash value based on the source directory path. Since I cannot tell CLion to respect my choice of build directory path, I need to find an automated way in my helper script to find out where the hell CLion would decide to generate it. I know I can find it manually in the CLion IDE itself but this is not good enough. Any one knows the hash function?

Comment actions Permalink


The hash in the path is hex form of java.String.hashCode applied to the absolute path to the project.
Howewer we consider it an unspecified implementation detail, which could be changed any time in the future without a notice.
Could you please specify what are you planning to do with it?
If you give us more details we may suggest you some other solutions.

Comment actions Permalink

Thanks for your reply. I just quickly tested it and it worked. I need to find a way to determine where CLion would generate the build directory given a source directory because of a few reasons. One of them is that I need to fix the generated build directory due to CLion erroneously resolving my symlinks as reported in I want the fix to be done automatically with an external helper script (a Rakefile). Another reason is, occassionally I also would like to perform a build without actually launching the IDE. In the past when I used CMake directly to generate build dir for Eclipse or C::B or for other IDE, me and my helper script knew where exactly the build directory was and I had rake task that could cd into it and called "cmake --build" with all the options that I need. One more other reason is, my project is cross-platform. I am used to have one source dir and multiple build dirs (one for each target platform). Now I am forced by CLion to create multiple symlinks to my source dir instead so that I could fool CLion to create multiple build dirs as well. I use a local versioning system on the ".idea" directory in my source dir to switch between. It is not nice as I can only fool CLion to do cross-platform build one target platform at a time but it is better than nothing. So, knowing the hash function would help to know which build dir is for which (again without launching the IDE).


Please sign in to leave a comment.