问题描述
第一次使用手写cmake编译 c++ 项目时,使用cmake ..
出现以下报错:
CMake Error at CMakeLists.txt:9 (target_link_libraries): Cannot specify link libraries for target “main” which is not built by this
project.
解决方法
在 CMakeLists.txt
中将ADD_EXECUTABLE
放在TARGET_LINK_LIBRARIES
参考
- https://blog.csdn.net/WAN_EXE/article/details/70307692