博文背景
CLion好是好,但是想让它拥有多Main入口总是没有那么方便,对于我写算法题来说总是感觉不是那么地够爽,那么如何使用CMake来自动化地对cpp文件构建主函数入口?
具体操作
cmake_minimum_required(VERSION 3.16)
project(withoutcmake)
set(CMAKE_CXX_STANDARD 14)
file(GLOB Hello *.cpp)
foreach( testsourcefile ${Hello})
string( REPLACE ".cpp" "" testname ${testsourcefile})
string( REPLACE "/home/ubuntu/CLionProjects/withoutcmake/" "" hiname ${testname})
add_executable( ${hiname} ${testsourcefile})
endforeach( testsourcefile ${Hello})
#add_executable(main main.cpp)