mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 11:40:44 +08:00
a45928045a
* cmake: avoid deprecated LINK_PRIVATE/LINK_PUBLIC see CMP0023 (CMake 2.8.12+) * cmake: fix 3rdparty list - don't include OpenCV modules
32 lines
1.4 KiB
CMake
32 lines
1.4 KiB
CMake
# Utility function: adds sample executable target with name "example_<group>_<file_name>"
|
|
# Usage:
|
|
# ocv_define_sample(<output target> <relative filename> <group>)
|
|
function(ocv_define_sample out_target source sub)
|
|
get_filename_component(name "${source}" NAME_WE)
|
|
set(the_target "example_${sub}_${name}")
|
|
add_executable(${the_target} "${source}")
|
|
if(TARGET Threads::Threads AND NOT OPENCV_EXAMPLES_DISABLE_THREADS)
|
|
target_link_libraries(${the_target} PRIVATE Threads::Threads)
|
|
endif()
|
|
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
|
|
if(ENABLE_SOLUTION_FOLDERS)
|
|
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sub}")
|
|
endif()
|
|
if(WIN32 AND MSVC AND NOT BUILD_SHARED_LIBS)
|
|
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
endif()
|
|
if(WIN32)
|
|
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${sub}" COMPONENT samples)
|
|
endif()
|
|
# Add single target to build all samples in the group: 'make opencv_samples_cpp'
|
|
set(parent_target opencv_samples_${sub})
|
|
if(NOT TARGET ${parent_target})
|
|
add_custom_target(${parent_target})
|
|
if(TARGET opencv_samples)
|
|
add_dependencies(opencv_samples ${parent_target})
|
|
endif()
|
|
endif()
|
|
add_dependencies(${parent_target} ${the_target})
|
|
set(${out_target} ${the_target} PARENT_SCOPE)
|
|
endfunction()
|