cmake: fix variable expand in CMake conditions

This commit is contained in:
Alexander Alekhin 2018-10-21 15:02:40 +00:00
parent d8ffddd075
commit d6a8e08acc
9 changed files with 20 additions and 16 deletions

View File

@ -96,6 +96,10 @@ if(POLICY CMP0051)
cmake_policy(SET CMP0051 NEW)
endif()
if(POLICY CMP0054) # CMake 3.1: Only interpret if() arguments as variables or keywords when unquoted.
cmake_policy(SET CMP0054 NEW)
endif()
if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()

View File

@ -50,13 +50,13 @@ endforeach()
# process legacy flags
macro(ocv_optimization_process_obsolete_option legacy_flag OPT legacy_warn)
if(DEFINED ${legacy_flag})
if(${legacy_warn})
if(DEFINED "${legacy_flag}")
if("${legacy_warn}")
message(STATUS "WARNING: Option ${legacy_flag}='${${legacy_flag}}' is deprecated and should not be used anymore")
message(STATUS " Behaviour of this option is not backward compatible")
message(STATUS " Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation")
endif()
if(${legacy_flag})
if("${legacy_flag}")
if(NOT ";${CPU_BASELINE_REQUIRE};" MATCHES ";${OPT};")
set(CPU_BASELINE_REQUIRE "${CPU_BASELINE_REQUIRE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_REQUIRE}" FORCE)
endif()

View File

@ -114,9 +114,9 @@ if(CUDA_FOUND)
endif()
set(__cuda_arch_ptx "")
else()
if(${CUDA_VERSION} VERSION_LESS "9.0")
if(CUDA_VERSION VERSION_LESS "9.0")
set(__cuda_arch_bin "2.0 3.0 3.5 3.7 5.0 5.2 6.0 6.1")
elseif(${CUDA_VERSION} VERSION_LESS "10.0")
elseif(CUDA_VERSION VERSION_LESS "10.0")
set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0")
else()
set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5")

View File

@ -20,27 +20,27 @@ if(NOT VTK_FOUND)
endif()
# Don't support earlier VTKs
if(${VTK_VERSION} VERSION_LESS "5.8.0")
if(VTK_VERSION VERSION_LESS "5.8.0")
message(STATUS "VTK support is disabled. VTK ver. 5.8.0 is minimum required, but found VTK ver. ${VTK_VERSION}")
return()
endif()
# Different Qt versions can't be linked together
if(HAVE_QT5 AND ${VTK_VERSION} VERSION_LESS "6.0.0")
if(HAVE_QT5 AND VTK_VERSION VERSION_LESS "6.0.0")
if(VTK_USE_QT)
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
endif()
endif()
# Different Qt versions can't be linked together. VTK 6.0.0 doesn't provide a way to get Qt version it was linked with
if(HAVE_QT5 AND ${VTK_VERSION} VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
if(HAVE_QT5 AND VTK_VERSION VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4")
message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake")
return()
endif()
# Different Qt versions can't be linked together
if(HAVE_QT AND ${VTK_VERSION} VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
if(HAVE_QT AND VTK_VERSION VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4")
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
return()

View File

@ -105,7 +105,7 @@ macro(ipp_detect_version)
message(STATUS "found Intel IPP${__msg}: ${_MAJOR}.${_MINOR}.${_BUILD} [${IPP_VERSION_STR}]")
message(STATUS "at: ${IPP_ROOT_DIR}")
if(${IPP_VERSION_STR} VERSION_LESS "7.0")
if(IPP_VERSION_STR VERSION_LESS "7.0")
_ipp_not_supported("Intel IPP ${IPP_VERSION_STR} is not supported")
endif()
@ -166,7 +166,7 @@ macro(ipp_detect_version)
endmacro()
set(IPP_PREFIX "ipp")
if(${IPP_VERSION_STR} VERSION_LESS "8.0")
if(IPP_VERSION_STR VERSION_LESS "8.0")
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV)
set(IPP_SUFFIX "") # dynamic not threaded libs suffix Intel IPP 7.x
else ()

View File

@ -94,7 +94,7 @@ else()
set(MKL_ARCH_SUFFIX "c")
endif()
if(${MKL_VERSION_STR} VERSION_GREATER "11.3.0" OR ${MKL_VERSION_STR} VERSION_EQUAL "11.3.0")
if(MKL_VERSION_STR VERSION_GREATER "11.3.0" OR MKL_VERSION_STR VERSION_EQUAL "11.3.0")
set(mkl_lib_find_paths
${MKL_ROOT_DIR}/lib
${MKL_ROOT_DIR}/lib/${MKL_ARCH} ${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH})

View File

@ -615,7 +615,7 @@ function(__ocv_resolve_dependencies)
list(APPEND LINK_DEPS opencv_world)
endif()
endif()
if(${m} STREQUAL opencv_world)
if("${m}" STREQUAL opencv_world)
list(APPEND OPENCV_MODULE_opencv_world_DEPS_EXT ${OPENCV_MODULE_${m2}_DEPS_EXT})
endif()
endif()
@ -842,7 +842,7 @@ macro(ocv_create_module)
if(NOT " ${ARGN}" STREQUAL " ")
set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
endif()
if(${BUILD_opencv_world} AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
if(BUILD_opencv_world AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
# nothing
set(the_module_target opencv_world)
else()

View File

@ -89,7 +89,7 @@ set(CPACK_COMPONENT_TESTS_DEPENDS libs)
if(HAVE_CUDA)
string(REPLACE "." "-" cuda_version_suffix ${CUDA_VERSION})
if(${CUDA_VERSION} VERSION_LESS "6.5")
if(CUDA_VERSION VERSION_LESS "6.5")
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
else()

View File

@ -16,7 +16,7 @@ endif()
set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES})
if(${CUDA_VERSION} VERSION_LESS "5.5")
if(CUDA_VERSION VERSION_LESS "5.5")
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY})
else()
find_cuda_helper_libs(nppc)