Getting a CMake Error: Cannot specify link libraries for target which is not built by the project
Solution 1:
In addition to the accepted answer: An important detail is to place target_link_libraries
after the add_executable
and find_package
lines, so all linked components are known.
Solution 2:
The first argument of target_link_libraries
is the target name:
target_link_libraries(eCAD Qt5::Widgets Qt5::Core)
Solution 3:
Also, do not confuse target name with the project name:
- a command
project
specifies a project name, but - a target is the one created with
add_executable
,add_library
oradd_custom_target
.
The error message is about the target.