CLion运行多个main函数

修改CMakeLists.txt

cmake_minimum_required(VERSION 3.17)
project(codeforces)

set(CMAKE_CXX_STANDARD 20)

#add_executable(codeforces main.cpp)
# 遍历项目根目录下所有的 .cpp 文件
file (GLOB_RECURSE files *.cpp)
foreach (file ${files})
    string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file})
    add_executable (${exe} ${file})
    message (\ \ \ \ --\ src/${exe}.cpp\ will\ be\ compiled\ to\ bin/${exe})
endforeach ()

创建新的cpp文件后,reload project

posted @ 2021-04-02 13:16  rxh1999  阅读(287)  评论(0编辑  收藏  举报