avoid explicit sample enumeration in samples/{c,cpp}/CMakeLists.txt

This commit is contained in:
Vadim Pisarevsky 2010-06-10 20:55:48 +00:00
parent 6cc7fb67dd
commit 432e0e0cd8
2 changed files with 36 additions and 66 deletions

View File

@ -27,64 +27,30 @@ if (BUILD_EXAMPLES)
# Define executable targets
# ---------------------------------------------
MACRO(MY_DEFINE_EXAMPLE name srcs)
add_executable(${name} ${srcs})
set_target_properties(${name} PROPERTIES PROJECT_LABEL "(EXAMPLE) ${name}")
add_dependencies(${name} opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
target_link_libraries(${name} ${OPENCV_LINKER_LIBS} opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
set(the_target "example_${name}")
add_executable(${the_target} ${srcs})
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}"
PROJECT_LABEL "(EXAMPLE) ${name}")
add_dependencies(${the_target} opencv_core opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
if(WIN32)
install(TARGETS ${name}
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/c" COMPONENT main)
endif()
ENDMACRO(MY_DEFINE_EXAMPLE)
MY_DEFINE_EXAMPLE(adaptiveskindetector adaptiveskindetector.cpp)
MY_DEFINE_EXAMPLE(bgfg_codebook bgfg_codebook.cpp)
MY_DEFINE_EXAMPLE(bgfg_segm bgfg_segm.cpp)
MY_DEFINE_EXAMPLE(blobtrack_sample blobtrack_sample.cpp)
MY_DEFINE_EXAMPLE(camshiftdemo camshiftdemo.c)
MY_DEFINE_EXAMPLE(contours contours.c)
MY_DEFINE_EXAMPLE(convert_cascade convert_cascade.c)
MY_DEFINE_EXAMPLE(convexhull convexhull.c)
MY_DEFINE_EXAMPLE(delaunay delaunay.c)
MY_DEFINE_EXAMPLE(demhist demhist.c)
MY_DEFINE_EXAMPLE(dft dft.c)
MY_DEFINE_EXAMPLE(distrans distrans.c)
MY_DEFINE_EXAMPLE(drawing drawing.c)
MY_DEFINE_EXAMPLE(edge edge.c)
MY_DEFINE_EXAMPLE(facedetect facedetect.cpp)
MY_DEFINE_EXAMPLE(ffilldemo ffilldemo.c)
MY_DEFINE_EXAMPLE(fback fback.cpp)
MY_DEFINE_EXAMPLE(fback_c fback_c.c)
MY_DEFINE_EXAMPLE(find_obj find_obj.cpp)
MY_DEFINE_EXAMPLE(fitellipse fitellipse.cpp)
MY_DEFINE_EXAMPLE(houghlines houghlines.c)
MY_DEFINE_EXAMPLE(image image.cpp)
MY_DEFINE_EXAMPLE(inpaint inpaint.cpp)
MY_DEFINE_EXAMPLE(kalman kalman.c)
MY_DEFINE_EXAMPLE(kmeans kmeans.c)
MY_DEFINE_EXAMPLE(laplace laplace.c)
MY_DEFINE_EXAMPLE(letter_recog letter_recog.cpp)
MY_DEFINE_EXAMPLE(lkdemo lkdemo.c)
MY_DEFINE_EXAMPLE(minarea minarea.c)
MY_DEFINE_EXAMPLE(morphology morphology.c)
MY_DEFINE_EXAMPLE(motempl motempl.c)
MY_DEFINE_EXAMPLE(mushroom mushroom.cpp)
MY_DEFINE_EXAMPLE(tree_engine tree_engine.cpp)
MY_DEFINE_EXAMPLE(one_way_sample one_way_sample.cpp)
MY_DEFINE_EXAMPLE(peopledetect peopledetect.cpp)
MY_DEFINE_EXAMPLE(pyramid_segmentation pyramid_segmentation.c)
MY_DEFINE_EXAMPLE(squares squares.c)
MY_DEFINE_EXAMPLE(stereo_calib stereo_calib.cpp)
MY_DEFINE_EXAMPLE(stereo_match stereo_match.cpp)
MY_DEFINE_EXAMPLE(watershed watershed.cpp)
MY_DEFINE_EXAMPLE(grabcut grabcut.cpp)
MY_DEFINE_EXAMPLE(polar_transforms polar_transforms.c)
MY_DEFINE_EXAMPLE(calibration calibration.cpp)
MY_DEFINE_EXAMPLE(calibration_artificial calibration_artificial.cpp)
MY_DEFINE_EXAMPLE(mser mser_sample.cpp)
MY_DEFINE_EXAMPLE(find_obj_calonder find_obj_calonder.cpp)
MY_DEFINE_EXAMPLE(find_obj_ferns find_obj_ferns.cpp)
file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.c)
foreach(sample_filename ${cpp_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
MY_DEFINE_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif(BUILD_EXAMPLES)
if (INSTALL_C_EXAMPLES AND NOT WIN32)

View File

@ -27,26 +27,30 @@ if (BUILD_EXAMPLES)
# Define executable targets
# ---------------------------------------------
MACRO(MY_DEFINE_EXAMPLE name srcs)
add_executable(${name} ${srcs})
set_target_properties(${name} PROPERTIES PROJECT_LABEL "(EXAMPLE) ${name}")
add_dependencies(${name} opencv_core opencv_imgproc
opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_contrib)
target_link_libraries(${name} ${OPENCV_LINKER_LIBS} opencv_core
opencv_imgproc opencv_highgui opencv_ml opencv_video
opencv_objdetect opencv_features2d opencv_calib3d opencv_contrib)
set(the_target "example_${name}")
add_executable(${the_target} ${srcs})
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}"
PROJECT_LABEL "(EXAMPLE) ${name}")
add_dependencies(${the_target} opencv_core opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
if(WIN32)
install(TARGETS ${name}
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/cpp" COMPONENT main)
endif()
ENDMACRO(MY_DEFINE_EXAMPLE)
MY_DEFINE_EXAMPLE(select3dobj select3dobj.cpp)
MY_DEFINE_EXAMPLE(connected_components connected_components.cpp)
MY_DEFINE_EXAMPLE(contours2 contours2.cpp)
MY_DEFINE_EXAMPLE(morphology2 morphology2.cpp)
MY_DEFINE_EXAMPLE(segment_objects segment_objects.cpp)
file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${cpp_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
MY_DEFINE_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif(BUILD_EXAMPLES)
if (INSTALL_C_EXAMPLES AND NOT WIN32)