1file(GLOB examples_SRCS "*.cpp")
2
3add_custom_target(all_examples)
4
5foreach(example_src ${examples_SRCS})
6  get_filename_component(example ${example_src} NAME_WE)
7  add_executable(${example} ${example_src})
8  if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
9    target_link_libraries(${example} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
10  endif()
11  get_target_property(example_executable
12                      ${example} LOCATION)
13  add_custom_command(
14    TARGET ${example}
15    POST_BUILD
16    COMMAND ${example_executable}
17    ARGS >${CMAKE_CURRENT_BINARY_DIR}/${example}.out
18  )
19  add_dependencies(all_examples ${example})
20endforeach(example_src)
21