如何使用 CMake 包含当前目录
为 C++ 项目包含当前目录通常很有帮助。直接使用 GCC 时,可以使用 -I. 来完成,而对于 CMake 你需要使用以下语句:
CMakeLists.txt
target_include_directories(myexe PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})记得将 myexe 替换为你的可执行目标名称。
Check out similar posts by category:
CMake
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow