mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
update cmake 'install' target for Windows platform
Allow to build samples via OpenCV binaries from distribution package (find_package with OpenCV_DIR).
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
# Detect if we want to build samples with library binaries or not
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
||||
#
|
||||
# BUILD CASE 1: Build samples with library sources
|
||||
#
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for samples. See root CMakeLists.txt
|
||||
#
|
||||
@@ -11,3 +18,32 @@ add_subdirectory(ocl)
|
||||
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
|
||||
add_subdirectory(android)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# END OF BUILD CASE 1: Build samples with library sources
|
||||
#
|
||||
else()
|
||||
#
|
||||
# BUILD CASE 2: Build samples with library binaries
|
||||
#
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(samples C CXX)
|
||||
option(BUILD_EXAMPLES "Build samples" ON)
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
add_subdirectory(c)
|
||||
add_subdirectory(cpp)
|
||||
add_subdirectory(ocl)
|
||||
add_subdirectory(gpu)
|
||||
|
||||
#
|
||||
# END OF BUILD CASE 2: Build samples with library binaries
|
||||
#
|
||||
endif()
|
||||
@@ -39,7 +39,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target}
|
||||
RUNTIME DESTINATION "samples/c" COMPONENT main)
|
||||
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/c" COMPONENT main)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
if("${srcs}" MATCHES "tutorial_code")
|
||||
set(sample_kind tutorial)
|
||||
set(sample_KIND TUTORIAL)
|
||||
set(sample_folder "samples//tutorials")
|
||||
set(sample_subfolder "tutorials")
|
||||
else()
|
||||
set(sample_kind example)
|
||||
set(sample_KIND EXAMPLE)
|
||||
set(sample_folder "samples//cpp")
|
||||
set(sample_subfolder "cpp")
|
||||
endif()
|
||||
|
||||
set(the_target "${sample_kind}_${name}")
|
||||
@@ -52,7 +52,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
PROJECT_LABEL "(${sample_KIND}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "${sample_folder}")
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
@@ -60,7 +60,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target}
|
||||
RUNTIME DESTINATION "${sample_folder}" COMPONENT main)
|
||||
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT main)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${project}" COMPONENT main)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT main)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/gpu" COMPONENT main)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/gpu" COMPONENT main)
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
||||
|
||||
@@ -38,7 +38,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${project}" COMPONENT main)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT main)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user