cmake: fix ocv_target_compile_definitions() for world builds
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Fri, 15 Dec 2017 19:21:51 +0000 (22:21 +0300)
committerAlexander Alekhin <alexander.alekhin@intel.com>
Fri, 15 Dec 2017 20:30:53 +0000 (23:30 +0300)
fixes CUDA build

cmake/OpenCVModule.cmake
cmake/OpenCVUtils.cmake

index 17f5b3b..a84bbff 100644 (file)
@@ -863,6 +863,11 @@ macro(_ocv_create_module)
     ocv_target_link_libraries(${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
   endif()
 
+  if(OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS)
+    target_compile_definitions(${the_module} ${OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS})
+    unset(OPENCV_MODULE_${the_module}_COMPILE_DEFINITIONS CACHE)
+  endif()
+
   add_dependencies(opencv_modules ${the_module})
 
   if(ENABLE_SOLUTION_FOLDERS)
index e5ca276..1bb539e 100644 (file)
@@ -987,7 +987,14 @@ endfunction()
 
 function(ocv_target_compile_definitions target)
   _ocv_fix_target(target)
-  target_compile_definitions(${target} ${ARGN})
+  if(NOT TARGET ${target})
+    if(NOT DEFINED OPENCV_MODULE_${target}_LOCATION)
+      message(FATAL_ERROR "ocv_target_compile_definitions: invalid target: '${target}'")
+    endif()
+    set(OPENCV_MODULE_${target}_COMPILE_DEFINITIONS ${OPENCV_MODULE_${target}_COMPILE_DEFINITIONS} ${ARGN} CACHE INTERNAL "" FORCE)
+  else()
+    target_compile_definitions(${target} ${ARGN})
+  endif()
 endfunction()