CMake "target_link_libraries called with incorrect number of arguments" in CI
target_link_libraries needs a valid target followed by libraries, and you cannot mix the keyword form (PRIVATE/PUBLIC) with the plain form on the same target. A malformed call triggers this.
What this error means
Configure fails with "target_link_libraries called with incorrect number of arguments", often when the target name is empty or a variable expanded to nothing.
cmake
CMake Error at CMakeLists.txt:12 (target_link_libraries):
target_link_libraries called with incorrect number of argumentsCommon causes
How to fix it
Use a single, complete signature
- Pass a defined target then a scope keyword and the libraries.
- Do not combine keyword and plain forms for the same target.
cmake
target_link_libraries(app PRIVATE fmt::fmt Threads::Threads)How to prevent it
- Always use the keyword signature consistently and confirm the target variable is set before calling target_link_libraries.
Related guides
CMake "install TARGETS given target which does not exist" in CIFix CMake "install TARGETS given target X which does not exist" in CI - install() references a target that wa…
CMake "Found unsuitable Qt version" in CIFix CMake "Found unsuitable Qt version X" in CI - find_package located a Qt that does not match the version t…