diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-04-05 21:41:26 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-04-05 21:41:26 +0200 |
commit | 8815732f37c5899dbe65d507c082c0c62250ab7d (patch) | |
tree | d350ed3f031447f07794ae4ce51e6f6b00f4bfeb | |
parent | 61592edd7b953c35167fb95f1d26aecc4e5c594a (diff) |
cmake: install shared opencv libraries
Issue: #867
Requested by: @Slion
-rw-r--r-- | cmake/opentrack-boilerplate.cmake | 27 | ||||
-rw-r--r-- | cmake/opentrack-opencv.cmake | 12 | ||||
-rw-r--r-- | cmake/opentrack-qt.cmake | 41 | ||||
-rw-r--r-- | cv/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tracker-aruco/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tracker-kinect-face/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tracker-pt/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tracker-pt/module/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tracker-wii/CMakeLists.txt | 2 | ||||
-rw-r--r-- | video-opencv/CMakeLists.txt | 2 |
10 files changed, 48 insertions, 46 deletions
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index eaccfc4e..5a4d7c71 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -242,3 +242,30 @@ function(otr_add_target_dirs var) list(SORT projects) set("${var}" "${projects}" PARENT_SCOPE) endfunction() + +function(otr_pdb_for_dll varname path) + set("${varname}" "" PARENT_SCOPE) + get_filename_component(dir "${path}" DIRECTORY) + get_filename_component(name-only "${path}" NAME_WE) + set(pdb-path "${dir}/${name-only}.pdb") + if(EXISTS "${pdb-path}") + set("${varname}" "${pdb-path}" PARENT_SCOPE) + endif() +endfunction() + +function(otr_install_lib target dest) + get_property(path TARGET "${target}" PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}") + if(path STREQUAL "") + get_property(path TARGET "${target}" PROPERTY "LOCATION") + endif() + if(path STREQUAL "") + message(FATAL_ERROR "Can't find ${target}") + endif() + string(TOLOWER "${path}" path_) + if(NOT path_ MATCHES "\\.(a|lib)$") + if(MSVC AND opentrack_install-debug-info) + otr_pdb_for_dll(pdb-path "${opentrack-hier-debug}") + endif() + install(FILES "${path}" DESTINATION "${dest}") + endif() +endfunction() diff --git a/cmake/opentrack-opencv.cmake b/cmake/opentrack-opencv.cmake new file mode 100644 index 00000000..4504e59f --- /dev/null +++ b/cmake/opentrack-opencv.cmake @@ -0,0 +1,12 @@ +include_guard(GLOBAL) + +include(opentrack-boilerplate) +find_package(OpenCV QUIET) + +function(otr_install_opencv_libs) + foreach(k core features2d calib3d flann imgcodecs imgproc videoio) + otr_install_lib("opencv_${k}" "${}opentrack-hier-pfx}") + endforeach() +endfunction() + +otr_install_opencv_libs() diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake index 5a8c27a0..fbea4d1c 100644 --- a/cmake/opentrack-qt.cmake +++ b/cmake/opentrack-qt.cmake @@ -7,49 +7,12 @@ find_package(Qt5 COMPONENTS SerialPort QUIET) set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES}) -function(otr_pdb_for_dll varname path) - set("${varname}" "" PARENT_SCOPE) - get_filename_component(dir "${path}" DIRECTORY) - get_filename_component(name-only "${path}" NAME_WE) - set(pdb-path "${dir}/${name-only}.pdb") - if(EXISTS "${pdb-path}") - set("${varname}" "${pdb-path}" PARENT_SCOPE) - endif() -endfunction() - function(otr_install_qt_libs) if(WIN32) foreach(i Qt5::Core Qt5::Gui Qt5::Network Qt5::SerialPort Qt5::Widgets) - get_property(path TARGET "${i}" PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}") - if(path STREQUAL "") - get_property(path TARGET "${i}" PROPERTY LOCATION) - endif() - if(path STREQUAL "") - message(FATAL_ERROR "can't find ${i}") - endif() - install(FILES "${path}" DESTINATION .) - if(MSVC AND opentrack_install-debug-info) - otr_pdb_for_dll(pdb-path "${path}") - if(pdb-path) - install(FILES "${pdb-path}" DESTINATION "${opentrack-hier-debug}") - endif() - endif() + otr_install_lib(${i} ".") endforeach() - - get_property(path TARGET Qt5::QWindowsIntegrationPlugin PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}") - if(path STREQUAL "") - get_property(path TARGET Qt5::QWindowsIntegrationPlugin PROPERTY LOCATION) - endif() - if(path STREQUAL "") - message(FATAL_ERROR "can't find Qt5::QWindowsIntegrationPlugin") - endif() - install(FILES "${path}" DESTINATION ./platforms) - if(MSVC AND opentrack_install-debug-info) - otr_pdb_for_dll(pdb-path "${path}") - if(pdb-path) - install(FILES "${pdb-path}" DESTINATION "${opentrack-hier-debug}") - endif() - endif() + otr_install_lib(Qt5::QWindowsIntegrationPlugin "./platforms") endif() endfunction() diff --git a/cv/CMakeLists.txt b/cv/CMakeLists.txt index dfc983aa..477047e7 100644 --- a/cv/CMakeLists.txt +++ b/cv/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(OpenCV QUIET) +include(opentrack-opencv) if(OpenCV_FOUND) otr_module(cv STATIC) target_link_libraries(${self} opencv_videoio opencv_core opentrack-video) diff --git a/tracker-aruco/CMakeLists.txt b/tracker-aruco/CMakeLists.txt index bfa7a348..99a4d21f 100644 --- a/tracker-aruco/CMakeLists.txt +++ b/tracker-aruco/CMakeLists.txt @@ -7,7 +7,7 @@ function(maybe_add_static_define) endfunction() -find_package(OpenCV QUIET) +include(opentrack-opencv) if(OpenCV_FOUND) set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Aruco paper marker tracker static library path") diff --git a/tracker-kinect-face/CMakeLists.txt b/tracker-kinect-face/CMakeLists.txt index 7d8f828a..48c51adb 100644 --- a/tracker-kinect-face/CMakeLists.txt +++ b/tracker-kinect-face/CMakeLists.txt @@ -43,7 +43,7 @@ if (WIN32 AND opentrack-intel) # Optional OpenCV support # Needed for Point Tracker to support Kinect V2 IR Sensor - find_package(OpenCV QUIET) + include(opentrack-opencv) if(OpenCV_FOUND) add_definitions(-DOTR_HAVE_OPENCV) target_include_directories(${self} SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) diff --git a/tracker-pt/CMakeLists.txt b/tracker-pt/CMakeLists.txt index 304a6b3d..52f86831 100644 --- a/tracker-pt/CMakeLists.txt +++ b/tracker-pt/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(OpenCV QUIET) +include(opentrack-opencv) if(OpenCV_FOUND) otr_module(tracker-pt-base STATIC) target_include_directories(${self} SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) diff --git a/tracker-pt/module/CMakeLists.txt b/tracker-pt/module/CMakeLists.txt index 22b725c9..8d731c9d 100644 --- a/tracker-pt/module/CMakeLists.txt +++ b/tracker-pt/module/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(OpenCV QUIET) +include(opentrack-opencv) if(OpenCV_FOUND) otr_module(tracker-pt) target_link_libraries(${self} opentrack-tracker-pt-base) diff --git a/tracker-wii/CMakeLists.txt b/tracker-wii/CMakeLists.txt index e40692ba..91156047 100644 --- a/tracker-wii/CMakeLists.txt +++ b/tracker-wii/CMakeLists.txt @@ -1,5 +1,5 @@ if(WIN32) - find_package(OpenCV QUIET) + include(opentrack-opencv) if(OpenCV_FOUND) add_subdirectory(wiiyourself) otr_module(tracker-wii) diff --git a/video-opencv/CMakeLists.txt b/video-opencv/CMakeLists.txt index d8b9b896..ac5ad143 100644 --- a/video-opencv/CMakeLists.txt +++ b/video-opencv/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(OpenCV QUIET) +include(opentrack-opencv) if(OpenCV_FOUND) otr_module(video-opencv) |