I try to rename my project from encoding to Tutorial, but after I refactor directory name, it comes out an error, like:
Error: CMakeLists.txt not found in D:\code\encoding
I find that files in .idea
directory don't change automatically, they are still encoding.iml
, encodings.xml
.
In the C/C++ Projects view, right-click a project, and select Rename. The edit box is activated for the selected project. Type a new name. Press Enter.
A single line of the current project name is displayed. Change it and save it. If the .name file is not present, create it, then add a single line of text with the desired name. Now reopen CLion and the project name has changed. Show activity on this post.
Clear the Rename associated file checkbox if don't want CLion to rename the associated files with the same name. Change the refactoring scope in the corresponding field if needed.
If the project is not open, select the project in Design Center’s Projects page, and then click the Edit icon in the top-right corner of the page. If the project is open. click the gear icon in API Designer’s top-right corner and then select Rename.
If your project is file based, you cannot rename the project from within IDEA. Convert your project to a directory based format, and then you will have the option to rename it under "File > Project Structure > Project > Project Name". 3. Go to file > project stricture > Project> Project-name: new-name-project 4. Apply and restart Intellij
In the project folder, cd
to the .idea
directory. Locate the .name
file and open it for editing. A single line of the current project name is displayed. Change it and save it.
If the .name
file is not present, create it, then add a single line of text with the desired name.
Now reopen CLion and the project name has changed.
When using CLion with CMake, the project name is set by the project
command inside the CMakeLists.txt.
Look for a line like the following and change "my_project_name" to the CLion project name you want.
project(my_project_name)
Then reload the file using Tools >> CMake >> Reload CMake Project or, if present, by clicking on Reload changes in the yellow bar across the top of the CMakeLists.txt
editor window.
Note, if you use New Cmake Project From Sources... to create your project, then CLion generates the CMakeLists.txt
at that time including a project command using the directory name. It is fine to edit CMakeLists.txt
after it is generated, including changing the project name.
On Mac:
If your are running Clion on a Mac, all you have to do is rename the directory that contains your .cpp and .h and CMake files then in Clion go to open then to the new name of the directory and Clion automatically figures everything else out.
That is what I did. However before you open the new project which is the project you renamed. Clion will create a project directory with the original name and it will be blank so you will have to Delete that directory.
However, if you are using windows or other machines it may not be the same. Because, now that i look, i don't have and .idea file.
Now that i think about it. Maybe this is a new feature since the new update. I am not sure when the new update for jetbrain IDEs was released. So, maybe that is a new feature that was not around at the time of your original post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With