I'm having issues with Clion (1.0.1) and CMakeLists.txt.
I use GitHub for my projects, and I commit them from directly within the IDE. If I then checkout the project on a different computer, the IDE looks for CMakeLists.txt in the original PC's directory.
The specific error message reported by Clion is this:
Error: CmakeLists.txt not found in C:\Users\Chris\ClionProjects\SDLTestClion
However, this is a Linux machine, so there's obviously no C drive.
Here's what I've tried:
I can't find anything else, so either I'm missing something or this is bugged in version 1.0.1 and I need to sift through project files to change the path that Clion looks for the CMakeLists.txt file.
Update: Wrote this answer 8 years ago and didn't know what I was doing. I see it occasionally getting upvotes, so I'm updating this.
Most likely you're a new git or version control user, or just a new developer in general. The proper solution is to not commit CLion's project files in the first place, but since you're here, you've probably already done so. Here's how you should remedy this problem and stop it from happening in the future:
Close CLion. Place an empty text file named .gitignore
in the project's root directory if you haven't already.
Add .idea
as a line in the file to ignore it. Most likely this is all you need to do, though I recommend taking the time to make sure you're not committing other files you shouldn't as well (*.iml
, *.iws
, *.o
, etc). See sample .gitignore
files here, here, and here.
If this is a shared project, it's worth making sure no other IDE project files are committed as well (Eclipse, Visual Studio, etc). Visual Studio is an edge case, as sometimes you actually want to commit those files depending on the project. See here for another sample ignore file. However, for a student project this is unlikely.
Run git add .gitignore
and git commit -m 'Updated .gitignore to exclude .idea directory
Remove the already committed .idea
directory with git rm --cached -r ./.idea
. If you have multiple things to remove from version control, run git rm --cached -r .
Run git add .
and git commit -m 'Removed items added to .gitignore'
. Push your changes to your remote git repository with git push
Navigate to your project's directory in your file browser and delete the .idea
directory.
Re-import the project in CLion and the .idea
directory will be rebuilt.
Remember you can re-use this .gitignore
file in any future projects. You can often just copy/paste it if it's the same language and IDE.
Old Answer:
Well, I found the issue. As far as I can tell, in version 1.0.1 there is no way to remedy the problem through the IDE.
Solution:
projectDir/.idea
misc.xml
PROJECT_DIR
to point to the directory with the project's CMakeLists.txt
.I think this is a bug and this field should probably be updated when choosing a new project root. A temporary solution may be to add misc.xml
to .gitignore
but I haven't tested this and don't know if this will cause other problems or if the IDE will automatically regenerate the file.