Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
9fabc340
Commit
9fabc340
authored
May 14, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14558 from alalek:cmake_samples_threading_3.4
parents
e7338024
3201ea89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
29 deletions
+50
-29
CMakeLists.txt
samples/CMakeLists.txt
+19
-29
samples_utils.cmake
samples/samples_utils.cmake
+31
-0
No files found.
samples/CMakeLists.txt
View file @
9fabc340
# 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
}
"
)
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
()
if
(
NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR
)
#===================================================================================================
#
...
...
@@ -34,6 +5,8 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
#
#===================================================================================================
include
(
"
${
CMAKE_CURRENT_LIST_DIR
}
/samples_utils.cmake"
)
function
(
ocv_install_example_src relpath
)
if
(
INSTALL_C_EXAMPLES
)
file
(
GLOB files
${
ARGN
}
)
...
...
@@ -43,6 +16,10 @@ function(ocv_install_example_src relpath)
endif
()
endfunction
()
if
((
TARGET Threads::Threads OR HAVE_PTHREAD OR MSVC OR APPLE
)
AND NOT OPENCV_EXAMPLES_DISABLE_THREADS
)
add_definitions
(
-DHAVE_THREADS=1
)
endif
()
add_subdirectory
(
cpp
)
add_subdirectory
(
java/tutorial_code
)
add_subdirectory
(
dnn
)
...
...
@@ -94,6 +71,8 @@ option(BUILD_EXAMPLES "Build samples" ON)
# │ ├── cpp/
find_package
(
OpenCV REQUIRED PATHS
".."
)
include
(
"
${
CMAKE_CURRENT_LIST_DIR
}
/samples_utils.cmake"
)
function
(
ocv_install_example_src
)
# not used in this branch
endfunction
()
...
...
@@ -125,6 +104,17 @@ endif()
add_definitions
(
-DDISABLE_OPENCV_24_COMPATIBILITY=1
)
# Avoid C-like legacy API
if
(
OPENCV_EXAMPLES_DISABLE_THREADS
)
# nothing
elseif
(
MSVC OR APPLE
)
set
(
HAVE_THREADS 1
)
else
()
find_package
(
Threads
)
endif
()
if
((
TARGET Threads::Threads OR HAVE_THREADS
)
AND NOT OPENCV_EXAMPLES_DISABLE_THREADS
)
add_definitions
(
-DHAVE_THREADS=1
)
endif
()
add_subdirectory
(
cpp
)
if
(
WIN32
)
add_subdirectory
(
directx
)
...
...
samples/samples_utils.cmake
0 → 100644
View file @
9fabc340
# 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
}
LINK_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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment