如何编写一个合格的CMakeLists(How to write a qualified cmakelists)

cmake 的link_libraries和target_link_libraries

How to properly link libraries with cmake?

CMake中有两个变量,可以获取到当前的当前目录名(绝对路径)和当前文件的绝对路径,分别是和。

CMakeLists.txt
CMAKE_CURRENT_SOURCE_DIR
CMAKE_CURRENT_LIST_FILE
————————

cmake 的link_libraries和target_link_libraries

How to properly link libraries with cmake?

There are two variables in cmake, which can obtain the current directory name (absolute path) and the absolute path of the current file, which are and respectively.

CMakeLists.txt
CMAKE_CURRENT_SOURCE_DIR
CMAKE_CURRENT_LIST_FILE