首页 > 其他分享 >Clion使用

Clion使用

时间:2023-01-21 16:33:40浏览次数:29  
标签:files 文件 exe file 使用 cpp main Clion

1.main函数

对于一个项目只有一个main函数,如果想运行多个文件的主函数,如下代码

注意添加到如下文件下
d5ac6bcc660d31f46e608035b4f2e6cd.png

# 遍历项目根目录下所有的 .cpp 文件
file (GLOB_RECURSE files *.cpp)
foreach (file ${files})
    string(REGEX REPLACE ".+/(.+)\\..*" "\\1" exe ${file})
    add_executable (${exe} ${file})
    message (\ \ \ \ --\ ${file}\ will\ be\ compiled\ to\ bin/${exe})
endforeach ()
  • 千万不要重命名,一旦创建就不要改名字。

  • 千万名字里不要带空格,上面那一串代码不会把名字有空格的cpp文件加入项目当中

  • 注意整个文件目录下不能出现中文,否则不成功。

标签:files,文件,exe,file,使用,cpp,main,Clion
From: https://www.cnblogs.com/hblgzsx/p/17063873.html

相关文章