Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(cmake): add an ability to opt in only for certain CV-CUDA operators #99

Open
wants to merge 1 commit into
base: release_v0.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/cvcuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
# cvcuda private implementation
add_subdirectory(priv)

add_library(cvcuda SHARED
set(CV_CUDA_LIB_FILES Operator.cpp)

set(CV_CUDA_OP_FILES
OpBoxBlur.cpp
OpBndBox.cpp
OpBrightnessContrast.cpp
OpRemap.cpp
OpColorTwist.cpp
OpCropFlipNormalizeReformat.cpp
OpNonMaximumSuppression.cpp
Operator.cpp
OpReformat.cpp
OpResize.cpp
OpCustomCrop.cpp
Expand Down Expand Up @@ -57,6 +58,29 @@ add_library(cvcuda SHARED
OpGaussianNoise.cpp
)

# filter only one that matches the patern (case insensitive), should be set on the global level
# usage:
# set(CV_CUDA_SRC_PATERN medianblur median_blur"
#
# will compile only files relevant to themedian blur op "OpMedianBlur.cpp"
if (NOT "${CV_CUDA_SRC_PATERN}" STREQUAL "")
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
string(TOLOWER ${PATTERN} PATTERN)
foreach(FILENAME ${CV_CUDA_OP_FILES})
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
list(APPEND CV_CUDA_LIB_FILES ${FILENAME})
endif()
endforeach()
endforeach()
else()
list(APPEND CV_CUDA_LIB_FILES ${CV_CUDA_OP_FILES})
endif()

add_library(cvcuda SHARED
${CV_CUDA_LIB_FILES}
)

target_link_libraries(cvcuda
PUBLIC
CUDA::cudart_static
Expand Down
28 changes: 26 additions & 2 deletions src/cvcuda/priv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

add_subdirectory(legacy)

add_library(cvcuda_priv STATIC
set(CV_CUDA_PRIV_FILES IOperator.cpp)

set(CV_CUDA_PRIV_OP_FILES
OpBoxBlur.cpp
OpBndBox.cpp
OpBrightnessContrast.cu
OpRemap.cu
OpColorTwist.cu
OpCropFlipNormalizeReformat.cu
OpNonMaximumSuppression.cu
IOperator.cpp
OpReformat.cpp
OpResize.cpp
OpCustomCrop.cpp
Expand Down Expand Up @@ -56,6 +57,29 @@ add_library(cvcuda_priv STATIC
OpGaussianNoise.cpp
)

# filter only one that matches the patern (case insensitive), should be set on the global level
# usage:
# set(CV_CUDA_SRC_PATERN medianblur median_blur"
#
# will compile only files relevant to themedian blur op "OpMedianBlur.cpp"
if (NOT "${CV_CUDA_SRC_PATERN}" STREQUAL "")
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
string(TOLOWER ${PATTERN} PATTERN)
foreach(FILENAME ${CV_CUDA_PRIV_OP_FILES})
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
list(APPEND CV_CUDA_PRIV_FILES ${FILENAME})
endif()
endforeach()
endforeach()
else()
list(APPEND CV_CUDA_PRIV_FILES ${CV_CUDA_PRIV_OP_FILES})
endif()

add_library(cvcuda_priv STATIC
${CV_CUDA_PRIV_FILES}
)

target_link_libraries(cvcuda_priv
PUBLIC
nvcv_types
Expand Down
28 changes: 26 additions & 2 deletions src/cvcuda/priv/legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(cvcuda_legacy STATIC
set(CV_CUDA_PRIV_LEGACY_FILES CvCudaLegacyHelpers.cpp)

set(CV_CUDA_PRIV_LEGACY_OP_FILES
filter_utils.cu
custom_crop.cu
reformat.cu
Expand Down Expand Up @@ -49,7 +51,6 @@ add_library(cvcuda_legacy STATIC
flip.cu
flip_or_copy_var_shape.cu
composite_var_shape.cu
CvCudaLegacyHelpers.cpp
custom_crop.cu
reformat.cu
resize.cu
Expand All @@ -75,6 +76,29 @@ add_library(cvcuda_legacy STATIC
gaussian_noise_util.cu
)

# filter only one that matches the patern (case insensitive), should be set on the global level
# usage:
# set(CV_CUDA_SRC_PATERN medianblur median_blur"
#
# will compile only files relevant to themedian blur op "median_blur.cu;median_blur_var_shape.cu"
if (NOT "${CV_CUDA_SRC_PATERN}" STREQUAL "")
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
string(TOLOWER ${PATTERN} PATTERN)
foreach(FILENAME ${CV_CUDA_PRIV_LEGACY_OP_FILES})
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
list(APPEND CV_CUDA_PRIV_LEGACY_FILES ${FILENAME})
endif()
endforeach()
endforeach()
else()
list(APPEND CV_CUDA_PRIV_LEGACY_FILES ${CV_CUDA_PRIV_LEGACY_OP_FILES})
endif()

add_library(cvcuda_legacy STATIC
${CV_CUDA_PRIV_LEGACY_FILES}
)

target_link_libraries(cvcuda_legacy
PUBLIC
CUDA::cudart_static
Expand Down