且构网

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

使用cmake的共享库的未定义引用

更新时间:2022-04-11 22:52:56

包含CMakeLists.txt是运行时的当前目录。相反,每当需要相对于CMakeLists.txt的路径时,使用 $ {CMAKE_CURRENT_SOURCE_DIR} 。例如:

Don't assume that the directory containing CMakeLists.txt is the current directory at runtime. Instead, use ${CMAKE_CURRENT_SOURCE_DIR} whenever you want a path relative to the CMakeLists.txt. For example:

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/hdr)