Detect cross-cutting frameworks before libraries so the latter can use them

This commit is contained in:
Ivan Pozdeev 2018-10-31 23:28:18 +03:00
parent cc2f8f1778
commit dbc6fe3a0f
3 changed files with 46 additions and 41 deletions

View File

@ -634,6 +634,8 @@ if(ANDROID AND WITH_CPUFEATURES)
set(HAVE_CPUFEATURES 1)
endif()
include(cmake/OpenCVFindFrameworks.cmake)
include(cmake/OpenCVFindLibsGrfmt.cmake)
include(cmake/OpenCVFindLibsGUI.cmake)
include(cmake/OpenCVFindLibsVideo.cmake)

View File

@ -0,0 +1,44 @@
# ----------------------------------------------------------------------------
# Detect frameworks that may be used by 3rd-party libraries as well as OpenCV
# ----------------------------------------------------------------------------
# --- C= ---
if(WITH_CSTRIPES AND NOT HAVE_TBB)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake")
else()
set(HAVE_CSTRIPES 0)
endif()
# --- GCD ---
if(APPLE AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES)
set(HAVE_GCD 1)
else()
set(HAVE_GCD 0)
endif()
# --- Concurrency ---
if(MSVC AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES)
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}" "${_fname}")
file(REMOVE "${_fname}")
else()
set(HAVE_CONCURRENCY 0)
endif()
# --- OpenMP ---
if(WITH_OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set(HAVE_OPENMP "${OPENMP_FOUND}")
endif()
ocv_clear_vars(HAVE_PTHREADS_PF)
if(WITH_PTHREADS_PF AND HAVE_PTHREAD)
set(HAVE_PTHREADS_PF 1)
else()
set(HAVE_PTHREADS_PF 0)
endif()

View File

@ -92,44 +92,3 @@ if(WITH_CLP)
endif()
endif()
endif(WITH_CLP)
# --- C= ---
if(WITH_CSTRIPES AND NOT HAVE_TBB)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake")
else()
set(HAVE_CSTRIPES 0)
endif()
# --- GCD ---
if(APPLE AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES)
set(HAVE_GCD 1)
else()
set(HAVE_GCD 0)
endif()
# --- Concurrency ---
if(MSVC AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES)
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}" "${_fname}")
file(REMOVE "${_fname}")
else()
set(HAVE_CONCURRENCY 0)
endif()
# --- OpenMP ---
if(WITH_OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
set(HAVE_OPENMP "${OPENMP_FOUND}")
endif()
ocv_clear_vars(HAVE_PTHREADS_PF)
if(WITH_PTHREADS_PF AND HAVE_PTHREAD)
set(HAVE_PTHREADS_PF 1)
else()
set(HAVE_PTHREADS_PF 0)
endif()