message("now using FindCAP-NG.cmake find libCAP-NG") FIND_PATH(CAP-NG_INCLUDE_DIR cap-ng.h /usr/local/include) FIND_LIBRARY(CAP-NG_LIBRARY libcap-ng.so /usr/lib/x86_64-linux-gnu/) message("lib dir: ${CAP-NG_LIBRARY} include files ${CAP-NG_INCLUDE_DIR}") if(CAP-NG_INCLUDE_DIR AND CAP-NG_LIBRARY) set(CAP-NG_FOUND TRUE) endif(CAP-NG_INCLUDE_DIR AND CAP-NG_LIBRARY)改造一下,如果是centos系统那去/usr/lib64下找动态库,如果是其余系统则按之前的找
时间: 2024-03-14 20:47:09 浏览: 103
cmake-3.21.1.tar.gz
可以这样改造:
```
message("now using FindCAP-NG.cmake to find libCAP-NG")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_VERSION MATCHES "centos")
FIND_PATH(CAP-NG_INCLUDE_DIR cap-ng.h /usr/local/include)
FIND_LIBRARY(CAP-NG_LIBRARY libcap-ng.so /usr/lib64/)
else()
FIND_PATH(CAP-NG_INCLUDE_DIR cap-ng.h /usr/local/include)
FIND_LIBRARY(CAP-NG_LIBRARY libcap-ng.so /usr/lib/x86_64-linux-gnu/)
endif()
message("lib dir: ${CAP-NG_LIBRARY} include files ${CAP-NG_INCLUDE_DIR}")
if(CAP-NG_INCLUDE_DIR AND CAP-NG_LIBRARY)
set(CAP-NG_FOUND TRUE)
endif(CAP-NG_INCLUDE_DIR AND CAP-NG_LIBRARY)
```
这样,如果系统是 Linux 并且版本是 centos,就会去 `/usr/lib64` 下找动态库;否则就按照之前的方式去 `/usr/lib/x86_64-linux-gnu/` 下找动态库。
阅读全文