forked from opencv/opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: function for application creation (opencv#11736)
* apps: add Win32 friendly opencv_version app Improve experience of launching app from explorer: - application just flash (open/close) the console window Suggested Win32 application flavor additionally shows MessageBox and waits for User interaction. * cmake: added unified application creation function
- Loading branch information
Showing
7 changed files
with
52 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,3 @@ | ||
SET(OPENCV_ANNOTATION_DEPS opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio) | ||
ocv_check_dependencies(${OPENCV_ANNOTATION_DEPS}) | ||
|
||
if(NOT OCV_DEPENDENCIES_FOUND) | ||
return() | ||
endif() | ||
|
||
project(annotation) | ||
set(the_target opencv_annotation) | ||
|
||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_ANNOTATION_DEPS}) | ||
|
||
file(GLOB SRCS *.cpp) | ||
|
||
set(annotation_files ${SRCS}) | ||
ocv_add_executable(${the_target} ${annotation_files}) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_ANNOTATION_DEPS}) | ||
|
||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_annotation") | ||
|
||
if(ENABLE_SOLUTION_FOLDERS) | ||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
endif() | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) | ||
endif() | ||
ocv_add_application(opencv_annotation | ||
MODULES opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio | ||
SRCS opencv_annotation.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,4 @@ | ||
set(OPENCV_CREATESAMPLES_DEPS opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d opencv_videoio) | ||
ocv_check_dependencies(${OPENCV_CREATESAMPLES_DEPS}) | ||
|
||
if(NOT OCV_DEPENDENCIES_FOUND) | ||
return() | ||
endif() | ||
|
||
project(createsamples) | ||
set(the_target opencv_createsamples) | ||
|
||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_CREATESAMPLES_DEPS}) | ||
|
||
file(GLOB SRCS *.cpp) | ||
file(GLOB HDRS *.h*) | ||
|
||
set(createsamples_files ${SRCS} ${HDRS}) | ||
|
||
ocv_add_executable(${the_target} ${createsamples_files}) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_CREATESAMPLES_DEPS}) | ||
|
||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_createsamples") | ||
|
||
if(ENABLE_SOLUTION_FOLDERS) | ||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
endif() | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} OPTIONAL RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) | ||
endif() | ||
ocv_add_application(opencv_createsamples | ||
MODULES opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d opencv_videoio | ||
SRCS ${SRCS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,6 @@ | ||
set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_highgui opencv_calib3d opencv_videoio) | ||
set(DEPS opencv_core opencv_imgproc opencv_features2d opencv_highgui opencv_calib3d opencv_videoio) | ||
if(${BUILD_opencv_aruco}) | ||
list(APPEND OPENCV_INTERACTIVECALIBRATION_DEPS opencv_aruco) | ||
list(APPEND DEPS opencv_aruco) | ||
endif() | ||
ocv_check_dependencies(${OPENCV_INTERACTIVECALIBRATION_DEPS}) | ||
|
||
if(NOT OCV_DEPENDENCIES_FOUND) | ||
return() | ||
endif() | ||
|
||
project(interactive-calibration) | ||
set(the_target opencv_interactive-calibration) | ||
|
||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_INTERACTIVECALIBRATION_DEPS}) | ||
|
||
file(GLOB SRCS *.cpp) | ||
file(GLOB HDRS *.h*) | ||
|
||
set(interactive-calibration_files ${SRCS} ${HDRS}) | ||
|
||
ocv_add_executable(${the_target} ${interactive-calibration_files}) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_INTERACTIVECALIBRATION_DEPS}) | ||
|
||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_interactive-calibration") | ||
|
||
if(ENABLE_SOLUTION_FOLDERS) | ||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
endif() | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} OPTIONAL RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) | ||
endif() | ||
ocv_add_application(opencv_interactive-calibration MODULES ${DEPS} SRCS ${SRCS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,5 @@ | ||
set(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d) | ||
ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS}) | ||
|
||
if(NOT OCV_DEPENDENCIES_FOUND) | ||
return() | ||
endif() | ||
|
||
project(traincascade) | ||
set(the_target opencv_traincascade) | ||
|
||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Woverloaded-virtual | ||
-Winconsistent-missing-override -Wsuggest-override | ||
) | ||
|
||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_TRAINCASCADE_DEPS}) | ||
|
||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Woverloaded-virtual -Winconsistent-missing-override -Wsuggest-override) | ||
file(GLOB SRCS *.cpp) | ||
file(GLOB HDRS *.h*) | ||
|
||
set(traincascade_files ${SRCS} ${HDRS}) | ||
|
||
ocv_add_executable(${the_target} ${traincascade_files}) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS}) | ||
|
||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_traincascade") | ||
|
||
if(ENABLE_SOLUTION_FOLDERS) | ||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
endif() | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} OPTIONAL RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) | ||
endif() | ||
ocv_add_application(opencv_traincascade | ||
MODULES opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d | ||
SRCS ${SRCS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,5 @@ | ||
set(OPENCV_APPLICATION_DEPS opencv_core) | ||
ocv_check_dependencies(${OPENCV_APPLICATION_DEPS}) | ||
if(NOT OCV_DEPENDENCIES_FOUND) | ||
return() | ||
endif() | ||
|
||
project(opencv_version) | ||
set(the_target opencv_version) | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_APPLICATION_DEPS}) | ||
ocv_add_executable(${the_target} opencv_version.cpp) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_APPLICATION_DEPS}) | ||
|
||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_version") | ||
|
||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT libs) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs) | ||
endif() | ||
|
||
ocv_add_application(opencv_version MODULES opencv_core SRCS opencv_version.cpp) | ||
if(WIN32) | ||
project(opencv_version_win32) | ||
set(the_target opencv_version_win32) | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_APPLICATION_DEPS}) | ||
ocv_add_executable(${the_target} opencv_version.cpp) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_APPLICATION_DEPS}) | ||
target_compile_definitions(${the_target} PRIVATE "OPENCV_WIN32_API=1") | ||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_version_win32") | ||
|
||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT libs) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs) | ||
endif() | ||
ocv_add_application(opencv_version_win32 MODULES opencv_core SRCS opencv_version.cpp) | ||
target_compile_definitions(opencv_version_win32 PRIVATE "OPENCV_WIN32_API=1") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,3 @@ | ||
SET(OPENCV_VISUALISATION_DEPS opencv_core opencv_highgui opencv_imgproc opencv_videoio opencv_imgcodecs) | ||
ocv_check_dependencies(${OPENCV_VISUALISATION_DEPS}) | ||
|
||
if(NOT OCV_DEPENDENCIES_FOUND) | ||
return() | ||
endif() | ||
|
||
project(visualisation) | ||
set(the_target opencv_visualisation) | ||
|
||
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") | ||
ocv_target_include_modules_recurse(${the_target} ${OPENCV_VISUALISATION_DEPS}) | ||
|
||
file(GLOB SRCS *.cpp) | ||
|
||
set(visualisation_files ${SRCS}) | ||
ocv_add_executable(${the_target} ${visualisation_files}) | ||
ocv_target_link_libraries(${the_target} ${OPENCV_VISUALISATION_DEPS}) | ||
|
||
set_target_properties(${the_target} PROPERTIES | ||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" | ||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} | ||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} | ||
OUTPUT_NAME "opencv_visualisation") | ||
|
||
if(ENABLE_SOLUTION_FOLDERS) | ||
set_target_properties(${the_target} PROPERTIES FOLDER "applications") | ||
endif() | ||
|
||
if(INSTALL_CREATE_DISTRIB) | ||
if(BUILD_SHARED_LIBS) | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev) | ||
endif() | ||
else() | ||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev) | ||
endif() | ||
ocv_add_application(opencv_visualisation | ||
MODULES opencv_core opencv_highgui opencv_imgproc opencv_videoio opencv_imgcodecs | ||
SRCS opencv_visualisation.cpp) |