Merge pull request #14341 from alalek:cmake_fix_pkgconfig_libs

This commit is contained in:
Alexander Alekhin 2019-04-16 19:04:06 +00:00
commit 6d3ae8d4ca
8 changed files with 132 additions and 100 deletions

View File

@ -1326,15 +1326,15 @@ endif()
if(WITH_GTK OR HAVE_GTK) if(WITH_GTK OR HAVE_GTK)
if(HAVE_GTK3) if(HAVE_GTK3)
status(" GTK+:" "YES (ver ${ALIASOF_gtk+-3.0_VERSION})") status(" GTK+:" "YES (ver ${GTK3_VERSION})")
elseif(HAVE_GTK) elseif(HAVE_GTK)
status(" GTK+:" "YES (ver ${ALIASOF_gtk+-2.0_VERSION})") status(" GTK+:" "YES (ver ${GTK2_VERSION})")
else() else()
status(" GTK+:" "NO") status(" GTK+:" "NO")
endif() endif()
if(HAVE_GTK) if(HAVE_GTK)
status( " GThread :" HAVE_GTHREAD THEN "YES (ver ${ALIASOF_gthread-2.0_VERSION})" ELSE NO) status( " GThread :" HAVE_GTHREAD THEN "YES (ver ${GTHREAD_VERSION})" ELSE NO)
status( " GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${ALIASOF_gtkglext-1.0_VERSION})" ELSE NO) status( " GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${GTKGLEXT_VERSION})" ELSE NO)
endif() endif()
endif() endif()
@ -1411,9 +1411,9 @@ endif()
if(WITH_1394 OR HAVE_DC1394) if(WITH_1394 OR HAVE_DC1394)
if (HAVE_DC1394_2) if (HAVE_DC1394_2)
status(" DC1394:" "YES (ver ${ALIASOF_libdc1394-2_VERSION})") status(" DC1394:" "YES (ver ${DC1394_2_VERSION})")
elseif (HAVE_DC1394) elseif (HAVE_DC1394)
status(" DC1394:" "YES (ver ${ALIASOF_libdc1394_VERSION})") status(" DC1394:" "YES (ver ${DC1394_VERSION})")
else() else()
status(" DC1394:" "NO") status(" DC1394:" "NO")
endif() endif()
@ -1435,7 +1435,7 @@ if(WITH_FFMPEG OR HAVE_FFMPEG)
endif() endif()
if(WITH_GSTREAMER OR HAVE_GSTREAMER) if(WITH_GSTREAMER OR HAVE_GSTREAMER)
status(" GStreamer:" HAVE_GSTREAMER THEN "" ELSE NO) status(" GStreamer:" HAVE_GSTREAMER THEN "YES" ELSE NO)
if(HAVE_GSTREAMER) if(HAVE_GSTREAMER)
status(" base:" "YES (ver ${GSTREAMER_BASE_VERSION})") status(" base:" "YES (ver ${GSTREAMER_BASE_VERSION})")
status(" video:" "YES (ver ${GSTREAMER_VIDEO_VERSION})") status(" video:" "YES (ver ${GSTREAMER_VIDEO_VERSION})")
@ -1477,12 +1477,12 @@ if(APPLE)
endif() endif()
if(WITH_UNICAP OR HAVE_UNICAP) if(WITH_UNICAP OR HAVE_UNICAP)
status(" UniCap:" HAVE_UNICAP THEN "YES (ver ${ALIASOF_libunicap_VERSION})" ELSE NO) status(" UniCap:" HAVE_UNICAP THEN "YES (ver ${UNICAP_libunicap_VERSION})" ELSE NO)
status(" UniCap ucil:" HAVE_UNICAP_UCIL THEN "YES (ver ${ALIASOF_libucil_VERSION})" ELSE NO) status(" UniCap ucil:" HAVE_UNICAP THEN "YES (ver ${UNICAP_libucil_VERSION})" ELSE NO)
endif() endif()
if(WITH_V4L OR WITH_LIBV4L OR HAVE_LIBV4L OR HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO) if(WITH_V4L OR WITH_LIBV4L OR HAVE_LIBV4L OR HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
status(" libv4l/libv4l2:" HAVE_LIBV4L THEN "${ALIASOF_libv4l1_VERSION} / ${ALIASOF_libv4l2_VERSION}" ELSE "NO") status(" libv4l/libv4l2:" HAVE_LIBV4L THEN "${LIBV4L_libv4l1_VERSION} / ${LIBV4L_libv4l2_VERSION}" ELSE "NO")
ocv_build_features_string(v4l_status ocv_build_features_string(v4l_status
IF HAVE_CAMV4L THEN "linux/videodev.h" IF HAVE_CAMV4L THEN "linux/videodev.h"
IF HAVE_CAMV4L2 THEN "linux/videodev2.h" IF HAVE_CAMV4L2 THEN "linux/videodev2.h"
@ -1505,7 +1505,7 @@ if(WITH_XIMEA OR HAVE_XIMEA)
endif() endif()
if(WITH_XINE OR HAVE_XINE) if(WITH_XINE OR HAVE_XINE)
status(" Xine:" HAVE_XINE THEN "YES (ver ${ALIASOF_libxine_VERSION})" ELSE NO) status(" Xine:" HAVE_XINE THEN "YES (ver ${XINE_VERSION})" ELSE NO)
endif() endif()
if(WITH_INTELPERC OR HAVE_INTELPERC) if(WITH_INTELPERC OR HAVE_INTELPERC)

View File

@ -42,24 +42,34 @@ endif()
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT) ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT) if(WITH_GTK AND NOT HAVE_QT)
if(NOT WITH_GTK_2_X) if(NOT WITH_GTK_2_X)
CHECK_MODULE(gtk+-3.0 HAVE_GTK3 HIGHGUI) ocv_check_modules(GTK3 gtk+-3.0)
if(HAVE_GTK3) if(HAVE_GTK3)
ocv_append_build_options(HIGHGUI GTK3)
set(HAVE_GTK TRUE) set(HAVE_GTK TRUE)
endif() endif()
endif() endif()
if(NOT HAVE_GTK) if(NOT HAVE_GTK)
CHECK_MODULE(gtk+-2.0 HAVE_GTK HIGHGUI) ocv_check_modules(GTK2 gtk+-2.0)
if(HAVE_GTK AND (ALIASOF_gtk+-2.0_VERSION VERSION_LESS MIN_VER_GTK)) if(HAVE_GTK2)
message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${ALIASOF_gtk+-2.0_VERSION} found)") if (GTK2_VERSION VERSION_LESS MIN_VER_GTK)
set(HAVE_GTK FALSE) message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${GTK2_VERSION} found)")
else()
ocv_append_build_options(HIGHGUI GTK2)
set(HAVE_GTK TRUE)
endif() endif()
endif() endif()
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD HIGHGUI) endif()
ocv_check_modules(GTHREAD gthread-2.0)
if(HAVE_GTK AND NOT HAVE_GTHREAD) if(HAVE_GTK AND NOT HAVE_GTHREAD)
message(FATAL_ERROR "gthread not found. This library is required when building with GTK support") message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
else()
ocv_append_build_options(HIGHGUI GTHREAD)
endif() endif()
if(WITH_OPENGL AND NOT HAVE_GTK3) if(WITH_OPENGL AND NOT HAVE_GTK3)
CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT HIGHGUI) ocv_check_modules(GTKGLEXT gtkglext-1.0)
if(HAVE_GTKGLEXT)
ocv_append_build_options(GTKGLEXT GTHREAD)
endif()
endif() endif()
endif() endif()

View File

@ -59,14 +59,13 @@ endif(WITH_EIGEN)
ocv_clear_vars(HAVE_CLP) ocv_clear_vars(HAVE_CLP)
if(WITH_CLP) if(WITH_CLP)
if(UNIX) if(UNIX)
PKG_CHECK_MODULES(CLP clp) ocv_check_modules(CLP clp)
if(CLP_FOUND) if(CLP_FOUND)
set(HAVE_CLP TRUE) set(HAVE_CLP TRUE)
if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "") if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "")
ocv_include_directories(${CLP_INCLUDE_DIRS}) ocv_include_directories(${CLP_INCLUDE_DIRS})
endif() endif()
link_directories(${CLP_LIBRARY_DIRS}) list(APPEND OPENCV_LINKER_LIBS ${CLP_LIBRARIES})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES})
endif() endif()
endif() endif()

View File

@ -27,50 +27,41 @@ if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
ENDIF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY) ENDIF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
else(WIN32) else(WIN32)
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE VIDEOIO) ocv_check_modules(GSTREAMER-1.0 gstreamer-base-1.0 gstreamer-video-1.0 gstreamer-app-1.0 gstreamer-riff-1.0 gstreamer-pbutils-1.0)
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO VIDEOIO) if(HAVE_GSTREAMER-1.0)
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP VIDEOIO)
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF VIDEOIO)
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS VIDEOIO)
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
set(HAVE_GSTREAMER TRUE) set(HAVE_GSTREAMER TRUE)
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION}) ocv_append_build_options(VIDEOIO GSTREAMER-1.0)
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION}) set(GSTREAMER_BASE_VERSION ${GSTREAMER-1.0_gstreamer-base-1.0_VERSION})
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION}) set(GSTREAMER_VIDEO_VERSION ${GSTREAMER-1.0_gstreamer-video-1.0_VERSION})
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION}) set(GSTREAMER_APP_VERSION ${GSTREAMER-1.0_gstreamer-app-1.0_VERSION})
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION}) set(GSTREAMER_RIFF_VERSION ${GSTREAMER-1.0_gstreamer-riff-1.0_VERSION})
set(GSTREAMER_PBUTILS_VERSION ${GSTREAMER-1.0_gstreamer-pbutils-1.0_VERSION})
endif() endif()
endif(WIN32) endif(WIN32)
endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10) endif()
# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it # if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10) if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE VIDEOIO) ocv_check_modules(GSTREAMER-0.10 gstreamer-base-0.10 gstreamer-video-0.10 gstreamer-app-0.10 gstreamer-riff-0.10 gstreamer-pbutils-0.10)
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO VIDEOIO) if(HAVE_GSTREAMER-0.10)
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP VIDEOIO)
CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF VIDEOIO)
CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS VIDEOIO)
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
set(HAVE_GSTREAMER TRUE) set(HAVE_GSTREAMER TRUE)
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-0.10_VERSION}) ocv_append_build_options(VIDEOIO GSTREAMER-0.10)
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-0.10_VERSION}) set(GSTREAMER_BASE_VERSION ${GSTREAMER-0.10_gstreamer-base-0.10_VERSION})
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-0.10_VERSION}) set(GSTREAMER_VIDEO_VERSION ${GSTREAMER-0.10_gstreamer-video-0.10_VERSION})
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-0.10_VERSION}) set(GSTREAMER_APP_VERSION ${GSTREAMER-0.10_gstreamer-app-0.10_VERSION})
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-0.10_VERSION}) set(GSTREAMER_RIFF_VERSION ${GSTREAMER-0.10_gstreamer-riff-0.10_VERSION})
set(GSTREAMER_PBUTILS_VERSION ${GSTREAMER-0.10_gstreamer-pbutils-0.10_VERSION})
endif()
endif() endif()
endif(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
# --- unicap --- # --- unicap ---
ocv_clear_vars(HAVE_UNICAP) ocv_clear_vars(HAVE_UNICAP)
if(WITH_UNICAP) if(WITH_UNICAP)
CHECK_MODULE(libunicap HAVE_UNICAP_ VIDEOIO) ocv_check_modules(HAVE_UNICAP libunicap libucil)
CHECK_MODULE(libucil HAVE_UNICAP_UCIL VIDEOIO) if(HAVE_UNICAP)
if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL) ocv_append_build_options(VIDEOIO UNICAP)
set(HAVE_UNICAP TRUE) endif()
endif() endif()
endif(WITH_UNICAP)
# --- PvApi --- # --- PvApi ---
ocv_clear_vars(HAVE_PVAPI) ocv_clear_vars(HAVE_PVAPI)
@ -120,7 +111,7 @@ endif(WITH_GIGEAPI)
# --- Aravis SDK --- # --- Aravis SDK ---
ocv_clear_vars(HAVE_ARAVIS_API) ocv_clear_vars(HAVE_ARAVIS_API)
if(WITH_ARAVIS) if(WITH_ARAVIS)
check_module(glib-2.0 HAVE_ARAVIS_GLIB VIDEOIO) ocv_check_modules(ARAVIS_GLIB glib-2.0)
if(HAVE_ARAVIS_GLIB) if(HAVE_ARAVIS_GLIB)
find_path(ARAVIS_INCLUDE_PATH "arv.h" find_path(ARAVIS_INCLUDE_PATH "arv.h"
PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432 PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432
@ -128,6 +119,7 @@ if(WITH_ARAVIS)
DOC "The path to Aravis SDK headers") DOC "The path to Aravis SDK headers")
find_library(ARAVIS_LIBRARIES NAMES "aravis-0.6" "aravis-0.4" ) find_library(ARAVIS_LIBRARIES NAMES "aravis-0.6" "aravis-0.4" )
if(ARAVIS_LIBRARIES AND ARAVIS_INCLUDE_PATH) if(ARAVIS_LIBRARIES AND ARAVIS_INCLUDE_PATH)
ocv_append_build_options(VIDEOIO ARAVIS_GLIB)
set(HAVE_ARAVIS_API TRUE) set(HAVE_ARAVIS_API TRUE)
endif() endif()
else() else()
@ -139,6 +131,7 @@ endif(WITH_ARAVIS)
ocv_clear_vars(HAVE_DC1394 HAVE_DC1394_2) ocv_clear_vars(HAVE_DC1394 HAVE_DC1394_2)
if(WITH_1394) if(WITH_1394)
if(WIN32 AND MINGW) if(WIN32 AND MINGW)
# TODO remove this, use pkgconfig from MinGW instead
find_path(CMU1394_INCLUDE_PATH "/1394common.h" find_path(CMU1394_INCLUDE_PATH "/1394common.h"
PATH_SUFFIXES include PATH_SUFFIXES include
DOC "The path to cmu1394 headers") DOC "The path to cmu1394 headers")
@ -153,36 +146,42 @@ if(WITH_1394)
endif() endif()
endif() endif()
if(HAVE_DC1394_2) if(HAVE_DC1394_2)
ocv_parse_pkg("libdc1394-2" "${DC1394_2_LIB_DIR}/pkgconfig" "") ocv_parse_pkg(DC1394_2_VERSION "libdc1394-2" "${DC1394_2_LIB_DIR}/pkgconfig")
ocv_include_directories(${DC1394_2_INCLUDE_PATH}) ocv_include_directories(${DC1394_2_INCLUDE_PATH})
set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES} set(VIDEOIO_LIBRARIES ${VIDEOIO_LIBRARIES}
"${DC1394_2_LIB_DIR}/libdc1394.a" "${DC1394_2_LIB_DIR}/libdc1394.a"
"${CMU1394_LIB_DIR}/lib1394camera.a") "${CMU1394_LIB_DIR}/lib1394camera.a")
endif(HAVE_DC1394_2)
else(WIN32 AND MINGW)
CHECK_MODULE(libdc1394-2 HAVE_DC1394_2 VIDEOIO)
if(NOT HAVE_DC1394_2)
CHECK_MODULE(libdc1394 HAVE_DC1394 VIDEOIO)
endif() endif()
endif(WIN32 AND MINGW) endif()
endif(WITH_1394) if(NOT HAVE_DC1394_2)
ocv_check_modules(DC1394_2 libdc1394-2)
if(HAVE_DC1394_2)
ocv_append_build_options(VIDEOIO DC1394_2)
else()
ocv_check_modules(DC1394 libdc1394)
if(HAVE_DC1394)
ocv_append_build_options(VIDEOIO DC1394)
endif()
endif()
endif()
endif()
# --- xine --- # --- xine ---
ocv_clear_vars(HAVE_XINE) ocv_clear_vars(HAVE_XINE)
if(WITH_XINE) if(WITH_XINE)
CHECK_MODULE(libxine HAVE_XINE VIDEOIO) ocv_check_modules(XINE libxine)
if(HAVE_XINE)
ocv_append_build_options(VIDEOIO XINE)
endif()
endif(WITH_XINE) endif(WITH_XINE)
# --- V4L --- # --- V4L ---
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO) ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
if(WITH_V4L) if(WITH_V4L)
if(WITH_LIBV4L) if(WITH_LIBV4L)
CHECK_MODULE(libv4l1 HAVE_LIBV4L1 VIDEOIO) ocv_check_modules(LIBV4L libv4l1 libv4l2)
CHECK_MODULE(libv4l2 HAVE_LIBV4L2 VIDEOIO) if(HAVE_LIBV4L)
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2) ocv_append_build_options(VIDEOIO LIBV4L)
set(HAVE_LIBV4L YES)
else()
set(HAVE_LIBV4L NO)
endif() endif()
endif() endif()
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L) CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
@ -323,8 +322,11 @@ endif()
# --- gPhoto2 --- # --- gPhoto2 ---
ocv_clear_vars(HAVE_GPHOTO2) ocv_clear_vars(HAVE_GPHOTO2)
if(WITH_GPHOTO2) if(WITH_GPHOTO2)
CHECK_MODULE(libgphoto2 HAVE_GPHOTO2 VIDEOIO) ocv_check_modules(GPHOTO2 libgphoto2)
endif(WITH_GPHOTO2) if(HAVE_GPHOTO2)
ocv_append_build_options(VIDEOIO GPHOTO2)
endif()
endif()
# --- VA & VA_INTEL --- # --- VA & VA_INTEL ---
if(WITH_VA_INTEL) if(WITH_VA_INTEL)

View File

@ -701,7 +701,7 @@ endfunction()
# Usage: ocv_append_build_options(HIGHGUI FFMPEG) # Usage: ocv_append_build_options(HIGHGUI FFMPEG)
macro(ocv_append_build_options var_prefix pkg_prefix) macro(ocv_append_build_options var_prefix pkg_prefix)
foreach(suffix INCLUDE_DIRS LIBRARIES LIBRARY_DIRS) foreach(suffix INCLUDE_DIRS LIBRARIES LIBRARY_DIRS LINK_LIBRARIES)
if(${pkg_prefix}_${suffix}) if(${pkg_prefix}_${suffix})
list(APPEND ${var_prefix}_${suffix} ${${pkg_prefix}_${suffix}}) list(APPEND ${var_prefix}_${suffix} ${${pkg_prefix}_${suffix}})
list(REMOVE_DUPLICATES ${var_prefix}_${suffix}) list(REMOVE_DUPLICATES ${var_prefix}_${suffix})
@ -739,7 +739,9 @@ macro(ocv_check_modules define)
endif() endif()
unset(${define}_${__modname}_FOUND) unset(${define}_${__modname}_FOUND)
endforeach() endforeach()
if(COMMAND pkg_check_modules)
pkg_check_modules(${define} ${ARGN}) pkg_check_modules(${define} ${ARGN})
endif()
if(${define}_FOUND) if(${define}_FOUND)
set(HAVE_${define} 1) set(HAVE_${define} 1)
endif() endif()
@ -753,29 +755,47 @@ macro(ocv_check_modules define)
set(${define}_${__modname}_FOUND 1) set(${define}_${__modname}_FOUND 1)
endif() endif()
endforeach() endforeach()
endmacro() if(${define}_FOUND AND ${define}_LIBRARIES)
if(${define}_LINK_LIBRARIES_XXXXX) # CMake 3.12+: https://gitlab.kitware.com/cmake/cmake/merge_requests/2068
set(${define}_LIBRARIES "${${define}_LINK_LIBRARIES}" CACHE INTERNAL "")
# Macro that checks if module has been installed. else()
# After it adds module to build and define unset(_libs) # absolute paths
# constants passed as second arg unset(_libs_paths) # -L args
macro(CHECK_MODULE module_name define cv_module) foreach(flag ${${define}_LDFLAGS})
set(${define} 0) if(flag MATCHES "^-L(.*)")
if(PKG_CONFIG_FOUND) list(APPEND _libs_paths ${CMAKE_MATCH_1})
set(ALIAS ALIASOF_${module_name}) elseif(IS_ABSOLUTE "${flag}")
set(ALIAS_FOUND ${ALIAS}_FOUND) list(APPEND _libs "${flag}")
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS) elseif(flag MATCHES "^-l(.*)")
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS) set(_lib "${CMAKE_MATCH_1}")
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES) if(_libs_paths)
find_library(pkgcfg_lib_${define}_${_lib} NAMES ${_lib}
PKG_CHECK_MODULES(${ALIAS} ${module_name}) HINTS ${_libs_paths} NO_DEFAULT_PATH)
if(${ALIAS_FOUND}) endif()
set(${define} 1) find_library(pkgcfg_lib_${define}_${_lib} NAMES ${_lib})
ocv_append_build_options(${cv_module} ${ALIAS}) mark_as_advanced(pkgcfg_lib_${define}_${_lib})
if(pkgcfg_lib_${define}_${_lib})
list(APPEND _libs "${pkgcfg_lib_${define}_${_lib}}")
else()
message(WARNING "ocv_check_modules(${define}): can't find library '${_lib}'. Specify 'pkgcfg_lib_${define}_${_lib}' manualy")
list(APPEND _libs "${_lib}")
endif()
else()
# -pthread
#message(WARNING "ocv_check_modules(${define}): unknown LDFLAG '${flag}'")
endif()
endforeach()
set(${define}_LINK_LIBRARIES "${_libs}")
set(${define}_LIBRARIES "${_libs}" CACHE INTERNAL "")
unset(_lib)
unset(_libs)
unset(_libs_paths)
endif() endif()
endif() endif()
endmacro() endmacro()
if(NOT DEFINED CMAKE_ARGC) # Guard CMake standalone invocations if(NOT DEFINED CMAKE_ARGC) # Guard CMake standalone invocations
# Use this option carefully, CMake's install() will install symlinks instead of real files # Use this option carefully, CMake's install() will install symlinks instead of real files
@ -1290,11 +1310,12 @@ macro(ocv_parse_header2 LIBNAME HDR_PATH VARNAME)
endif() endif()
endmacro() endmacro()
# TODO remove this
# read single version info from the pkg file # read single version info from the pkg file
macro(ocv_parse_pkg LIBNAME PKG_PATH SCOPE) macro(ocv_parse_pkg ver_varname LIBNAME PKG_PATH)
if(EXISTS "${PKG_PATH}/${LIBNAME}.pc") if(EXISTS "${PKG_PATH}/${LIBNAME}.pc")
file(STRINGS "${PKG_PATH}/${LIBNAME}.pc" line_to_parse REGEX "^Version:[ \t]+[0-9.]*.*$" LIMIT_COUNT 1) file(STRINGS "${PKG_PATH}/${LIBNAME}.pc" line_to_parse REGEX "^Version:[ \t]+[0-9.]*.*$" LIMIT_COUNT 1)
STRING(REGEX REPLACE ".*Version: ([^ ]+).*" "\\1" ALIASOF_${LIBNAME}_VERSION "${line_to_parse}" ) STRING(REGEX REPLACE ".*Version: ([^ ]+).*" "\\1" ${ver_varname} "${line_to_parse}" )
endif() endif()
endmacro() endmacro()

View File

@ -128,8 +128,8 @@ elseif(HAVE_COCOA)
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa") list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
endif() endif()
if(UNIX) if(TRUE)
#these variables are set by CHECK_MODULE macro # these variables are set by 'ocv_append_build_options(HIGHGUI ...)'
foreach(P ${HIGHGUI_INCLUDE_DIRS}) foreach(P ${HIGHGUI_INCLUDE_DIRS})
ocv_include_directories(${P}) ocv_include_directories(${P})
endforeach() endforeach()

View File

@ -111,8 +111,8 @@ if(APPLE_FRAMEWORK)
list(APPEND IMGCODECS_LIBRARIES "-framework UIKit") list(APPEND IMGCODECS_LIBRARIES "-framework UIKit")
endif() endif()
if(UNIX) if(TRUE)
#these variables are set by CHECK_MODULE macro # these variables are set by 'ocv_append_build_options(IMGCODECS ...)'
foreach(P ${IMGCODECS_INCLUDE_DIRS}) foreach(P ${IMGCODECS_INCLUDE_DIRS})
ocv_include_directories(${P}) ocv_include_directories(${P})
endforeach() endforeach()

View File

@ -233,8 +233,8 @@ if(IOS)
list(APPEND VIDEOIO_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework UIKit") list(APPEND VIDEOIO_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework UIKit")
endif() endif()
if(UNIX) if(TRUE)
#these variables are set by CHECK_MODULE macro # these variables are set by 'ocv_append_build_options(VIDEOIO ...)'
foreach(P ${VIDEOIO_INCLUDE_DIRS}) foreach(P ${VIDEOIO_INCLUDE_DIRS})
ocv_include_directories(${P}) ocv_include_directories(${P})
endforeach() endforeach()