diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bf6eacd..9edbc40e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,42 @@ add_executable(test_wildcard target_compile_definitions(test_wildcard PRIVATE TEST) target_link_libraries(test_wildcard utils ${platform_libraries}) -foreach(subdir ${PLATFORM_SUBDIRS}) +add_executable(plink + ${platform}/plink.c + be_all_s.c) +target_link_libraries(plink + eventloop noterminal console sshclient otherbackends settings network crypto + utils + ${platform_libraries}) +installed_program(plink) + +add_executable(pscp + pscp.c + be_ssh.c) +target_link_libraries(pscp + sftpclient eventloop console sshclient settings network crypto utils + ${platform_libraries}) +installed_program(pscp) + +add_executable(psftp + psftp.c + be_ssh.c) +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 + norand.c + nocproxy.c + ssh/portfwd.c) +target_link_libraries(psocks + eventloop console network utils + ${platform_libraries}) + +foreach(subdir ${platform} ${extra_dirs}) add_subdirectory(${subdir}) endforeach() diff --git a/cmake/platforms/unix.cmake b/cmake/platforms/unix.cmake index c09d5d8f..080896a6 100644 --- a/cmake/platforms/unix.cmake +++ b/cmake/platforms/unix.cmake @@ -1,5 +1,3 @@ -set(PLATFORM_SUBDIRS charset unix) - set(PUTTY_GSSAPI DYNAMIC CACHE STRING "Build PuTTY with dynamically or statically linked \ Kerberos / GSSAPI support, if possible") @@ -80,6 +78,8 @@ add_optional_system_lib(m pow) add_optional_system_lib(rt clock_gettime) add_optional_system_lib(xnet socket) +set(extra_dirs charset) + if(PUTTY_GSSAPI STREQUAL DYNAMIC) add_optional_system_lib(dl dlopen) if(HAVE_NO_LIBdl) diff --git a/cmake/platforms/windows.cmake b/cmake/platforms/windows.cmake index c3f2b97f..931812f2 100644 --- a/cmake/platforms/windows.cmake +++ b/cmake/platforms/windows.cmake @@ -1,5 +1,3 @@ -set(PLATFORM_SUBDIRS windows) - set(PUTTY_MINEFIELD OFF CACHE BOOL "Build PuTTY with its built-in memory debugger 'Minefield'") set(PUTTY_GSSAPI ON diff --git a/cmake/setup.cmake b/cmake/setup.cmake index 4bd599a4..ffc23184 100644 --- a/cmake/setup.cmake +++ b/cmake/setup.cmake @@ -61,16 +61,20 @@ function(add_sources_from_current_dir target) target_sources(${target} PRIVATE ${sources}) endfunction() +set(extra_dirs) if(CMAKE_SYSTEM_NAME MATCHES "Windows" OR WINELIB) - include(cmake/platforms/windows.cmake) + set(platform windows) else() - include(cmake/platforms/unix.cmake) + set(platform unix) endif() +include(cmake/platforms/${platform}.cmake) + include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${GENERATED_SOURCES_DIR} - ${PLATFORM_SUBDIRS}) + ${platform} + ${extra_dirs}) if(PUTTY_DEBUG) add_compile_definitions(DEBUG) diff --git a/unix/CMakeLists.txt b/unix/CMakeLists.txt index 56786b94..f724bbe7 100644 --- a/unix/CMakeLists.txt +++ b/unix/CMakeLists.txt @@ -61,40 +61,10 @@ target_link_libraries(fuzzterm add_executable(osxlaunch osxlaunch.c) -add_executable(plink - plink.c - ${CMAKE_SOURCE_DIR}/be_all_s.c - no-gtk.c) -target_link_libraries(plink - eventloop noterminal console sshclient otherbackends settings network crypto - utils) -installed_program(plink) - -add_executable(pscp - ${CMAKE_SOURCE_DIR}/pscp.c - ${CMAKE_SOURCE_DIR}/be_ssh.c - no-gtk.c) -target_link_libraries(pscp - sftpclient eventloop console sshclient settings network crypto utils) -installed_program(pscp) - -add_executable(psftp - ${CMAKE_SOURCE_DIR}/psftp.c - ${CMAKE_SOURCE_DIR}/be_ssh.c - no-gtk.c) -target_link_libraries(psftp - sftpclient eventloop console sshclient settings network crypto utils) -installed_program(psftp) - -add_executable(psocks - psocks.c - ${CMAKE_SOURCE_DIR}/psocks.c - ${CMAKE_SOURCE_DIR}/norand.c - ${CMAKE_SOURCE_DIR}/nocproxy.c - ${CMAKE_SOURCE_DIR}/ssh/portfwd.c - no-gtk.c) -target_link_libraries(psocks - eventloop console network utils) +add_sources_from_current_dir(plink no-gtk.c) +add_sources_from_current_dir(pscp no-gtk.c) +add_sources_from_current_dir(psftp no-gtk.c) +add_sources_from_current_dir(psocks no-gtk.c) add_executable(psusan psusan.c diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 739b49f3..288827cb 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -68,53 +68,16 @@ set_target_properties(pageant PROPERTIES LINK_FLAGS "${LFLAG_MANIFEST_NO}") installed_program(pageant) -add_executable(plink - plink.c - ${CMAKE_SOURCE_DIR}/be_all_s.c - no-jump-list.c - nohelp.c - plink.rc) +add_sources_from_current_dir(plink no-jump-list.c nohelp.c plink.rc) add_dependencies(plink generated_licence_h) -target_link_libraries(plink - eventloop console noterminal sshclient otherbackends settings network crypto - utils - ${platform_libraries}) -installed_program(plink) -add_executable(pscp - ${CMAKE_SOURCE_DIR}/pscp.c - ${CMAKE_SOURCE_DIR}/be_ssh.c - no-jump-list.c - nohelp.c - pscp.rc) +add_sources_from_current_dir(pscp no-jump-list.c nohelp.c pscp.rc) add_dependencies(pscp generated_licence_h) -target_link_libraries(pscp - sftpclient eventloop console sshclient settings network crypto utils - ${platform_libraries}) -installed_program(pscp) -add_executable(psftp - ${CMAKE_SOURCE_DIR}/psftp.c - ${CMAKE_SOURCE_DIR}/be_ssh.c - no-jump-list.c - nohelp.c - psftp.rc) +add_sources_from_current_dir(psftp no-jump-list.c nohelp.c psftp.rc) add_dependencies(psftp generated_licence_h) -target_link_libraries(psftp - sftpclient eventloop console sshclient settings network crypto utils - ${platform_libraries}) -installed_program(psftp) -add_executable(psocks - psocks.c - nohelp.c - ${CMAKE_SOURCE_DIR}/psocks.c - ${CMAKE_SOURCE_DIR}/norand.c - ${CMAKE_SOURCE_DIR}/nocproxy.c - ${CMAKE_SOURCE_DIR}/ssh/portfwd.c) -target_link_libraries(psocks - eventloop console network utils - ${platform_libraries}) +add_sources_from_current_dir(psocks nohelp.c) add_executable(putty window.c