Skip to content

Commit 0b33eb0

Browse files
committed
cmake: fix ocv_target_compile_definitions() for world builds
fixes CUDA build
1 parent 8ed1a27 commit 0b33eb0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmake/OpenCVModule.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,11 @@ macro(_ocv_create_module)
863863
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
864864
endif()
865865

866+
if(OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS)
867+
target_compile_definitions(${the_module} ${OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS})
868+
unset(OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS CACHE)
869+
endif()
870+
866871
add_dependencies(opencv_modules ${the_module})
867872

868873
if(ENABLE_SOLUTION_FOLDERS)

cmake/OpenCVUtils.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,14 @@ endfunction()
987987

988988
function(ocv_target_compile_definitions target)
989989
_ocv_fix_target(target)
990-
target_compile_definitions(${target} ${ARGN})
990+
if(NOT TARGET ${target})
991+
if(NOT DEFINED OPENCV_MODULE_${target}_LOCATION)
992+
message(FATAL_ERROR "ocv_target_compile_definitions: invalid target: '${target}'")
993+
endif()
994+
set(OPENCV_MODULE_${target}_COMPILE_DEFINITIONS ${OPENCV_MODULE_${target}_COMPILE_DEFINITIONS} ${ARGN} CACHE INTERNAL "" FORCE)
995+
else()
996+
target_compile_definitions(${target} ${ARGN})
997+
endif()
991998
endfunction()
992999

9931000

0 commit comments

Comments
 (0)