CMakeLists.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. cmake_minimum_required(VERSION 3.7)
  2. project(putty LANGUAGES C)
  3. set(CMAKE_C_STANDARD 99)
  4. include(cmake/setup.cmake)
  5. # Scan the docs directory first, so that when we start calling
  6. # installed_program(), we'll know if we have man pages available
  7. add_subdirectory(doc)
  8. add_compile_definitions(HAVE_CMAKE_H)
  9. include_directories(terminal)
  10. add_library(utils STATIC
  11. ${GENERATED_COMMIT_C})
  12. add_dependencies(utils cmake_commit_c)
  13. add_subdirectory(utils)
  14. add_subdirectory(stubs)
  15. add_library(logging OBJECT
  16. logging.c utils/logeventf.c)
  17. add_library(eventloop STATIC
  18. callback.c timing.c)
  19. add_library(console STATIC
  20. clicons.c console.c)
  21. add_library(settings STATIC
  22. cmdline.c settings.c)
  23. add_library(crypto STATIC
  24. proxy/cproxy.c proxy/sshproxy.c)
  25. add_subdirectory(crypto)
  26. add_library(network STATIC
  27. errsock.c x11disp.c
  28. $<TARGET_OBJECTS:logging>
  29. proxy/proxy.c
  30. proxy/http.c
  31. proxy/socks4.c
  32. proxy/socks5.c
  33. proxy/telnet.c
  34. proxy/local.c
  35. proxy/interactor.c)
  36. add_library(keygen STATIC
  37. import.c)
  38. add_subdirectory(keygen)
  39. add_library(agent STATIC
  40. sshpubk.c pageant.c aqsync.c)
  41. add_library(guiterminal STATIC
  42. terminal/terminal.c terminal/bidi.c
  43. ldisc.c terminal/lineedit.c config.c dialog.c
  44. $<TARGET_OBJECTS:logging>)
  45. add_library(noterminal STATIC
  46. stubs/no-term.c ldisc.c)
  47. add_library(all-backends OBJECT
  48. pinger.c)
  49. add_library(sftpclient STATIC
  50. psftpcommon.c)
  51. add_subdirectory(ssh)
  52. add_library(otherbackends STATIC
  53. $<TARGET_OBJECTS:all-backends>
  54. $<TARGET_OBJECTS:logging>)
  55. add_subdirectory(otherbackends)
  56. add_executable(testcrypt
  57. test/testcrypt.c sshpubk.c ssh/crc-attack-detector.c)
  58. target_link_libraries(testcrypt
  59. keygen crypto utils ${platform_libraries})
  60. add_executable(test_host_strfoo
  61. utils/host_strchr_internal.c)
  62. target_compile_definitions(test_host_strfoo PRIVATE TEST)
  63. target_link_libraries(test_host_strfoo utils ${platform_libraries})
  64. add_executable(test_decode_utf8
  65. utils/decode_utf8.c)
  66. target_compile_definitions(test_decode_utf8 PRIVATE TEST)
  67. target_link_libraries(test_decode_utf8 utils ${platform_libraries})
  68. add_executable(test_unicode_norm
  69. utils/unicode-norm.c)
  70. target_compile_definitions(test_unicode_norm PRIVATE TEST)
  71. target_link_libraries(test_unicode_norm utils ${platform_libraries})
  72. add_executable(test_tree234
  73. utils/tree234.c)
  74. target_compile_definitions(test_tree234 PRIVATE TEST)
  75. target_link_libraries(test_tree234 utils ${platform_libraries})
  76. add_executable(test_wildcard
  77. utils/wildcard.c)
  78. target_compile_definitions(test_wildcard PRIVATE TEST)
  79. target_link_libraries(test_wildcard utils ${platform_libraries})
  80. add_executable(test_cert_expr
  81. utils/cert-expr.c)
  82. target_compile_definitions(test_cert_expr PRIVATE TEST)
  83. target_link_libraries(test_cert_expr utils ${platform_libraries})
  84. add_executable(bidi_gettype
  85. terminal/bidi_gettype.c)
  86. target_link_libraries(bidi_gettype guiterminal utils ${platform_libraries})
  87. add_executable(bidi_test
  88. terminal/bidi_test.c)
  89. target_link_libraries(bidi_test guiterminal utils ${platform_libraries})
  90. add_executable(plink
  91. ${platform}/plink.c
  92. stubs/no-lineedit.c)
  93. # Note: if we ever port Plink to a platform where we can't implement a
  94. # serial backend, this be_list command will need to become platform-
  95. # dependent, so that it only sets the SERIAL option on platforms where
  96. # that backend exists. For the moment, though, we have serial port
  97. # backends for both our platforms, so we can do this unconditionally.
  98. be_list(plink Plink SSH SERIAL OTHERBACKENDS)
  99. target_link_libraries(plink
  100. eventloop noterminal console sshclient otherbackends settings network crypto
  101. utils
  102. ${platform_libraries})
  103. installed_program(plink)
  104. add_executable(pscp
  105. pscp.c)
  106. be_list(pscp PSCP SSH)
  107. target_link_libraries(pscp
  108. sftpclient eventloop console sshclient settings network crypto utils
  109. ${platform_libraries})
  110. installed_program(pscp)
  111. add_executable(psftp
  112. psftp.c)
  113. be_list(psftp PSFTP SSH)
  114. target_link_libraries(psftp
  115. sftpclient eventloop console sshclient settings network crypto utils
  116. ${platform_libraries})
  117. installed_program(psftp)
  118. add_executable(psocks
  119. ${platform}/psocks.c
  120. psocks.c
  121. stubs/no-rand.c
  122. proxy/nocproxy.c
  123. proxy/nosshproxy.c
  124. ssh/portfwd.c)
  125. target_link_libraries(psocks
  126. eventloop console network utils
  127. ${platform_libraries})
  128. add_executable(test_conf
  129. test/test_conf.c
  130. stubs/no-agent.c
  131. stubs/no-callback.c
  132. stubs/no-gss.c
  133. stubs/no-ldisc.c
  134. stubs/no-network.c
  135. stubs/no-timing.c
  136. proxy/noproxy.c # FIXME: move this to stubs
  137. )
  138. be_list(test_conf TestConf SSH SERIAL OTHERBACKENDS)
  139. target_link_libraries(test_conf sshclient otherbackends settings network crypto utils ${platform_libraries})
  140. foreach(subdir ${platform} ${extra_dirs})
  141. add_subdirectory(${subdir})
  142. endforeach()
  143. configure_file(cmake/cmake.h.in ${GENERATED_SOURCES_DIR}/cmake.h)