CMake --- find_library(... NO_DEFAULT_PATH)不起作用?

时间:2019-04-13 05:15:17

标签: cmake

如果我明确表示一个库,我有一个成功的CMake:

set(GLFW_LIB ~/.mujoco/mujoco200/bin/libglfw.so.3)

但如果我尝试查找库则不会

find_library(GLFW_LIB glfw PATH ~/.mujoco/mujoco200/bin NO_DEFAULT_PATH)
CMake Warning at CMakeLists.txt:17 (add_executable):
  Cannot generate a safe runtime search path for target basic because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libglfw.so.3] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/xxxxxxx/.mujoco/mujoco200/bin

  Some of these libraries may not be found correctly.

它确实找不到正确的库

message(${GLFW_LIB})
/usr/lib/x86_64-linux-gnu/libglfw.so.3

我尝试了很多很多变体(组合的数量超出了我可能会穷尽所有的可能性)

find_library(GLFW_LIB libglfw.so.3 PATH ~/.mujoco/mujoco200/bin NO_DEFAULT_PATH)

find_library(GLFW_LIB glfw HINT ~/.mujoco/mujoco200/bin NO_DEFAULT_PATH)

find_library(GLFW_LIB glfw NO_DEFAULT_PATH PATH ~/.mujoco/mujoco200/bin)

find_library(GLFW_LIB glfw PATH /home/xxxxxxx/.mujoco/mujoco200/bin NO_DEFAULT_PATH)

find_library(GLFW_LIB glfw PATH ~/.mujoco/mujoco200/bin NO_DEFAULT_PATH 
      NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH
      NO_CMAKE_ENVIRONMENT_PATH  NO_SYSTEM_ENVIRONMENT_PATH
      NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)

依此类推,全部失败,并发出完全相同的警告,并错误地找到了库。

这不会阻塞我的小项目,因为我只能命名库,但是我担心我一点都不了解find_library,而且随着我的项目变得越来越复杂,我会陷入困境。

0 个答案:

没有答案