我正在尝试学习如何用c ++编写代码。我无法在任何地方找到如何在我运行它的项目中在Clion中简单地创建一个新文件。在新项目中创建的第一个文件运行正常。我是否必须编辑cmakelists.txt文件?
答案 0 :(得分:4)
答案 1 :(得分:2)
来自https://stackoverflow.com/a/32177224/6614294:
像这样修改CMakeLists.txt
(示例):
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})