修改CMakeLists.txt内容
cmake_minimum_required(VERSION 3.23)
project(test)
set(CMAKE_CXX_STANDARD 14)
#上面三行无需改动
#递归遍历所有的cpp文件
file (GLOB_RECURSE files *.cpp)
#将所有的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 ()
标签:files,exe,函数,file,cpp,main,CLion
From: https://www.cnblogs.com/meww/p/16926989.html