CMakeLists.txt 2.9 KB

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