FreeLand
FreeLand

Reputation: 169

Clion, making new file in project in c++

I'm trying to learn how to code in c++. I can't find anywhere how to simply create a new file in Clion in a project that will work when I run it. The first file created in a new project runs fine. Do I have to edit the cmakelists.txt file?

Upvotes: 1

Views: 3305

Answers (2)

uta
uta

Reputation: 2069

You can make it from mouse context menu over the folder where you like to have new file new file creation.

Upvotes: 4

user6614294
user6614294

Reputation:

From https://stackoverflow.com/a/32177224/6614294:

Modify CMakeLists.txt like this (example):

cmake_minimum_required(VERSION 3.3)
project(test_build)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(BUILD_1 main)
set(SOURCE_FILES_1 main.cc) //where main.cc is your first main/program
add_executable(${BUILD_1} ${SOURCE_FILES_1})

set(BUILD_2 main_2)
set(SOURCE_FILES_2 main_2.cc) //where main_2.cc is your second main/program
add_executable(${BUILD_2} ${SOURCE_FILES_2})

Upvotes: 2

Related Questions