|
3 | 3 | # ----------------------------------------------------------------------------- |
4 | 4 | option(BUILD_USEFUL_DEMOS "Build useful demos (hashsum)" FALSE) |
5 | 5 | option(BUILD_USABLE_DEMOS "Build usable demos (crypt sizes constants pem-info)" FALSE) |
| 6 | +option(BUILD_BROKEN_DEMOS "Build broken demos (aesgcm openssh-privkey openssl-enc timing)" FALSE) |
6 | 7 | option(BUILD_TEST_DEMOS "Build test demos (small tv_gen)" FALSE) |
7 | 8 |
|
| 9 | +option(INSTALL_DEMOS "Install enabled demos (USEFUL and/or USABLE) and ltc wrapper script" FALSE) |
| 10 | +option(INSTALL_BROKEN_DEMOS "Install broken demos and ltc wrapper script" FALSE) |
| 11 | + |
8 | 12 | # ----------------------------------------------------------------------------- |
9 | 13 | # Useful demos |
| 14 | +# |
| 15 | +# Demos that are even somehow useful and could be installed as a system-tool |
| 16 | +# |
| 17 | +# * USEFUL_DEMOS = hashsum |
10 | 18 | # ----------------------------------------------------------------------------- |
11 | 19 |
|
12 | 20 | if(BUILD_USEFUL_DEMOS) |
13 | | - |
14 | | - list(APPEND ALL_DEMOS_TARGETS hashsum) |
15 | | - |
16 | | - # hashsum |
17 | | - add_executable(hashsum ${CMAKE_CURRENT_SOURCE_DIR}/hashsum.c) |
18 | | - |
19 | | - target_link_libraries(hashsum PRIVATE ${PROJECT_NAME}) |
20 | | - |
| 21 | + list(APPEND USABLE_DEMOS_TARGETS hashsum) |
21 | 22 | endif() |
22 | 23 |
|
23 | 24 | # ----------------------------------------------------------------------------- |
24 | 25 | # Usable demos |
| 26 | +# |
| 27 | +# Demos that are usable but only rarely make sense to be installed |
| 28 | +# |
| 29 | +# USEABLE_DEMOS = crypt sizes constants pem-info |
25 | 30 | # ----------------------------------------------------------------------------- |
26 | 31 |
|
27 | 32 | if(BUILD_USABLE_DEMOS) |
| 33 | + list(APPEND USABLE_DEMOS_TARGETS crypt sizes constants pem-info) |
| 34 | +endif() |
28 | 35 |
|
29 | | - list(APPEND ALL_DEMOS_TARGETS crypt sizes constants pem-info) |
30 | | - |
31 | | - # ltcrypt |
32 | | - add_executable(crypt ${CMAKE_CURRENT_SOURCE_DIR}/crypt.c) |
33 | | - |
34 | | - target_link_libraries(crypt PRIVATE ${PROJECT_NAME}) |
35 | | - |
36 | | - # sizes |
37 | | - add_executable(sizes ${CMAKE_CURRENT_SOURCE_DIR}/sizes.c) |
38 | | - |
39 | | - target_link_libraries(sizes PRIVATE ${PROJECT_NAME}) |
40 | | - |
41 | | - # constants |
42 | | - add_executable(constants ${CMAKE_CURRENT_SOURCE_DIR}/constants.c) |
43 | | - |
44 | | - target_link_libraries(constants PRIVATE ${PROJECT_NAME}) |
45 | | - |
46 | | - # pem-info |
47 | | - add_executable(pem-info ${CMAKE_CURRENT_SOURCE_DIR}/pem-info.c) |
48 | | - |
49 | | - target_link_libraries(pem-info PRIVATE ${PROJECT_NAME}) |
| 36 | +# ----------------------------------------------------------------------------- |
| 37 | +# Broken demos |
| 38 | +# |
| 39 | +# Demos that are kind of useful, but in some way broken |
| 40 | +# |
| 41 | +# * aesgcm - can't be built with LTC_EASY |
| 42 | +# * openssl-enc - can't be built with LTC_EASY |
| 43 | +# * openssh-privkey - can't be built with LTC_EASY |
| 44 | +# * timing - not really broken, but older gcc builds spit warnings |
| 45 | +# |
| 46 | +# BROKEN_DEMOS = aesgcm openssl-enc openssh-privkey timing |
| 47 | +# ----------------------------------------------------------------------------- |
50 | 48 |
|
| 49 | +if(BUILD_BROKEN_DEMOS AND INSTALL_BROKEN_DEMOS) |
| 50 | + list(APPEND USABLE_DEMOS_TARGETS aesgcm openssh-privkey openssl-enc timing) |
| 51 | +elseif(BUILD_BROKEN_DEMOS) |
| 52 | + list(APPEND ALL_DEMOS_TARGETS aesgcm openssh-privkey openssl-enc timing) |
51 | 53 | endif() |
52 | 54 |
|
53 | 55 | # ----------------------------------------------------------------------------- |
54 | 56 | # Test demos |
| 57 | +# |
| 58 | +# Demos that are used for testing or measuring |
| 59 | +# |
| 60 | +# * TEST_DEMOS = small tv_gen |
55 | 61 | # ----------------------------------------------------------------------------- |
56 | 62 |
|
57 | 63 | if(BUILD_TEST_DEMOS) |
| 64 | + list(APPEND ALL_DEMOS_TARGETS small tv_gen) |
| 65 | +endif() |
58 | 66 |
|
59 | | - list(APPEND ALL_DEMOS_TARGETS tv_gen) |
| 67 | +# ----------------------------------------------------------------------------- |
| 68 | +# Generate executables |
| 69 | +# ----------------------------------------------------------------------------- |
60 | 70 |
|
61 | | - # small |
62 | | - add_executable(small ${CMAKE_CURRENT_SOURCE_DIR}/small.c) |
| 71 | +# USABLE_DEMOS can get installed, so they're prefixed with `ltc-` |
| 72 | +foreach(target ${USABLE_DEMOS_TARGETS}) |
| 73 | + list(APPEND ALL_DEMOS_INSTALL_TARGETS ltc-${target}) |
63 | 74 |
|
64 | | - target_link_libraries(small PRIVATE ${PROJECT_NAME}) |
| 75 | + add_executable(ltc-${target} ${CMAKE_CURRENT_SOURCE_DIR}/${target}.c) |
65 | 76 |
|
66 | | - # tv_gen |
67 | | - add_executable(tv_gen ${CMAKE_CURRENT_SOURCE_DIR}/tv_gen.c) |
| 77 | + target_link_libraries(ltc-${target} PRIVATE ${PROJECT_NAME}) |
| 78 | +endforeach() |
68 | 79 |
|
69 | | - target_link_libraries(tv_gen PRIVATE ${PROJECT_NAME}) |
| 80 | +foreach(target ${ALL_DEMOS_TARGETS}) |
| 81 | + add_executable(${target} ${CMAKE_CURRENT_SOURCE_DIR}/${target}.c) |
70 | 82 |
|
71 | | -endif() |
| 83 | + target_link_libraries(${target} PRIVATE ${PROJECT_NAME}) |
| 84 | +endforeach() |
72 | 85 |
|
73 | 86 | # ----------------------------------------------------------------------------- |
74 | 87 | # Install targets |
75 | 88 | # ----------------------------------------------------------------------------- |
76 | | -install( |
77 | | - TARGETS ${ALL_DEMOS_TARGETS} |
78 | | - COMPONENT "runtime" |
79 | | - EXPORT ${TARGETS_EXPORT_NAME} |
80 | | - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
81 | | -) |
| 89 | +if(INSTALL_DEMOS) |
| 90 | + install( |
| 91 | + TARGETS ${ALL_DEMOS_INSTALL_TARGETS} |
| 92 | + COMPONENT "runtime" |
| 93 | + EXPORT ${TARGETS_EXPORT_NAME} |
| 94 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 95 | + ) |
| 96 | + |
| 97 | + # Also install the `ltc` wrapper script |
| 98 | + install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/ltc DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 99 | +endif() |
0 commit comments