1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-08 08:58:00 +00:00
putty-source/CMakeLists.txt
Simon Tatham 75b6e12f84 Add two new string types to the Conf system.
This begins the process of making PuTTY more able to handle Unicode
strings as a first-class type in its configuration. One of the new
types, CONF_TYPE_UTF8, looks physically just like CONF_TYPE_STR but
the semantics are that it's definitely encoded in UTF-8, instead of
'shrug, whatever the system locale's encoding is'.

Unfortunately, we can't yet switch over any Conf items to having that
type, because our data representations in saved configuration (both on
Unix and Windows) store char strings in the system encoding. So we'll
have to change that representation at the same time, which risks
breaking backwards compatibility with old PuTTYs reading the same
configuration.

So the other new type, CONF_TYPE_STR_AMBI, is intended as a
transitional form, recording a configuration setting that _might_ be
explicitly UTF-8 or might have the legacy 'shrug, whatever' semantics,
depending on where we got it from.

My general migration plan is that first I _enable_ Unicode support in
a Conf item, by turning it into STR_AMBI; the Unicode version of the
string (if any) is saved in a new location, and a best-effort
local-charset version is saved where it's always been. That way new
PuTTY can read the Unicode version, and old PuTTY reading that
configuration will behave no worse than it would have done already.

It would be nice to think that in the far future we've migrated
everything to STR_AMBI and can move them all to mandatory UTF-8,
obsoleting the old configuration. I think it's more likely we'll never
get there. But at least _new_ Conf items, with no backwards
compatibility requirement in the first place, can be CONF_TYPE_UTF8
where appropriate.

(In conf_get_str_ambi(), I considered making it mandatory via assert()
to pass the 'utf8' output pointer as non-NULL, to defend against lazy
adaptation of existing code by just changing the function call. But in
fact I think there's a legitimate use case for not caring if the
output is UTF-8 or not, because some of the existing SSH code
currently just shoves strings like usernames directly on to the wire
whether they're in the right encoding or not; so if you want to do the
correct UTF-8 thing where possible and preserve legacy behaviour if
not, then treating both classes of string the same _is_ the right
thing to do.)

This also requires linking the Unicode support into many Unix
applications that hadn't previously needed it.
2024-09-26 11:30:07 +01:00

188 lines
5.1 KiB
CMake

cmake_minimum_required(VERSION 3.7)
project(putty LANGUAGES C)
set(CMAKE_C_STANDARD 99)
include(cmake/setup.cmake)
# Scan the docs directory first, so that when we start calling
# installed_program(), we'll know if we have man pages available
add_subdirectory(doc)
add_compile_definitions(HAVE_CMAKE_H)
include_directories(terminal)
add_library(utils STATIC
${GENERATED_COMMIT_C})
add_dependencies(utils cmake_commit_c)
add_subdirectory(utils)
add_subdirectory(stubs)
add_library(logging OBJECT
logging.c utils/logeventf.c)
add_library(eventloop STATIC
callback.c timing.c)
add_library(console STATIC
clicons.c console.c)
add_library(settings STATIC
cmdline.c settings.c)
add_library(crypto STATIC
proxy/cproxy.c proxy/sshproxy.c)
add_subdirectory(crypto)
add_library(network STATIC
errsock.c x11disp.c
$<TARGET_OBJECTS:logging>
proxy/proxy.c
proxy/http.c
proxy/socks4.c
proxy/socks5.c
proxy/telnet.c
proxy/local.c
proxy/interactor.c)
add_library(keygen STATIC
import.c)
add_subdirectory(keygen)
add_library(agent STATIC
sshpubk.c pageant.c aqsync.c)
add_library(guiterminal STATIC
terminal/terminal.c terminal/bidi.c
ldisc.c terminal/lineedit.c config.c dialog.c
$<TARGET_OBJECTS:logging>)
add_library(noterminal STATIC
stubs/no-term.c ldisc.c)
add_library(all-backends OBJECT
pinger.c)
add_library(sftpclient STATIC
psftpcommon.c)
add_subdirectory(ssh)
add_library(otherbackends STATIC
$<TARGET_OBJECTS:all-backends>
$<TARGET_OBJECTS:logging>)
add_subdirectory(otherbackends)
add_executable(testcrypt
test/testcrypt.c sshpubk.c ssh/crc-attack-detector.c)
target_link_libraries(testcrypt
keygen crypto utils ${platform_libraries})
add_executable(test_host_strfoo
utils/host_strchr_internal.c)
target_compile_definitions(test_host_strfoo PRIVATE TEST)
target_link_libraries(test_host_strfoo utils ${platform_libraries})
add_executable(test_decode_utf8
utils/decode_utf8.c)
target_compile_definitions(test_decode_utf8 PRIVATE TEST)
target_link_libraries(test_decode_utf8 utils ${platform_libraries})
add_executable(test_unicode_norm
utils/unicode-norm.c)
target_compile_definitions(test_unicode_norm PRIVATE TEST)
target_link_libraries(test_unicode_norm utils ${platform_libraries})
add_executable(test_tree234
utils/tree234.c)
target_compile_definitions(test_tree234 PRIVATE TEST)
target_link_libraries(test_tree234 utils ${platform_libraries})
add_executable(test_wildcard
utils/wildcard.c)
target_compile_definitions(test_wildcard PRIVATE TEST)
target_link_libraries(test_wildcard utils ${platform_libraries})
add_executable(test_cert_expr
utils/cert-expr.c)
target_compile_definitions(test_cert_expr PRIVATE TEST)
target_link_libraries(test_cert_expr utils ${platform_libraries})
add_executable(bidi_gettype
terminal/bidi_gettype.c)
target_link_libraries(bidi_gettype guiterminal utils ${platform_libraries})
add_executable(bidi_test
terminal/bidi_test.c)
target_link_libraries(bidi_test guiterminal utils ${platform_libraries})
add_executable(plink
${platform}/plink.c
stubs/no-lineedit.c)
# Note: if we ever port Plink to a platform where we can't implement a
# serial backend, this be_list command will need to become platform-
# dependent, so that it only sets the SERIAL option on platforms where
# that backend exists. For the moment, though, we have serial port
# backends for both our platforms, so we can do this unconditionally.
be_list(plink Plink SSH SERIAL OTHERBACKENDS)
target_link_libraries(plink
eventloop noterminal console sshclient otherbackends settings network crypto
utils
${platform_libraries})
installed_program(plink)
add_executable(pscp
pscp.c)
be_list(pscp PSCP SSH)
target_link_libraries(pscp
sftpclient eventloop console sshclient settings network crypto utils
${platform_libraries})
installed_program(pscp)
add_executable(psftp
psftp.c)
be_list(psftp PSFTP SSH)
target_link_libraries(psftp
sftpclient eventloop console sshclient settings network crypto utils
${platform_libraries})
installed_program(psftp)
add_executable(psocks
${platform}/psocks.c
psocks.c
stubs/no-rand.c
proxy/nocproxy.c
proxy/nosshproxy.c
ssh/portfwd.c)
target_link_libraries(psocks
eventloop console network utils
${platform_libraries})
add_executable(test_conf
test/test_conf.c
stubs/no-agent.c
stubs/no-callback.c
stubs/no-gss.c
stubs/no-ldisc.c
stubs/no-network.c
stubs/no-timing.c
proxy/noproxy.c # FIXME: move this to stubs
)
be_list(test_conf TestConf SSH SERIAL OTHERBACKENDS)
target_link_libraries(test_conf sshclient otherbackends settings network crypto utils ${platform_libraries})
foreach(subdir ${platform} ${extra_dirs})
add_subdirectory(${subdir})
endforeach()
# Nasty bodge: we'd like to run this command inside unix/CMakeLists,
# adding the 'charset' library to everything that links with utils.
# But that wasn't allowed until cmake 3.13 (see cmake policy CMP0073),
# and we still have a min cmake version less than that. So we do it
# here instead.
if(platform STREQUAL unix)
target_link_libraries(utils charset)
endif()
configure_file(cmake/cmake.h.in ${GENERATED_SOURCES_DIR}/cmake.h)