2019-11-01 00:36:37 +08:00
|
|
|
file(GLOB snippets_SRCS "*.cpp")
|
2009-03-19 04:06:06 +08:00
|
|
|
|
2019-11-01 00:36:37 +08:00
|
|
|
add_custom_target(unsupported_snippets)
|
2009-03-19 04:06:06 +08:00
|
|
|
|
2019-11-01 00:36:37 +08:00
|
|
|
foreach(snippet_src ${snippets_SRCS})
|
|
|
|
get_filename_component(snippet ${snippet_src} NAME_WE)
|
|
|
|
set(compile_snippet_target compile_${snippet})
|
|
|
|
set(compile_snippet_src ${compile_snippet_target}.cpp)
|
|
|
|
file(READ ${snippet_src} snippet_source_code)
|
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/doc/snippets/compile_snippet.cpp.in
|
2009-03-19 04:06:06 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
|
2019-11-01 00:36:37 +08:00
|
|
|
add_executable(${compile_snippet_target}
|
2009-03-19 04:06:06 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
|
2010-04-19 23:19:22 +08:00
|
|
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
|
|
|
target_link_libraries(${compile_snippet_target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
|
|
|
endif()
|
2019-11-01 00:36:37 +08:00
|
|
|
add_custom_command(
|
2009-03-19 04:06:06 +08:00
|
|
|
TARGET ${compile_snippet_target}
|
|
|
|
POST_BUILD
|
2014-08-22 18:13:07 +08:00
|
|
|
COMMAND ${compile_snippet_target}
|
2009-03-19 04:06:06 +08:00
|
|
|
ARGS >${CMAKE_CURRENT_BINARY_DIR}/${snippet}.out
|
|
|
|
)
|
2019-11-01 00:36:37 +08:00
|
|
|
add_dependencies(unsupported_snippets ${compile_snippet_target})
|
2009-03-19 04:06:06 +08:00
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src}
|
|
|
|
PROPERTIES OBJECT_DEPENDS ${snippet_src})
|
2019-11-01 00:36:37 +08:00
|
|
|
endforeach(snippet_src)
|