forked from open-mmlab/mmdeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] fix-cmake-relocatable (open-mmlab#223)
* require user to specify xxx_dir * fix line ending * fix end-of-file-fixer * try to fix ld cudart cublas * add ENV var search * fix CMAKE_CUDA_COMPILER * cpu, cuda should all work well * remove commented code
- Loading branch information
Showing
14 changed files
with
159 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
if (NOT DEFINED CUDNN_DIR) | ||
set(CUDNN_DIR $ENV{CUDNN_DIR}) | ||
endif () | ||
|
||
find_path( | ||
CUDNN_INCLUDE_DIR cudnn.h | ||
HINTS ${CUDNN_DIR} ${CUDA_TOOLKIT_ROOT_DIR} | ||
PATH_SUFFIXES include) | ||
|
||
find_library( | ||
CUDNN_LIBRARY_CUDNN_PATH cudnn | ||
HINTS ${CUDNN_DIR} ${CUDA_TOOLKIT_ROOT_DIR} | ||
PATH_SUFFIXES lib lib64 lib/x64) | ||
|
||
if (NOT (CUDNN_INCLUDE_DIR AND CUDNN_LIBRARY_CUDNN_PATH)) | ||
message(FATAL_ERROR "Couldn't find cuDNN in CUDNN_DIR: ${CUDNN_DIR}, " | ||
"or in CUDA_TOOLKIT_ROOT_DIR: ${CUDA_TOOLKIT_ROOT_DIR}, " | ||
"please check if the path is correct.") | ||
endif() | ||
|
||
add_library(cudnn SHARED IMPORTED) | ||
set_property(TARGET cudnn APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) | ||
if (MSVC) | ||
set_target_properties(cudnn PROPERTIES | ||
IMPORTED_IMPLIB_RELEASE ${CUDNN_LIBRARY_CUDNN_PATH} | ||
INTERFACE_INCLUDE_DIRECTORIES ${CUDNN_INCLUDE_DIR} | ||
) | ||
|
||
else() | ||
set_target_properties(cudnn PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${CUDNN_LIBRARY_CUDNN_PATH} | ||
INTERFACE_INCLUDE_DIRECTORIES ${CUDNN_INCLUDE_DIR} | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
if (NOT DEFINED ONNXRUNTIME_DIR) | ||
set(ONNXRUNTIME_DIR $ENV{ONNXRUNTIME_DIR}) | ||
endif () | ||
if (NOT ONNXRUNTIME_DIR) | ||
message(FATAL_ERROR "Please set ONNXRUNTIME_DIR with cmake -D option.") | ||
endif() | ||
|
||
find_path( | ||
ONNXRUNTIME_INCLUDE_DIR onnxruntime_cxx_api.h | ||
HINTS ${ONNXRUNTIME_DIR} | ||
PATH_SUFFIXES include) | ||
find_library( | ||
ONNXRUNTIME_LIBRARY_ONNXRUNTIME_PATH onnxruntime | ||
HINTS ${ONNXRUNTIME_DIR} | ||
PATH_SUFFIXES lib lib64 lib/x64) | ||
if (NOT (ONNXRUNTIME_INCLUDE_DIR AND ONNXRUNTIME_LIBRARY_ONNXRUNTIME_PATH)) | ||
message(FATAL_ERROR "Couldn't find onnxruntime in ONNXRUNTIME_DIR: " | ||
"${ONNXRUNTIME_DIR}, please check if the path is correct.") | ||
endif() | ||
|
||
add_library(onnxruntime SHARED IMPORTED) | ||
set_property(TARGET onnxruntime APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) | ||
if (MSVC) | ||
set_target_properties(onnxruntime PROPERTIES | ||
IMPORTED_IMPLIB_RELEASE ${ONNXRUNTIME_LIBRARY_ONNXRUNTIME_PATH} | ||
INTERFACE_INCLUDE_DIRECTORIES ${ONNXRUNTIME_INCLUDE_DIR} | ||
) | ||
|
||
else() | ||
set_target_properties(onnxruntime PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${ONNXRUNTIME_LIBRARY_ONNXRUNTIME_PATH} | ||
INTERFACE_INCLUDE_DIRECTORIES ${ONNXRUNTIME_INCLUDE_DIR} | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
if (NOT DEFINED TENSORRT_DIR) | ||
set(TENSORRT_DIR $ENV{TENSORRT_DIR}) | ||
endif () | ||
if (NOT TENSORRT_DIR) | ||
message(FATAL_ERROR "Please set TENSORRT_DIR with cmake -D option.") | ||
endif() | ||
|
||
find_path( | ||
TENSORRT_INCLUDE_DIR NvInfer.h | ||
HINTS ${TENSORRT_DIR} | ||
PATH_SUFFIXES include) | ||
|
||
if (NOT TENSORRT_INCLUDE_DIR) | ||
message(FATAL_ERROR "Cannot find TensorRT header NvInfer.h, " | ||
"please check if the path is correct") | ||
endif () | ||
|
||
set(__TENSORRT_LIB_COMPONENTS nvinfer;nvinfer_plugin) | ||
foreach(__component ${__TENSORRT_LIB_COMPONENTS}) | ||
find_library( | ||
__component_path ${__component} | ||
HINTS ${TENSORRT_DIR} | ||
PATH_SUFFIXES lib lib64 lib/x64) | ||
if (NOT __component_path) | ||
message(FATAL_ERROR "Cannot find TensorRT lib ${__component}, " | ||
"please check if the path is correct") | ||
endif() | ||
|
||
add_library(${__component} SHARED IMPORTED) | ||
set_property(TARGET ${__component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) | ||
if (MSVC) | ||
set_target_properties( | ||
${__component} PROPERTIES | ||
IMPORTED_IMPLIB_RELEASE ${__component_path} | ||
INTERFACE_INCLUDE_DIRECTORIES ${TENSORRT_INCLUDE_DIR} | ||
) | ||
else() | ||
set_target_properties( | ||
${__component} PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${__component_path} | ||
INTERFACE_INCLUDE_DIRECTORIES ${TENSORRT_INCLUDE_DIR} | ||
) | ||
endif() | ||
unset(__component_path CACHE) | ||
endforeach() | ||
|
||
set(TENSORRT_LIBS ${__TENSORRT_LIB_COMPONENTS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters