CMakeLists.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -----------------------------------------------------------------------------
  2. # Options
  3. # -----------------------------------------------------------------------------
  4. option(INSTALL_DEMOS "Install enabled demos (USEFUL and/or USABLE) and ltc wrapper script" FALSE)
  5. # -----------------------------------------------------------------------------
  6. # Useful demos
  7. #
  8. # Demos that are even somehow useful and could be installed as a system-tool
  9. #
  10. # -----------------------------------------------------------------------------
  11. set(USEFUL_DEMOS hashsum)
  12. list(JOIN USEFUL_DEMOS " " USEFUL_DEMOS_STR)
  13. option(BUILD_USEFUL_DEMOS "Build useful demos (${USEFUL_DEMOS_STR})" FALSE)
  14. if(BUILD_USEFUL_DEMOS)
  15. list(APPEND USABLE_DEMOS_TARGETS ${USEFUL_DEMOS})
  16. endif()
  17. # -----------------------------------------------------------------------------
  18. # Usable demos
  19. #
  20. # Demos that are usable but only rarely make sense to be installed
  21. #
  22. # -----------------------------------------------------------------------------
  23. set(USABLE_DEMOS aesgcm constants crypt der_print_flexi latex-tables openssh-privkey openssl-enc sizes timing)
  24. list(JOIN USABLE_DEMOS " " USABLE_DEMOS_STR)
  25. option(BUILD_USABLE_DEMOS "Build usable demos (${USABLE_DEMOS_STR})" FALSE)
  26. if(BUILD_USABLE_DEMOS)
  27. list(APPEND USABLE_DEMOS_TARGETS ${USABLE_DEMOS})
  28. endif()
  29. # -----------------------------------------------------------------------------
  30. # Test demos
  31. #
  32. # Demos that are used for testing or measuring
  33. #
  34. # -----------------------------------------------------------------------------
  35. set(TEST_DEMOS small tv_gen)
  36. list(JOIN TEST_DEMOS " " TEST_DEMOS_STR)
  37. option(BUILD_TEST_DEMOS "Build test demos (${TEST_DEMOS_STR})" FALSE)
  38. if(BUILD_TEST_DEMOS)
  39. list(APPEND ALL_DEMOS_TARGETS ${TEST_DEMOS})
  40. endif()
  41. # -----------------------------------------------------------------------------
  42. # Generate executables
  43. # -----------------------------------------------------------------------------
  44. # USABLE_DEMOS can get installed, so they're prefixed with `ltc-`
  45. foreach(target ${USABLE_DEMOS_TARGETS})
  46. list(APPEND ALL_DEMOS_INSTALL_TARGETS ltc-${target})
  47. add_executable(ltc-${target} ${CMAKE_CURRENT_SOURCE_DIR}/${target}.c)
  48. target_link_libraries(ltc-${target} PRIVATE ${PROJECT_NAME})
  49. endforeach()
  50. foreach(target ${ALL_DEMOS_TARGETS})
  51. add_executable(${target} ${CMAKE_CURRENT_SOURCE_DIR}/${target}.c)
  52. target_link_libraries(${target} PRIVATE ${PROJECT_NAME})
  53. endforeach()
  54. # -----------------------------------------------------------------------------
  55. # Install targets
  56. # -----------------------------------------------------------------------------
  57. if(INSTALL_DEMOS)
  58. install(
  59. TARGETS ${ALL_DEMOS_INSTALL_TARGETS}
  60. COMPONENT "runtime"
  61. EXPORT ${TARGETS_EXPORT_NAME}
  62. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  63. )
  64. # Also install the `ltc` wrapper script
  65. install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/ltc DESTINATION ${CMAKE_INSTALL_BINDIR})
  66. endif()