Skip to content

Commit

Permalink
cmake(cpu optmizations): fix cleanup of OPENCV_DEPENDANT_TARGETS_* vars
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Nov 2, 2019
1 parent cec7cc0 commit 21c38bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmake/OpenCVCompilerOptimizations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,10 @@ macro(ocv_compiler_optimization_process_sources SOURCES_VAR_NAME LIBS_VAR_NAME T
foreach(OPT ${CPU_DISPATCH_FINAL})
if(__result_${OPT})
#message("${OPT}: ${__result_${OPT}}")
if(CMAKE_GENERATOR MATCHES "^Visual")
if(CMAKE_GENERATOR MATCHES "^Visual"
OR OPENCV_CMAKE_CPU_OPTIMIZATIONS_FORCE_TARGETS
)
# MSVS generator is not able to properly order compilation flags:
# extra flags are added before common flags, so switching between optimizations doesn't work correctly
# Also CMAKE_CXX_FLAGS doesn't work (it is directory-based, so add_subdirectory is required)
add_library(${TARGET_BASE_NAME}_${OPT} OBJECT ${__result_${OPT}})
Expand Down
1 change: 0 additions & 1 deletion cmake/OpenCVModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_LINK_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_WRAPPERS CACHE)
unset(OPENCV_DEPENDANT_TARGETS_${mod} CACHE)
endforeach()

# clean modules info which needs to be recalculated
Expand Down
13 changes: 13 additions & 0 deletions cmake/OpenCVUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,22 @@ function(ocv_append_target_property target prop)
endif()
endfunction()

if(DEFINED OPENCV_DEPENDANT_TARGETS_LIST)
foreach(v ${OPENCV_DEPENDANT_TARGETS_LIST})
unset(${v} CACHE)
endforeach()
unset(OPENCV_DEPENDANT_TARGETS_LIST CACHE)
endif()

function(ocv_append_dependant_targets target)
#ocv_debug_message("ocv_append_dependant_targets(${target} ${ARGN})")
_ocv_fix_target(target)
list(FIND OPENCV_DEPENDANT_TARGETS_LIST "OPENCV_DEPENDANT_TARGETS_${target}" __id)
if(__id EQUAL -1)
list(APPEND OPENCV_DEPENDANT_TARGETS_LIST "OPENCV_DEPENDANT_TARGETS_${target}")
list(SORT OPENCV_DEPENDANT_TARGETS_LIST)
set(OPENCV_DEPENDANT_TARGETS_LIST "${OPENCV_DEPENDANT_TARGETS_LIST}" CACHE INTERNAL "")
endif()
set(OPENCV_DEPENDANT_TARGETS_${target} "${OPENCV_DEPENDANT_TARGETS_${target}};${ARGN}" CACHE INTERNAL "" FORCE)
endfunction()

Expand Down

0 comments on commit 21c38bb

Please sign in to comment.