Some concepts in CMake

1. The use of double colons in CMP0028

https://cmake.org/cmake/help/latest/policy/CMP0028.html
The double colon in the target name means ALIAS or IMPORTEDtarget
In CMake2.18.2 and lower versions, it is allowed to use double colons in the target_link_libraries() command target or file.
When computing link dependencies for a target, each dependency name is either the target or a filename on disk. (target is the target of the build, which is what you wrote in add_execute or add_library). Before the double colon "::", if the target does not find a matching name, the name is considered to point to a file on disk, which will lead to confusing messages (if the name of the target is typo ).
Refer to the target attribute in LINK_LIBRARIES_ONLY_TARGETS
In the old version of CMake, it will search for target, then the files on the disk and even search for items containing double colons. The new CMP0028 behavior throws a FATAL_ERROR error if a link dependency contains double colons but is not an IMPORTED or ALIAS target.

2. ALIAS TARGET

Cmake original document address
An ALIAS target is an alias, which can be used interchangeably with the binary target name in a read-only context (I don't understand what the read-only context means). The main use case for ALIAS targets are unit test executables shipped with libraries, which can be part of the same build system or built separately based on user configuration.

Guess you like

Origin blog.csdn.net/u013238941/article/details/130226258