diff --git a/cmake/FindCUDA.cmake b/cmake/FindCUDA.cmake index ca04bb4a4e..fc7ed0609b 100644 --- a/cmake/FindCUDA.cmake +++ b/cmake/FindCUDA.cmake @@ -1091,12 +1091,6 @@ endfunction() ############################################################################## macro(CUDA_WRAP_SRCS cuda_target format generated_files) - - # If CMake doesn't support separable compilation, complain - if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") - message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") - endif() - # Set up all the command line flags here, so that they can be overridden on a per target basis. set(nvcc_flags "") diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index f0d6378bd7..c77f06b3b6 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -379,7 +379,7 @@ endif() # Apply "-Wl,--as-needed" linker flags: https://github.com/opencv/opencv/issues/7001 if(NOT OPENCV_SKIP_LINK_AS_NEEDED) - if(UNIX AND (NOT APPLE OR NOT CMAKE_VERSION VERSION_LESS "3.2")) + if(UNIX) set(_option "-Wl,--as-needed") set(_saved_CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_option}") # requires CMake 3.2+ and CMP0056 @@ -395,7 +395,7 @@ endif() # Apply "-Wl,--no-undefined" linker flags: https://github.com/opencv/opencv/pull/21347 if(NOT OPENCV_SKIP_LINK_NO_UNDEFINED) - if(UNIX AND ((NOT APPLE OR NOT CMAKE_VERSION VERSION_LESS "3.2") AND NOT CMAKE_SYSTEM_NAME MATCHES "OpenBSD")) + if(UNIX AND (NOT CMAKE_SYSTEM_NAME MATCHES "OpenBSD")) set(_option "-Wl,--no-undefined") set(_saved_CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_option}") # requires CMake 3.2+ and CMP0056 diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index 06998400d7..b295645c02 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -14,9 +14,7 @@ if(CUDA_TOOLKIT_ROOT_DIR) set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) endif() -if(((NOT CMAKE_VERSION VERSION_LESS "3.9.0") # requires https://gitlab.kitware.com/cmake/cmake/merge_requests/663 - OR OPENCV_CUDA_FORCE_EXTERNAL_CMAKE_MODULE) - AND NOT OPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE) +if(NOT OPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE) ocv_update(CUDA_LINK_LIBRARIES_KEYWORD "PRIVATE") find_host_package(CUDA "${MIN_VER_CUDA}" QUIET) else() diff --git a/cmake/OpenCVDetectCUDAUtils.cmake b/cmake/OpenCVDetectCUDAUtils.cmake index 69d093efca..72f98de27e 100644 --- a/cmake/OpenCVDetectCUDAUtils.cmake +++ b/cmake/OpenCVDetectCUDAUtils.cmake @@ -113,9 +113,7 @@ macro(ocv_initialize_nvidia_device_generations) list(APPEND _generations "Auto") endif() set(CUDA_GENERATION "" CACHE STRING "Build CUDA device code only for specific GPU architecture. Leave empty to build for all architectures (see https://docs.opencv.org/5.x/d2/dbc/cuda_intro.html).") - if( CMAKE_VERSION VERSION_GREATER "2.8" ) - set_property( CACHE CUDA_GENERATION PROPERTY STRINGS "" ${_generations} ) - endif() + set_property( CACHE CUDA_GENERATION PROPERTY STRINGS "" ${_generations} ) if(CUDA_GENERATION) if(NOT ";${_generations};" MATCHES ";${CUDA_GENERATION};") diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake index 4b4dbb672a..4e3cfa30d1 100644 --- a/cmake/OpenCVDetectPython.cmake +++ b/cmake/OpenCVDetectPython.cmake @@ -84,15 +84,11 @@ if(NOT ${found}) "Consider providing the '${executable}' variable via CMake command line or environment variables\n") endif() ocv_clear_vars(PYTHONINTERP_FOUND PYTHON_EXECUTABLE PYTHON_VERSION_STRING PYTHON_VERSION_MAJOR PYTHON_VERSION_MINOR PYTHON_VERSION_PATCH) - if(NOT CMAKE_VERSION VERSION_LESS "3.12") - set(__PYTHON_PREFIX Python3) - find_host_package(${__PYTHON_PREFIX} "${preferred_version}" COMPONENTS Interpreter) - if(${__PYTHON_PREFIX}_EXECUTABLE) - set(PYTHON_EXECUTABLE "${${__PYTHON_PREFIX}_EXECUTABLE}") - find_host_package(PythonInterp "${preferred_version}") # Populate other variables - endif() - else() - message(STATUS "Consider using CMake 3.12+ for better Python support") + set(__PYTHON_PREFIX Python3) + find_host_package(${__PYTHON_PREFIX} "${preferred_version}" COMPONENTS Interpreter) + if(${__PYTHON_PREFIX}_EXECUTABLE) + set(PYTHON_EXECUTABLE "${${__PYTHON_PREFIX}_EXECUTABLE}") + find_host_package(PythonInterp "${preferred_version}") # Populate other variables endif() endif() if(PYTHONINTERP_FOUND AND "${_python_version_major}" STREQUAL "${PYTHON_VERSION_MAJOR}") diff --git a/cmake/OpenCVFindIPP.cmake b/cmake/OpenCVFindIPP.cmake index eb26bea5a1..c8716d869a 100644 --- a/cmake/OpenCVFindIPP.cmake +++ b/cmake/OpenCVFindIPP.cmake @@ -168,11 +168,7 @@ macro(ipp_detect_version) ) AND NOT OPENCV_SKIP_IPP_EXCLUDE_LIBS_CORE ) - if(CMAKE_VERSION VERSION_LESS "3.13.0") - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs,${_filename} ${CMAKE_SHARED_LINKER_FLAGS}") - else() - target_link_options(ipp${name} INTERFACE "LINKER:--exclude-libs,${_filename}") - endif() + target_link_options(ipp${name} INTERFACE "LINKER:--exclude-libs,${_filename}") endif() endif() list(APPEND IPP_LIBRARIES ipp${name}) diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 493f005d7a..4400a88172 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -55,10 +55,7 @@ endif(WITH_CUDA) # --- Eigen --- if(WITH_EIGEN AND NOT HAVE_EIGEN) - if((OPENCV_FORCE_EIGEN_FIND_PACKAGE_CONFIG - OR NOT (CMAKE_VERSION VERSION_LESS "3.0.0") # Eigen3Targets.cmake required CMake 3.0.0+ - ) AND NOT OPENCV_SKIP_EIGEN_FIND_PACKAGE_CONFIG - ) + if(NOT OPENCV_SKIP_EIGEN_FIND_PACKAGE_CONFIG) find_package(Eigen3 CONFIG QUIET) # Ceres 2.0.0 CMake scripts doesn't work with CMake's FindEigen3.cmake module (due to missing EIGEN3_VERSION_STRING) endif() if(NOT Eigen3_FOUND) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index f94235038f..b47e7366c9 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -373,7 +373,7 @@ function(ocv_target_include_directories target) endif() endif() endforeach() - if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11) + if(HAVE_CUDA) include_directories(${__params}) include_directories(SYSTEM ${__system_params}) else() @@ -915,15 +915,9 @@ if(DEFINED ENV{BUILD_USE_SYMLINKS}) endif() OCV_OPTION(BUILD_USE_SYMLINKS "Use symlinks instead of files copying during build (and !!INSTALL!!)" (${__symlink_default}) IF (UNIX OR DEFINED __symlink_default)) -if(CMAKE_VERSION VERSION_LESS "3.2") - macro(ocv_cmake_byproducts var_name) - set(${var_name}) # nothing - endmacro() -else() - macro(ocv_cmake_byproducts var_name) - set(${var_name} BYPRODUCTS ${ARGN}) - endmacro() -endif() +macro(ocv_cmake_byproducts var_name) + set(${var_name} BYPRODUCTS ${ARGN}) +endmacro() set(OPENCV_DEPHELPER "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/dephelper" CACHE INTERNAL "") file(MAKE_DIRECTORY ${OPENCV_DEPHELPER}) @@ -1267,13 +1261,8 @@ function(ocv_install_target) # don't move this into global scope of this file: compiler settings (like MSVC variable) are not available during processing if(BUILD_SHARED_LIBS) # no defaults for static libs (modern CMake is required) - if(NOT CMAKE_VERSION VERSION_LESS 3.6.0) - option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default" ON) - option(INSTALL_PDB "Add install PDB rules" ON) - elseif(NOT CMAKE_VERSION VERSION_LESS 3.1.0) - option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default (not supported)" OFF) - option(INSTALL_PDB "Add install PDB rules" OFF) - endif() + option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default" ON) + option(INSTALL_PDB "Add install PDB rules" ON) endif() if(INSTALL_PDB AND NOT INSTALL_IGNORE_PDB @@ -1305,36 +1294,28 @@ function(ocv_install_target) # message(STATUS "Process ${__target} dst=${__dst}...") if(DEFINED __dst) - if(NOT CMAKE_VERSION VERSION_LESS 3.1.0) - set(__pdb_install_component "pdb") - if(DEFINED INSTALL_PDB_COMPONENT AND INSTALL_PDB_COMPONENT) - set(__pdb_install_component "${INSTALL_PDB_COMPONENT}") - endif() - set(__pdb_exclude_from_all "") - if(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL) - if(NOT CMAKE_VERSION VERSION_LESS 3.6.0) - set(__pdb_exclude_from_all EXCLUDE_FROM_ALL) - else() - message(WARNING "INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL requires CMake 3.6+") - endif() - endif() + set(__pdb_install_component "pdb") + if(DEFINED INSTALL_PDB_COMPONENT AND INSTALL_PDB_COMPONENT) + set(__pdb_install_component "${INSTALL_PDB_COMPONENT}") + endif() + set(__pdb_exclude_from_all "") + if(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL) + set(__pdb_exclude_from_all EXCLUDE_FROM_ALL) + endif() # message(STATUS "Adding PDB file installation rule: target=${__target} dst=${__dst} component=${__pdb_install_component}") - if("${__target_type}" STREQUAL "SHARED_LIBRARY" OR "${__target_type}" STREQUAL "MODULE_LIBRARY") - install(FILES "$" DESTINATION "${__dst}" - COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all}) - else() - # There is no generator expression similar to TARGET_PDB_FILE and TARGET_PDB_FILE can't be used: https://gitlab.kitware.com/cmake/cmake/issues/16932 - # However we still want .pdb files like: 'lib/Debug/opencv_core341d.pdb' or '3rdparty/lib/zlibd.pdb' - install(FILES "$/$/$>,$,$>.pdb" - DESTINATION "${__dst}" CONFIGURATIONS Debug - COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all}) - install(FILES "$/$/$>,$,$>.pdb" - DESTINATION "${__dst}" CONFIGURATIONS Release - COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all}) - endif() + if("${__target_type}" STREQUAL "SHARED_LIBRARY" OR "${__target_type}" STREQUAL "MODULE_LIBRARY") + install(FILES "$" DESTINATION "${__dst}" + COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all}) else() - message(WARNING "PDB files installation is not supported (need CMake >= 3.1.0)") + # There is no generator expression similar to TARGET_PDB_FILE and TARGET_PDB_FILE can't be used: https://gitlab.kitware.com/cmake/cmake/issues/16932 + # However we still want .pdb files like: 'lib/Debug/opencv_core341d.pdb' or '3rdparty/lib/zlibd.pdb' + install(FILES "$/$/$>,$,$>.pdb" + DESTINATION "${__dst}" CONFIGURATIONS Debug + COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all}) + install(FILES "$/$/$>,$,$>.pdb" + DESTINATION "${__dst}" CONFIGURATIONS Release + COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all}) endif() endif() endif() @@ -1628,45 +1609,19 @@ function(ocv_add_external_target name inc link def) endif() add_library(ocv.3rdparty.${name} INTERFACE ${imp}) if(def) - if(NOT (CMAKE_VERSION VERSION_LESS "3.11.0")) # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1264 : eliminates "Cannot specify compile definitions for imported target" error message - target_compile_definitions(ocv.3rdparty.${name} INTERFACE "${def}") - else() - set_target_properties(ocv.3rdparty.${name} PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${def}") - endif() + target_compile_definitions(ocv.3rdparty.${name} INTERFACE "${def}") endif() if(inc) - if(NOT (CMAKE_VERSION VERSION_LESS "3.11.0")) # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1264 : eliminates "Cannot specify compile definitions for imported target" error message - target_include_directories(ocv.3rdparty.${name} SYSTEM INTERFACE "$") - else() - set_target_properties(ocv.3rdparty.${name} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "$" - INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$" - ) - endif() + target_include_directories(ocv.3rdparty.${name} SYSTEM INTERFACE "$") endif() if(link) - # When cmake version is greater than or equal to 3.11, INTERFACE_LINK_LIBRARIES no longer applies to interface library - # See https://github.com/opencv/opencv/pull/18658 - if(CMAKE_VERSION VERSION_LESS 3.11) - set_target_properties(ocv.3rdparty.${name} PROPERTIES - INTERFACE_LINK_LIBRARIES "${link}") - else() - target_link_libraries(ocv.3rdparty.${name} INTERFACE ${link}) - endif() - endif() - # to install used target only upgrade CMake - if(NOT BUILD_SHARED_LIBS - AND CMAKE_VERSION VERSION_LESS "3.13.0" # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152 - ) - install(TARGETS ocv.3rdparty.${name} EXPORT OpenCVModules) + target_link_libraries(ocv.3rdparty.${name} INTERFACE ${link}) endif() endfunction() set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "" CACHE INTERNAL "") function(ocv_install_used_external_targets) - if(NOT BUILD_SHARED_LIBS - AND NOT (CMAKE_VERSION VERSION_LESS "3.13.0") # upgrade CMake: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152 - ) + if(NOT BUILD_SHARED_LIBS) foreach(tgt in ${ARGN}) if(tgt MATCHES "^ocv\.3rdparty\.") list(FIND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}" _found) @@ -1784,7 +1739,7 @@ endmacro() function(ocv_add_test_from_target test_name test_kind the_target) - if(CMAKE_VERSION VERSION_GREATER "2.8" AND NOT CMAKE_CROSSCOMPILING) + if(NOT CMAKE_CROSSCOMPILING) if(NOT "${test_kind}" MATCHES "^(Accuracy|Performance|Sanity)$") message(FATAL_ERROR "Unknown test kind : ${test_kind}") endif() @@ -1979,12 +1934,7 @@ macro(ocv_get_smart_file_name output_var fpath) endmacro() # Needed by install(DIRECTORY ...) -if(NOT CMAKE_VERSION VERSION_LESS 3.1) - set(compatible_MESSAGE_NEVER MESSAGE_NEVER) -else() - set(compatible_MESSAGE_NEVER "") -endif() - +set(compatible_MESSAGE_NEVER MESSAGE_NEVER) macro(ocv_git_describe var_name path) if(GIT_FOUND) diff --git a/modules/core/cmake/parallel/detect_openmp.cmake b/modules/core/cmake/parallel/detect_openmp.cmake index 39c050c78d..7b6afbd45e 100644 --- a/modules/core/cmake/parallel/detect_openmp.cmake +++ b/modules/core/cmake/parallel/detect_openmp.cmake @@ -1,7 +1,3 @@ -if(CMAKE_VERSION VERSION_LESS "3.9") - message(STATUS "OpenMP detection requires CMake 3.9+") # OpenMP::OpenMP_CXX target -endif() - find_package(OpenMP) if(OpenMP_FOUND) if(TARGET OpenMP::OpenMP_CXX) diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index de132aad53..c353a072f8 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -71,11 +71,9 @@ endforeach() include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL) # Standalone samples only -if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.1") +if(OpenCV_FOUND) add_subdirectory("example_cmake") endif() -if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.9" - AND NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND -) +if(OpenCV_FOUND AND NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND) add_subdirectory("tutorial_code/core/parallel_backend") endif() diff --git a/samples/opencl/CMakeLists.txt b/samples/opencl/CMakeLists.txt index d71e866ffa..a77e4e6a30 100644 --- a/samples/opencl/CMakeLists.txt +++ b/samples/opencl/CMakeLists.txt @@ -1,11 +1,5 @@ ocv_install_example_src(opencl *.cpp *.hpp CMakeLists.txt) -# cmake 3.1 needed for find_package(OpenCL) -if(CMAKE_VERSION VERSION_LESS "3.1") - message(STATUS "OpenCL samples require CMakes 3.1+") - return() -endif() - set(OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc diff --git a/samples/sycl/CMakeLists.txt b/samples/sycl/CMakeLists.txt index 3a3483bd21..442ef4e3f0 100644 --- a/samples/sycl/CMakeLists.txt +++ b/samples/sycl/CMakeLists.txt @@ -16,13 +16,6 @@ if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND OR OPENCV_SKIP_SAMPLES_BUILD return() endif() -if(CMAKE_VERSION VERSION_LESS "3.5") - message(STATUS "SYCL samples require CMake 3.5+") - return() -endif() - -cmake_policy(VERSION 3.5) - find_package(SYCL QUIET) # will oneAPI support this straightforward way? if(NOT SYCL_FOUND AND NOT OPENCV_SKIP_SAMPLES_SYCL_ONEDNN)