且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

本征cmake要求使用“ target_link_libraries”即使仅模板

更新时间:2023-10-23 10:03:22

啊,我现在知道发生了什么:CMake中有一个称为接口库的概念实际上并没有建立一个库二进制文件。它是专为像Eigen这样的仅模板库而设计的。

Ah now I know what's going on: there's a concept called "interface library" in CMake that doesn't actually build a library binary. It is designed precisely for template-only libraries like Eigen.

参考文献:
- https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries
- http://mariobadr.com/creating-a-header-only-library-with-cmake.html

希望这可以帮助其他挣扎cmake的人!

Hope this helps other souls struggling with cmake!