最佳答案
如何让 CMake 将可执行文件链接到不在同一 CMake 项目中生成的外部共享库?
只要做 target_link_libraries(GLBall ${CMAKE_BINARY_DIR}/res/mylib.so)
就会出错
make[2]: *** No rule to make target `res/mylib.so', needed by `GLBall'. Stop.
make[1]: *** [CMakeFiles/GLBall.dir/all] Error 2
make: *** [all] Error 2
(GLBall is the executable)
在我将库复制到二进制目录 bin/res
之后。
我试过用 find_library(RESULT mylib.so PATHS ${CMAKE_BINARY_DIR}/res)
RESULT-NOTFOUND
也失败了。