【cmake】——find

it2022-12-30  65

例子

#在HINTS后的路径中找NvInfer.h, PATH_SUFFIXES:在每个搜索路径的子目录下搜索 find_path(TENSORRT_INCLUDE_DIR NvInfer.h HINTS ${TENSORRT_ROOT} ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES include) find_library(TENSORRT_INFER libnvinfer.so HINTS ${TENSORRT_ROOT} ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES lib lib64 lib/x64) find_library(TENSORRT_INFER_PLUGIN libnvinfer_plugin.so HINTS ${TENSORRT_ROOT} ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES lib lib64 lib/x64)

后面使用的时候: target_link_libraries(trt ${TENSORRT_INFER} ${TENSORRT_INFER_PLUGIN})

也可以在同时找多个.h / .so文件 find_library(TENSORRT_INFER libnvinfer.so B.so C.so HINTS ${TENSORRT_ROOT} ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES lib lib64 lib/x64)

最新回复(0)