Debian Codegraph @

doc/examples/CMakeLists.txt

raw
1 add_custom_target(doc-examples)
2
3 macro(TEXI_FROM_SOURCE source)
4 get_filename_component(name ${source} NAME_WE)
5 set(texi ${name}.texi)
6 add_custom_command(TARGET doc-examples
7 COMMAND sed -e 's/{/@{/' -e 's/}/@}/' ${CMAKE_CURRENT_SOURCE_DIR}/${source} | fold -s -w 80 > ${texi}
8 DEPENDS ${source}
9 OUTPUTS ${texi})
10 endmacro()
11
12 macro(OUTPUT_FROM_SOURCE source)
13 get_filename_component(name ${source} NAME_WE)
14 add_executable(${name} ${source})
15 target_link_libraries(${name} blitz ${BLITZ_EXTRA_LIBRARIES})
16 set(out ${name}.out)
17 add_custom_command(TARGET doc-examples
18 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${source} 2>&1 | fold -s -w 80 > ${out}
19 DEPENDS ${name}
20 OUTPUTS ${out})
21 endmacro()
22
23 set(GENERATED_FILES)
24 macro(GENERATE_EXAMPLES var)
25 if (NOT "${var}" STREQUAL "texi" AND NOT "${var}" STREQUAL "out")
26 message(ERROR,"Unknown output type: ${var}")
27 endif()
28 set(ll)
29 foreach(source ${ARGN})
30 if ("${var}" STREQUAL "texi")
31 TEXI_FROM_SOURCE(${source})
32 else()
33 OUTPUT_FROM_SOURCE(${source})
34 endif()
35 get_filename_component(name ${source} NAME_WE)
36 list(APPEND ll ${name}.${var})
37 endforeach()
38 add_custom_target(${var} DEPENDS ${ll})
39 set(GENERATED_FILES ${GENERATED_FILES} ${ll})
40 endmacro()
41
42 #TODO: Handle fixed-class.cpp fixed-point.h makefile.example io.data
43
44 set(EXAMPLES simple.cpp storage.cpp outer.cpp strideslice.cpp slicing.cpp debug.cpp
45 output.cpp io.cpp dump.cpp xor.cpp cast.cpp range.cpp fixed.cpp)
46
47 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
48 include_directories(${CMAKE_SOURCE_DIR})
49 include_directories(${CMAKE_BINARY_DIR})
50
51 GENERATE_EXAMPLES(texi ${EXAMPLES} fixed-point.h)
52 GENERATE_EXAMPLES(out ${EXAMPLES})
53
54 target_link_libraries(io blitz)
55
56 # Per the documentation this should not be needed as OUTPUT of
57 # ADD_CUSTOM_COMMAND should be automatically cleaned...
58
59 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}")