Skip to content

Commit 8cb7eae

Browse files
committed
Merge pull request opencv#18294 from mshabunin:install-bin-samples
2 parents 18440c1 + 2dff2f3 commit 8cb7eae

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ OCV_OPTION(BUILD_JAVA "Enable Java support"
463463
# OpenCV installation options
464464
# ===================================================
465465
OCV_OPTION(INSTALL_CREATE_DISTRIB "Change install rules to build the distribution package" OFF )
466+
OCV_OPTION(INSTALL_BIN_EXAMPLES "Install prebuilt examples" WIN32 IF BUILD_EXAMPLES)
466467
OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
467468
OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
468469
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )

cmake/OpenCVModule.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,8 @@ function(ocv_add_samples)
13371337
endif()
13381338
add_dependencies(${parent_target} ${the_target})
13391339

1340-
if(WIN32)
1341-
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples)
1340+
if(INSTALL_BIN_EXAMPLES)
1341+
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${module_id}" COMPONENT samples)
13421342
endif()
13431343
endforeach()
13441344
endif()

samples/samples_utils.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ function(ocv_define_sample out_target source sub)
1515
if(WIN32 AND MSVC AND NOT BUILD_SHARED_LIBS)
1616
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
1717
endif()
18-
if(WIN32)
19-
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${sub}" COMPONENT samples)
18+
# Should be usable in stand-alone build scenario
19+
if((NOT DEFINED INSTALL_BIN_EXAMPLES AND WIN32) OR INSTALL_BIN_EXAMPLES)
20+
if(NOT DEFINED OPENCV_SAMPLES_BIN_INSTALL_PATH)
21+
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "samples")
22+
endif()
23+
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sub}" COMPONENT samples)
2024
endif()
2125
# Add single target to build all samples in the group: 'make opencv_samples_cpp'
2226
set(parent_target opencv_samples_${sub})

0 commit comments

Comments
 (0)