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