Clion运行单个文件

  1. 安装C/C++ Single File Execution Plugin插件;
  2. 打开文件夹为项目;
  3. 编写CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(CODING__ALAN_CF)

set(CMAKE_CXX_STANDARD 14)
include_directories(.)
# 如果你只需要根目录下的 test 文件夹的所有 .cpp 文件
file (GLOB files test/*.cpp)
# 如果你只有两层目录的话
file (GLOB files *.cpp */*.cpp)
# 同理,三层的话
file (GLOB files *.cpp */*.cpp */*/*.cpp)

# 官方提供了一种递归的方法
# 这样在运行框会多一个 CMakeCXXCompilerId,不过无伤大雅
file (GLOB_RECURSE files *.cpp)

4. 单个文件鼠标右键选择 Add executable for single c/cpp file

C/C++ Single File Execution Plugin

https://blog.csdn.net/caoxiaobao1207/article/details/122376642

This entry was posted in 默认分类. Bookmark the permalink.