【Qt】【CMake】-CMakelists.txt-编译错误:No SOURCES given to target: project

1.【编译错误】:

项目中,找不到源文件!

CMake Error at CMakeLists.txt:36 (add_library):
  No SOURCES given to target: project
CMake Generate step failed.  Build files cannot be regenerated correctly.
make: *** [cmake_check_build_system] Error 1
16:10:33: The process "/Users/goodmao/Qt_all_version/Qt5.15.4/Tools/CMake/CMake.app/Contents/bin/cmake" exited with code 2.
Error while building/deploying project base (kit: Desktop (arm-darwin-generic-mach_o-64bit))
When executing step "CMake Build"
16:10:33: Elapsed time: 00:00.

2.【错误原因】:

项目配置不正确。

一般是代码文件路径配置问题。

3.【解决方法】:

修改路径正确即可。

4.【例子】:

项目路径如下:

project
|-CMakeLists.txt
|-src\
|-header\
此时,CMakeLists.txt中的宏  ${ CMAKE_CURRENT_SOURCE_DIR },
表示:project/

那么,src源文件的路径,配置如下:

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/.   PROJECT_SRC)

= = =

你可能感兴趣的:(CMake,Qt,CMake,CMakelists.txt,编译错误)