Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting build target in CLion

Tags:

c++

clion

I'm trying to set up CLion (windows 8.1, 64-bit, using cygwin and not mingw), and I'm trying to compile+run a project, but I don't know what to do here:

enter image description here

It says I need a Target and a Configuration, but there're none in the dropdown. Is there a configuration step I missed?

like image 206
hintss Avatar asked Jan 06 '15 15:01

hintss


People also ask

How do I set environment variables in CLion?

Environment variables You can pass additional environment variables to CMake generation and build via the Environment field of the CMake Settings dialog (navigate to Settings / Preferences | Build, Execution, Deployment | CMake). or pressing Shift+Enter , and set the Include system environment variables checkbox.

How do you build a project in CLion?

Create a new projectIf no project is currently opened in CLion, click New Project on the Welcome screen. Otherwise, select File | New Project on the main menu. In the New Project dialog that opens, select the target type of your project (executable or library), and the language to be used (pure C or C++).

How do I change configurations in CLion?

From the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog, select a configuration where you want to add the environment variables.

What is a build target?

A build target is a string that identifies a build rule in your project. Build targets are used as arguments to Buck commands, such as buck build and buck run . Build targets are also used as arguments to build rules to enable one build rule to reference another.


2 Answers

At the end of your CMakeLists.txt you should have a line that reads:

add_executable(MyTarget ${SOURCE_FILES})

This line specifies the name of your target (the executable is generated with this name).

If you don't have this line, add it and click on the "Reload changes" link at the top. This line should have been created when CLion created your project.

like image 88
Daniel Avatar answered Nov 08 '22 15:11

Daniel


Check in CMakeLists.txt that the line set(SOURCE_FILES main.cpp ... does not reference files that does not exist. It solved it for me.

like image 24
MaC Avatar answered Nov 08 '22 14:11

MaC