在cmakelists.txt中添加下面内容:
option(BUILD_xxx_xxx_EXAMPLES "xxx xxx example" OFF)
if(xxx_BUILD_EXAMPLE)
set(BUILD_xxx_xxx_EXAMPLES ON)
endif()
if (BUILD_xxx_xxx_EXAMPLES)
add_subdirectory(${PROJECT_SOURCE_DIR}/example/example1)
add_subdirectory(${PROJECT_SOURCE_DIR}/example/example2)
endif()