Why can't I configure a CMake target with CLion (Nothing to run on)?
Asked Answered
F

12

10

I'm struggling to run a program with CLion on Windows 10. It was working fine a couple weeks ago and the only thing I could think of that might have broken things is installing git.

As you can see from the below picture, the run button is greyed out and the run configuration says "Nothing to run on", which I'm guessing refers to the target.

enter image description here

What I've done So Far

I tried going through the steps outlined in the accepted answer of this question: How do I set up CLion to compile and run?

  • I installed MinGW in C:\MinGW
  • Added C:\MinGWand C:\MinGW\bin to the path
  • I've configured paths to my Environment, CMake, Make, C Compiler, and C++ Compiler

enter image description here

  • I've set my target & executable, but the only target I can choose is 'All targets'.

enter image description here

If I run this program through 'Run->Run...' and select the 'Wahum' run configuration, I get the following output in my Event Log:

Error running 'Wahum': Cannot run 'Wahum' on '<default>'
Frogman answered 2/3, 2020 at 3:45 Comment(0)
D
3

My setup was a little different, but I managed to make it work doing this:

  • Deleted the ".idea" file for the project.
  • Deleted all cmake files & folders for the project (cmake-build_xyz, CMakeLists, .clion.source.upload.marker, etc)
  • Deleted other cmake files found in parent directories (which I knew were not supposed to be used)
  • Created a new project "from the files" (of the project initial project)
  • Deleted any CMake Profile (Settings-> Build, Execution, Deployment->CMake)
  • Created a new CMake Profile.
  • Added the code back in the CMakeLists.txt
  • Reloaded the CMake.

A difference in my setup was that I was building on a remote computer (Linux) over SSH. So I had some entries in the "Deployment" section (Settings-> Build, Execution, Deployment-> Deployment). Therefore, I did the same thing on the target and the host to make sure that any conflicting while would not be synced on top of the "other file".

While looking for a solution, I did try to setup a dummy project using Microsoft Toolchains without any success.

Dag answered 17/3, 2021 at 15:51 Comment(0)
C
12

What worked for me is selecting the top CMakeList.txt file, right-clicking on it and selecting Load CMake Project from the context menu.

enter image description here

Carpogonium answered 1/10, 2021 at 8:9 Comment(0)
H
11

I have CLion 2020.2.1 and there is no import project option in the file menu.

my working solution:

File > Invalidate caches and restart

Hydracid answered 28/12, 2020 at 14:3 Comment(1)
Doesn't work for me on CLion 2020.3. "Invalidate caches and restart" is usually my "goto". I must add that i'm connecting ssh from Windows to a remote Linux.Dag
D
3

My setup was a little different, but I managed to make it work doing this:

  • Deleted the ".idea" file for the project.
  • Deleted all cmake files & folders for the project (cmake-build_xyz, CMakeLists, .clion.source.upload.marker, etc)
  • Deleted other cmake files found in parent directories (which I knew were not supposed to be used)
  • Created a new project "from the files" (of the project initial project)
  • Deleted any CMake Profile (Settings-> Build, Execution, Deployment->CMake)
  • Created a new CMake Profile.
  • Added the code back in the CMakeLists.txt
  • Reloaded the CMake.

A difference in my setup was that I was building on a remote computer (Linux) over SSH. So I had some entries in the "Deployment" section (Settings-> Build, Execution, Deployment-> Deployment). Therefore, I did the same thing on the target and the host to make sure that any conflicting while would not be synced on top of the "other file".

While looking for a solution, I did try to setup a dummy project using Microsoft Toolchains without any success.

Dag answered 17/3, 2021 at 15:51 Comment(0)
S
2

It seems to me that there is a valid CMakeLists.txt in your directory, however CLion is not finding it. This is probably happening because you have deleted/misplaced some files from your .idea directory. I'm not sure this is the optimal solution, but what has helped me in this situation is to re-import the project.

File-> Import Project... and select directory with your project.

You are going to get a warning message Directory '{dir}' already contains CMake project, go ahead and choose Open existing project, select Open in this window and after that CLion should recognize your CMakeList.txt again and run cmake (did for me at least).

Sava answered 3/3, 2020 at 18:51 Comment(1)
With CLion 2020.3, can't see the File->import Project .Dag
H
1

I delete the .cache cmake-build-debug/

and backup the CMakeLists.txt and then delete it.

and then add a new CMakeLists.txt for the project and copy the backup comment to it.

and now run the code. it work! Yeah

Hamulus answered 14/4, 2021 at 3:35 Comment(0)
E
1

For me, "File" -> "Reload CMake Project" did the trick.

Epiphyte answered 20/1, 2022 at 13:17 Comment(0)
M
0

In CLion 2020.1.3 I have found that switching targets and switching back seems to avoid a bug that causes "Nothing to run on" to appear next to what I presume is a valid target.

Mazer answered 23/7, 2020 at 16:14 Comment(0)
P
0

I had the same error message using CLion with Googletest when running a specific test: "Cannot run xyz on ". The above hints did not work for me.

What worked was to rename the test, run it, then rename back. Solved.

Papotto answered 25/2, 2021 at 7:55 Comment(0)
R
0

Try to add a new configuration using the "Custom Build Application" template instead of a "CMake Application", and select the custom target you created earlier as the Target.

Romanaromanas answered 25/2, 2021 at 15:0 Comment(0)
C
0

If you want to make new CMakeLists.txt, do the following.

Go to Tools --> CMake --> Unload CMake Project.

Then open any source file. It will suggest you create or load CMake file, just click on create a new file and select the source files that you want to include.

Conciliator answered 10/8, 2022 at 6:15 Comment(1)
While this did not solve my issue (PlatformIO doesn't seem to generate CMakeLists.txt or CMakeListsPrivate.txt at any point even though at some point these files started to exist and contain a header pointing out, that they are generated), it helped me configure CLion. Thank you.Fiume
G
0

close Clion------>delete CMakeLists.txt ------>open Clion,he will help you to generate a new CMakeLists.txt.

whether you have ever deteled or instead CMakeLists.txt? May Clion could not find the CMakeLists.txt, it's not your fault

Grad answered 3/10, 2022 at 15:27 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Stapleton
I
0

If there are no available targets (apart from "All Targets") the problem is probably that you are lacking a CMake Profile. (That you are even find yourself looking at the Run Configuration screen suggests this, since once a profile is created, this it is set up for you.)

Go to File -> Settings -> CMake and ensure you have a profile. Just click + and the rest should be autocompleted. Close the dialogue and after a few seconds your Run configuration should be added by itself:

file, settings, CMake

Note: As suggested by the other answers reinstalling all the things can work, because CLion prompts you to create a profile when you create your project (or if your project gets reset). In my experience I tend to "OK" this without thinking, ending up with the above issue, but using the File menu to get back to this dialogue is easier than deleting your data.

Incidentally answered 13/7, 2023 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.