diff --git a/CMakeLists.txt b/CMakeLists.txt index cd93eaf2ec..074d972f10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,21 +301,19 @@ find_host_program(GIT_EXECUTABLE NAMES ${git_names} PATH_SUFFIXES Git/cmd Git/bi mark_as_advanced(GIT_EXECUTABLE) if(GIT_EXECUTABLE) - execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty --match "2.[0-9].[0-9]*" WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}" - OUTPUT_VARIABLE OPENCV_GIT_HASH_SORT + OUTPUT_VARIABLE OPENCV_VCSVERSION RESULT_VARIABLE GIT_RESULT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - if(GIT_RESULT EQUAL 0) - set(OPENCV_VCSVERSION "commit:${OPENCV_GIT_HASH_SORT}") - else() - set(OPENCV_VCSVERSION "exported") + if(NOT GIT_RESULT EQUAL 0) + set(OPENCV_VCSVERSION "unknown") endif() else() # We don't have git: - set(OPENCV_VCSVERSION "") + set(OPENCV_VCSVERSION "unknown") endif() @@ -523,10 +521,21 @@ if(NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio") endif() # ========================== C/C++ options ========================== +if(CMAKE_CXX_COMPILER_VERSION) + set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CXX_COMPILER_VERSION})") +elseif(CMAKE_COMPILER_IS_CLANGCXX) + set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CLANG_REGEX_VERSION})") +elseif(CMAKE_COMPILER_IS_GNUCXX) + set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_GCC_REGEX_VERSION})") +else() + set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}") +endif() +string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR) + status("") status(" C/C++:") status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO) -status(" C++ Compiler:" CMAKE_COMPILER_IS_GNUCXX THEN "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_GCC_REGEX_VERSION})" ELSE "${CMAKE_CXX_COMPILER}" ) +status(" C++ Compiler:" ${OPENCV_COMPILER_STR}) status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}) status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}) status(" C Compiler:" ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}) @@ -575,15 +584,16 @@ if(ANDROID) status(" Android ABI:" ${ANDROID_ABI}) status(" STL type:" ${ANDROID_STL}) status(" Native API level:" android-${ANDROID_NATIVE_API_LEVEL}) - status(" SDK target:" "${ANDROID_SDK_TARGET}") + android_get_compatible_target(android_sdk_target_status ${ANDROID_NATIVE_API_LEVEL} ${ANDROID_SDK_TARGET} 11) + status(" SDK target:" "${android_sdk_target_status}") if(BUILD_WITH_ANDROID_NDK) status(" Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})") elseif(BUILD_WITH_STANDALONE_TOOLCHAIN) status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}") endif() status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO) - status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO) - status(" Google Play package:" BUILD_ANDROID_PACKAGE THEN YES ELSE NO) + status(" Google Play package:" BUILD_ANDROID_PACKAGE THEN YES ELSE NO) + status(" Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO) endif() # ========================== GUI ========================== @@ -707,7 +717,7 @@ if(DEFINED WITH_PVAPI) endif(DEFINED WITH_PVAPI) if(DEFINED WITH_GIGEAPI) - status(" GigEVisionSDK:" HAVE_GIGE_API THEN YES ELSE NO) + status(" GigEVisionSDK:" HAVE_GIGE_API THEN YES ELSE NO) endif(DEFINED WITH_GIGEAPI) if(DEFINED WITH_QUICKTIME) @@ -753,30 +763,21 @@ endif(DEFINED WITH_XINE) status("") status(" Other third-party libraries:") -if(DEFINED WITH_IPP) - if(WITH_IPP AND IPP_FOUND) - status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]") - status(" at:" "${IPP_ROOT_DIR}") - else() - status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO) - endif() -endif(DEFINED WITH_IPP) - -if(DEFINED WITH_TBB) - status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO) -endif(DEFINED WITH_TBB) - -if(DEFINED WITH_CSTRIPES) - status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO) -endif(DEFINED WITH_CSTRIPES) - -if(DEFINED WITH_CUDA) - status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO) -endif(DEFINED WITH_CUDA) - -status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO) +if(WITH_IPP AND IPP_FOUND) + status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]") + status(" at:" "${IPP_ROOT_DIR}") +else() + status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO) +endif() -status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO) +status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO) +status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO) +status(" Use OpenMP:" HAVE_OPENMP THEN YES ELSE NO) +status(" Use GCD" HAVE_GCD THEN YES ELSE NO) +status(" Use Concurrency" HAVE_CONCURRENCY THEN YES ELSE NO) +status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO) +status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO) +status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO) if(HAVE_CUDA) status("") @@ -790,10 +791,23 @@ if(HAVE_CUDA) status(" Use fast math:" CUDA_FAST_MATH THEN YES ELSE NO) endif() +if(HAVE_OPENCL AND BUILD_opencv_ocl) + status("") + status(" OpenCL") + if(OPENCL_INCLUDE_DIR) + status(" Include:" ${OPENCL_INCLUDE_DIR}) + endif() + if(OPENCL_LIBRARIES) + status(" libraries:" ${OPENCL_LIBRARIES}) + endif() + status(" Use AMDFFT:" HAVE_CLAMDFFT THEN YES ELSE NO) + status(" Use AMDBLAS:" HAVE_CLAMDBLAS THEN YES ELSE NO) +endif() + # ========================== python ========================== status("") status(" Python:") -status(" Interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})" ELSE NO) +status(" Interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})" ELSE NO) if(BUILD_opencv_python) if(PYTHONLIBS_VERSION_STRING) status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO) @@ -804,6 +818,15 @@ if(BUILD_opencv_python) status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-") endif() +# ========================== java ========================== +status("") +status(" Java:") +status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO) +if(NOT ANDROID) + status(" JNI:" JNI_INCLUDE_DIRS THEN "${JNI_INCLUDE_DIRS}" ELSE NO) +endif() +status(" Java tests:" BUILD_TESTS AND (NOT ANDROID OR CAN_BUILD_ANDROID_PROJECTS) THEN YES ELSE NO) + # ========================== documentation ========================== if(BUILD_DOCS) status("") @@ -822,12 +845,7 @@ status("") status(" Tests and samples:") status(" Tests:" BUILD_TESTS AND HAVE_opencv_ts THEN YES ELSE NO) status(" Performance tests:" BUILD_PERF_TESTS AND HAVE_opencv_ts THEN YES ELSE NO) -status(" Examples:" BUILD_EXAMPLES THEN YES ELSE NO) - -if(ANDROID) - status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO) - status(" Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO) -endif() +status(" C/C++ Examples:" BUILD_EXAMPLES THEN YES ELSE NO) # ========================== auxiliary ========================== status("") diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake index d8c00cfdd3..7b6ff5e5bc 100644 --- a/cmake/OpenCVDetectCXXCompiler.cmake +++ b/cmake/OpenCVDetectCXXCompiler.cmake @@ -8,10 +8,12 @@ endif() if(NOT APPLE) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_COMPILER_IS_GNUCXX 1) + set(CMAKE_COMPILER_IS_CLANGCXX 1) set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE) endif() if(CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_COMPILER_IS_GNUCC 1) + set(CMAKE_COMPILER_IS_CLANGCC 1) set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE) endif() endif() @@ -44,16 +46,24 @@ if(MSVC AND CMAKE_C_COMPILER MATCHES "icc") set(CV_ICC __INTEL_COMPILER_FOR_WINDOWS) endif() -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR (UNIX AND CV_ICC)) - set(CV_COMPILER_IS_GNU TRUE) -else() - set(CV_COMPILER_IS_GNU FALSE) -endif() - # ---------------------------------------------------------------------------- # Detect GNU version: # ---------------------------------------------------------------------------- -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_CLANGCXX) + set(CMAKE_GCC_REGEX_VERSION "4.2.1") + set(CMAKE_OPENCV_GCC_VERSION_MAJOR 4) + set(CMAKE_OPENCV_GCC_VERSION_MINOR 2) + set(CMAKE_OPENCV_GCC_VERSION 42) + set(CMAKE_OPENCV_GCC_VERSION_NUM 402) + + execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v + ERROR_VARIABLE CMAKE_OPENCV_CLANG_VERSION_FULL + ERROR_STRIP_TRAILING_WHITESPACE) + + string(REGEX MATCH "version.*$" CMAKE_OPENCV_CLANG_VERSION_FULL "${CMAKE_OPENCV_CLANG_VERSION_FULL}") + string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_CLANG_REGEX_VERSION "${CMAKE_OPENCV_CLANG_VERSION_FULL}") + +elseif(CMAKE_COMPILER_IS_GNUCXX) execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 86815c0d47..b94c357699 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -7,11 +7,6 @@ if(WITH_TBB) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake") endif(WITH_TBB) -# --- C= --- -if(WITH_CSTRIPES) - include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake") -endif(WITH_CSTRIPES) - # --- IPP --- ocv_clear_vars(IPP_FOUND) if(WITH_IPP) @@ -43,3 +38,35 @@ if(WITH_EIGEN) set(HAVE_EIGEN 1) endif() endif(WITH_EIGEN) + +# --- C= --- +if(WITH_CSTRIPES AND NOT HAVE_TBB) + include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake") +else() + set(HAVE_CSTRIPES 0) +endif() + +# --- OpenMP --- +if(NOT HAVE_TBB AND NOT HAVE_CSTRIPES) + set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/omptest.cpp") + FILE(WRITE "${_fname}" "#ifndef _OPENMP\n#error\n#endif\nint main() { return 0; }\n") + TRY_COMPILE(HAVE_OPENMP "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp" "${_fname}") +else() + set(HAVE_OPENMP 0) +endif() + +# --- GCD --- +if(APPLE AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES AND NOT HAVE_OPENMP) + set(HAVE_GCD 1) +else() + set(HAVE_GCD 0) +endif() + +# --- Concurrency --- +if(MSVC AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES AND NOT HAVE_OPENMP) + set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concurrencytest.cpp") + FILE(WRITE "${_fname}" "#if _MSC_VER < 1600\n#error\n#endif\nint main() { return 0; }\n") + TRY_COMPILE(HAVE_CONCURRENCY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp" "${_fname}") +else() + set(HAVE_CONCURRENCY 0) +endif() diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index f40cc6d19c..db24c99708 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -141,7 +141,7 @@ macro(ocv_warnings_disable) set(${var} "${${var}} ${warning}") endforeach() endforeach() - elseif(CV_COMPILER_IS_GNU AND _gxx_warnings AND _flag_vars) + elseif((CMAKE_COMPILER_IS_GNUCXX OR (UNIX AND CV_ICC)) AND _gxx_warnings AND _flag_vars) foreach(var ${_flag_vars}) foreach(warning ${_gxx_warnings}) if(NOT warning MATCHES "^-Wno-")