Skip to content

Commit 5e7aa1c

Browse files
committed
Add an ability to opt in only for certain CV-CUDA operators
- adds an ability to compile only CV-CUDA files that match the given pattern so the user can have binary only with selected operators (which also reduces its size) Signed-off-by: Janusz Lisiecki <[email protected]>
1 parent e4f97ee commit 5e7aa1c

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

src/cvcuda/CMakeLists.txt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# Licensed under the Apache License, Version 2.0 (the "License")
55
# you may not use this file except in compliance with the License.
66
# You may obtain a copy of the License at
77
#
@@ -16,7 +16,13 @@
1616
# cvcuda private implementation
1717
add_subdirectory(priv)
1818

19+
<<<<<<< Updated upstream
1920
add_library(cvcuda SHARED
21+
=======
22+
set(CV_CUDA_LIB_FILES Operator.cpp)
23+
24+
set(CV_CUDA_OP_FILES
25+
>>>>>>> Stashed changes
2026
OpBoxBlur.cpp
2127
OpBndBox.cpp
2228
OpBrightnessContrast.cpp
@@ -55,6 +61,28 @@ add_library(cvcuda SHARED
5561
OpAdaptiveThreshold.cpp
5662
OpRandomResizedCrop.cpp
5763
OpGaussianNoise.cpp
64+
<<<<<<< Updated upstream
65+
=======
66+
)
67+
68+
# filter only one that matches the patern
69+
if (NOT CV_CUDA_SRC_PATERN STREQUAL "")
70+
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
71+
string(TOLOWER ${PATTERN} PATTERN)
72+
foreach(FILENAME ${CV_CUDA_OP_FILES})
73+
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
74+
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
75+
list(APPEND CV_CUDA_LIB_FILES ${FILENAME})
76+
endif()
77+
endforeach()
78+
endforeach()
79+
else()
80+
list(APPEND CV_CUDA_LIB_FILES ${CV_CUDA_OP_FILES})
81+
endif()
82+
83+
add_library(cvcuda SHARED
84+
${CV_CUDA_LIB_FILES}
85+
>>>>>>> Stashed changes
5886
)
5987

6088
target_link_libraries(cvcuda

src/cvcuda/priv/CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,24 @@
1515

1616
add_subdirectory(legacy)
1717

18+
<<<<<<< Updated upstream
1819
add_library(cvcuda_priv STATIC
1920
OpBoxBlur.cpp
21+
=======
22+
set(CV_CUDA_PRIV_FILES IOperator.cpp)
23+
24+
set(CV_CUDA_PRIV_OP_FILES OpBoxBlur.cpp
25+
>>>>>>> Stashed changes
2026
OpBndBox.cpp
2127
OpBrightnessContrast.cu
2228
OpRemap.cu
2329
OpColorTwist.cu
2430
OpCropFlipNormalizeReformat.cu
2531
OpNonMaximumSuppression.cu
32+
<<<<<<< Updated upstream
2633
IOperator.cpp
34+
=======
35+
>>>>>>> Stashed changes
2736
OpReformat.cpp
2837
OpResize.cpp
2938
OpCustomCrop.cpp
@@ -54,6 +63,28 @@ add_library(cvcuda_priv STATIC
5463
OpAdaptiveThreshold.cpp
5564
OpRandomResizedCrop.cpp
5665
OpGaussianNoise.cpp
66+
<<<<<<< Updated upstream
67+
=======
68+
)
69+
70+
# filter only one that matches the patern
71+
if (NOT CV_CUDA_SRC_PATERN STREQUAL "")
72+
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
73+
string(TOLOWER ${PATTERN} PATTERN)
74+
foreach(FILENAME ${CV_CUDA_PRIV_OP_FILES})
75+
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
76+
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
77+
list(APPEND CV_CUDA_PRIV_FILES ${FILENAME})
78+
endif()
79+
endforeach()
80+
endforeach()
81+
else()
82+
list(APPEND CV_CUDA_PRIV_FILES ${CV_CUDA_PRIV_OP_FILES})
83+
endif()
84+
85+
add_library(cvcuda_priv STATIC
86+
${CV_CUDA_PRIV_FILES}
87+
>>>>>>> Stashed changes
5788
)
5889

5990
target_link_libraries(cvcuda_priv

src/cvcuda/priv/legacy/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
<<<<<<< Updated upstream
1617
add_library(cvcuda_legacy STATIC
18+
=======
19+
set(CV_CUDA_PRIV_LEGACY_FILES CvCudaLegacyHelpers.cpp)
20+
21+
set(CV_CUDA_PRIV_LEGACY_OP_FILES
22+
>>>>>>> Stashed changes
1723
filter_utils.cu
1824
custom_crop.cu
1925
reformat.cu
@@ -49,7 +55,10 @@ add_library(cvcuda_legacy STATIC
4955
flip.cu
5056
flip_or_copy_var_shape.cu
5157
composite_var_shape.cu
58+
<<<<<<< Updated upstream
5259
CvCudaLegacyHelpers.cpp
60+
=======
61+
>>>>>>> Stashed changes
5362
custom_crop.cu
5463
reformat.cu
5564
resize.cu
@@ -73,6 +82,29 @@ add_library(cvcuda_legacy STATIC
7382
gaussian_noise.cu
7483
gaussian_noise_var_shape.cu
7584
gaussian_noise_util.cu
85+
<<<<<<< Updated upstream
86+
=======
87+
88+
)
89+
90+
# filter only one that matches the patern
91+
if (NOT CV_CUDA_SRC_PATERN STREQUAL "")
92+
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
93+
string(TOLOWER ${PATTERN} PATTERN)
94+
foreach(FILENAME ${CV_CUDA_PRIV_LEGACY_OP_FILES})
95+
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
96+
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
97+
list(APPEND CV_CUDA_PRIV_LEGACY_FILES ${FILENAME})
98+
endif()
99+
endforeach()
100+
endforeach()
101+
else()
102+
list(APPEND CV_CUDA_PRIV_LEGACY_FILES ${CV_CUDA_PRIV_LEGACY_OP_FILES})
103+
endif()
104+
105+
add_library(cvcuda_legacy STATIC
106+
${CV_CUDA_PRIV_LEGACY_FILES}
107+
>>>>>>> Stashed changes
76108
)
77109

78110
target_link_libraries(cvcuda_legacy

0 commit comments

Comments
 (0)