vcpkg/ports/opencv/0002-install-options.patch
Robert Schumacher 471f7dc970 [opencv] Rework
Split off contrib, ipp, webp, openexr, tiff, png, tiff, jpeg, jasper, eigen into features.
Prevent downloads during the build
2018-02-23 17:06:37 -08:00

175 lines
8.4 KiB
Diff

From 5d4d154117b39d9e11fda709ede7aadf6b960a7d Mon Sep 17 00:00:00 2001
From: Robert Schumacher <roschuma@microsoft.com>
Date: Wed, 21 Feb 2018 17:05:16 -0800
Subject: [PATCH 2/5] install-options
---
CMakeLists.txt | 20 +++++++++++---------
cmake/OpenCVGenConfig.cmake | 4 ++--
cmake/OpenCVGenHeaders.cmake | 8 ++++++--
cmake/OpenCVModule.cmake | 4 +++-
data/CMakeLists.txt | 6 ++++--
include/CMakeLists.txt | 16 +++++++++-------
6 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6bfbecd..0156eeb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -292,6 +292,10 @@ OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT APPLE_FRAMEWORK AND BUILD_SHARED_LIBS) )
OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binaries and test data" OFF)
+OCV_OPTION(INSTALL_HEADERS "Install header files" ON)
+OCV_OPTION(INSTALL_LICENSE "Install license file" ON)
+OCV_OPTION(INSTALL_OTHER "Install other files" ON)
+OCV_OPTION(INSTALL_FORCE_UNIX_PATHS "Force unix-style installation" OFF)
# OpenCV build options
# ===================================================
@@ -319,7 +323,7 @@ OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON)
-OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (${BUILD_DOCS} OR ${BUILD_EXAMPLES}) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
+OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
if(ENABLE_IMPL_COLLECTION)
add_definitions(-DCV_COLLECT_IMPL_DATA)
@@ -355,7 +359,9 @@ else()
endif()
if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
- if(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH)
+ if(DEFINED OpenCV_DISABLE_ARCH_PATH)
+ ocv_update(OpenCV_INSTALL_BINARIES_PREFIX "")
+ elseif(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH)
ocv_update(OpenCV_INSTALL_BINARIES_PREFIX "${OpenCV_ARCH}/${OpenCV_RUNTIME}/")
else()
message(STATUS "Can't detect runtime and/or arch")
@@ -409,12 +415,8 @@ else()
ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
- if(OpenCV_STATIC)
- ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
- else()
- ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
- endif()
- ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
+ ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
+ ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native)
ocv_update(OPENCV_JAR_INSTALL_PATH java)
ocv_update(OPENCV_OTHER_INSTALL_PATH etc)
@@ -856,7 +858,7 @@ if(NOT OPENCV_LICENSE_FILE)
endif()
# for UNIX it does not make sense as LICENSE and readme will be part of the package automatically
-if(ANDROID OR NOT UNIX)
+if(ANDROID OR NOT UNIX AND INSTALL_LICENSE)
install(FILES ${OPENCV_LICENSE_FILE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
DESTINATION ./ COMPONENT libs)
diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake
index 57c79f2..23f1012 100644
--- a/cmake/OpenCVGenConfig.cmake
+++ b/cmake/OpenCVGenConfig.cmake
@@ -103,7 +103,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
endif()
endfunction()
-if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID)
+if(((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID) OR INSTALL_FORCE_UNIX_PATHS)
ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "")
endif()
@@ -115,7 +115,7 @@ endif()
# --------------------------------------------------------------------------------------------
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
# --------------------------------------------------------------------------------------------
-if(WIN32)
+if(WIN32 AND NOT INSTALL_FORCE_UNIX_PATHS)
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
if(BUILD_SHARED_LIBS)
set(_lib_suffix "lib")
diff --git a/cmake/OpenCVGenHeaders.cmake b/cmake/OpenCVGenHeaders.cmake
index 477b910..beace28 100644
--- a/cmake/OpenCVGenHeaders.cmake
+++ b/cmake/OpenCVGenHeaders.cmake
@@ -1,7 +1,9 @@
# platform-specific config file
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h")
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/cvconfig.h")
-install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev)
+if(INSTALL_HEADERS)
+ install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev)
+endif()
# platform-specific config file
ocv_compiler_optimization_fill_cpu_config()
@@ -29,4 +31,6 @@ set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE
#endforeach()
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv_modules.hpp.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
-install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev)
+if(INSTALL_HEADERS)
+ install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev)
+endif()
diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake
index 8feb6df..1a098c4 100644
--- a/cmake/OpenCVModule.cmake
+++ b/cmake/OpenCVModule.cmake
@@ -930,7 +930,9 @@ macro(_ocv_create_module)
foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
if(NOT hdr2 MATCHES "private" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
- install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
+ if(INSTALL_HEADERS)
+ install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
+ endif()
endif()
endforeach()
endif()
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 1f0d720..86b9d89 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,8 +1,10 @@
file(GLOB HAAR_CASCADES haarcascades/*.xml)
file(GLOB LBP_CASCADES lbpcascades/*.xml)
-install(FILES ${HAAR_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/haarcascades COMPONENT libs)
-install(FILES ${LBP_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/lbpcascades COMPONENT libs)
+if(INSTALL_OTHER)
+ install(FILES ${HAAR_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/haarcascades COMPONENT libs)
+ install(FILES ${LBP_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/lbpcascades COMPONENT libs)
+endif()
if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH)
install(DIRECTORY "${OPENCV_TEST_DATA_PATH}/" DESTINATION "${OPENCV_TEST_DATA_INSTALL_PATH}" COMPONENT "tests")
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index b4e48e6..5ac6f16 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -1,7 +1,9 @@
-file(GLOB old_hdrs "opencv/*.h*")
-install(FILES ${old_hdrs}
- DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv
- COMPONENT dev)
-install(FILES "opencv2/opencv.hpp"
- DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2
- COMPONENT dev)
+if(INSTALL_HEADERS)
+ file(GLOB old_hdrs "opencv/*.h*")
+ install(FILES ${old_hdrs}
+ DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv
+ COMPONENT dev)
+ install(FILES "opencv2/opencv.hpp"
+ DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2
+ COMPONENT dev)
+endif()
--
2.15.1.windows.2