File: CMakeLists.txt

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (51 lines) | stat: -rw-r--r-- 1,748 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
if(NOT CONFIGURE_EXAMPLES)
    message(FATAL_ERROR "Invalid call w/o CONFIGURE_EXAMPLES")
endif()

file(GLOB_RECURSE examples *.py)

unset(outputs)
foreach(ex ${examples})
    cmake_path(GET ex FILENAME ex_name )
    cmake_path(GET ex PARENT_PATH in_path)

    # Configure the public version of examples.
    string(REPLACE ${EXAMPLES_SRC_DIR} ${EXAMPLES_PUBL_DIR} out_path ${in_path})
    file(MAKE_DIRECTORY ${out_path})
    set(ex_out ${out_path}/${ex_name})
    add_custom_command(
        OUTPUT ${ex_out}
        COMMAND erb -T - ${CMAKE_CURRENT_SOURCE_DIR}/publicmode.erb ${ex} > ${ex_out}
        COMMAND chmod a+x ${ex_out}
        DEPENDS ${ex}
    )
    list(APPEND outputs ${ex_out})

    # Configure testable version of examples.
    # Tests will be configured by <ba>/Tests/Examples/CMakeLists.txt.
    string(REPLACE ${EXAMPLES_SRC_DIR} ${EXAMPLES_TEST_DIR} out_path ${in_path})
    file(MAKE_DIRECTORY ${out_path})
    set(ex_out ${out_path}/${ex_name})
    add_custom_command(
        OUTPUT ${ex_out}
        COMMAND erb -T - ${CMAKE_CURRENT_SOURCE_DIR}/testmode.erb ${ex} > ${ex_out}
        COMMAND chmod a+x ${ex_out}
        DEPENDS ${ex}
    )
    list(APPEND outputs ${ex_out})

    # Configure the version of examples to produce documentation figures.
    string(REPLACE ${EXAMPLES_SRC_DIR} ${EXAMPLES_FIGURES_DIR} out_path ${in_path})
    file(MAKE_DIRECTORY ${out_path})
    set(ex_out ${out_path}/${ex_name})
    add_custom_command(
        OUTPUT ${ex_out}
        COMMAND erb -T - ${CMAKE_CURRENT_SOURCE_DIR}/figuremode.erb ${ex} > ${ex_out}
        COMMAND chmod a+x ${ex_out}
        DEPENDS ${ex}
    )
    list(APPEND outputs ${ex_out})

endforeach()

add_custom_target(configured_examples ALL DEPENDS ${outputs})