aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/snippets
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-10-05 23:08:39 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-10-05 23:08:39 +0200
commit91613bf2c2132fc4b45182146f9367398b6167f0 (patch)
treef1e6e9869a0ff7ec513bb17d5d207343e95570ed /doc/snippets
parent3e64b1fc8661316b20335cd287a726b4b37dff0c (diff)
Add support for c++11 snippets
Diffstat (limited to 'doc/snippets')
-rw-r--r--doc/snippets/CMakeLists.txt39
1 files changed, 23 insertions, 16 deletions
diff --git a/doc/snippets/CMakeLists.txt b/doc/snippets/CMakeLists.txt
index 1baf32fba..d2f787424 100644
--- a/doc/snippets/CMakeLists.txt
+++ b/doc/snippets/CMakeLists.txt
@@ -6,21 +6,28 @@ 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(${CMAKE_CURRENT_SOURCE_DIR}/compile_snippet.cpp.in
- ${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
- add_executable(${compile_snippet_target}
- ${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
- if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
- target_link_libraries(${compile_snippet_target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
+ if((NOT ${snippet_src} MATCHES "cxx11") OR EIGEN_COMPILER_SUPPORT_CXX11)
+ file(READ ${snippet_src} snippet_source_code)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/compile_snippet.cpp.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
+ add_executable(${compile_snippet_target}
+ ${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
+ if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
+ target_link_libraries(${compile_snippet_target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
+ endif()
+ if(${snippet_src} MATCHES "cxx11")
+ set_target_properties(${compile_snippet_target} PROPERTIES COMPILE_FLAGS "-std=c++11")
+ endif()
+ add_custom_command(
+ TARGET ${compile_snippet_target}
+ POST_BUILD
+ COMMAND ${compile_snippet_target}
+ ARGS >${CMAKE_CURRENT_BINARY_DIR}/${snippet}.out
+ )
+ add_dependencies(all_snippets ${compile_snippet_target})
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src}
+ PROPERTIES OBJECT_DEPENDS ${snippet_src})
+ else()
+ message("skip snippet ${snippet_src} because compiler does not support C++11")
endif()
- add_custom_command(
- TARGET ${compile_snippet_target}
- POST_BUILD
- COMMAND ${compile_snippet_target}
- ARGS >${CMAKE_CURRENT_BINARY_DIR}/${snippet}.out
- )
- add_dependencies(all_snippets ${compile_snippet_target})
- set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src}
- PROPERTIES OBJECT_DEPENDS ${snippet_src})
endforeach(snippet_src)