首页 > 其他分享 >CLion中运行多个main()函数

CLion中运行多个main()函数

时间:2022-11-26 10:23:08浏览次数:52  
标签:files exe 函数 file cpp main CLion

修改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

相关文章