From 2b3c8c47a40608572160edc33fd7f7484df7b3b4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 11 May 2023 14:15:53 +0200 Subject: [PATCH] [build] fix install with BUILD_SHARED_LIBS=OFF generate proper CMake targets so static linking works again. --- channels/CMakeLists.txt | 19 ++++++++++++++++++- channels/rdpsnd/client/CMakeLists.txt | 5 ++++- channels/rdpsnd/common/CMakeLists.txt | 6 +++--- channels/rdpsnd/server/CMakeLists.txt | 5 +++-- channels/urbdrc/client/CMakeLists.txt | 3 ++- client/CMakeLists.txt | 4 +--- server/CMakeLists.txt | 4 +--- server/proxy/CMakeLists.txt | 6 ++---- server/proxy/channels/CMakeLists.txt | 2 +- server/shadow/CMakeLists.txt | 4 +--- 10 files changed, 36 insertions(+), 22 deletions(-) diff --git a/channels/CMakeLists.txt b/channels/CMakeLists.txt index 09318fd83..45f3ccec8 100644 --- a/channels/CMakeLists.txt +++ b/channels/CMakeLists.txt @@ -162,6 +162,20 @@ macro(add_channel_client_subsystem _channel_prefix _channel_name _subsystem _typ endif() endmacro(add_channel_client_subsystem) +macro(channel_install _targets _destination _export_target) + if (NOT BUILD_SHARED_LIBS) + install(TARGETS ${_targets} DESTINATION ${_destination} EXPORT ${_export_target}) + endif() +endmacro(channel_install) + +macro(server_channel_install _targets _destination) + channel_install(${_targets} ${_destination} "FreeRDP-ServerTargets") +endmacro(server_channel_install) + +macro(client_channel_install _targets _destination) + channel_install(${_targets} ${_destination} "FreeRDP-ClientTargets") +endmacro(client_channel_install) + macro(add_channel_client_library _module_prefix _module_name _channel_name _dynamic _entry) set(_lnk_dir ${${_module_prefix}_LINK_DIRS}) if (NOT "${_lnk_dir}" STREQUAL "") @@ -174,11 +188,12 @@ macro(add_channel_client_library _module_prefix _module_name _channel_name _dyna set(${_module_prefix}_ENTRY ${_entry} PARENT_SCOPE) add_library(${_module_name} OBJECT ${${_module_prefix}_SRCS}) - set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client") + set_property(TARGET ${_module_name} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client") if (${_module_prefix}_LIBS) target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS}) endif() + client_channel_install(${_module_name} ${FREERDP_ADDIN_PATH}) endmacro(add_channel_client_library) macro(add_channel_client_subsystem_library _module_prefix _module_name _channel_name _type _dynamic _entry) @@ -197,6 +212,7 @@ macro(add_channel_client_subsystem_library _module_prefix _module_name _channel_ if (${_module_prefix}_LIBS) target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS}) endif() + client_channel_install(${_module_name} ${FREERDP_ADDIN_PATH}) endmacro(add_channel_client_subsystem_library) macro(add_channel_server_library _module_prefix _module_name _channel_name _dynamic _entry) @@ -216,6 +232,7 @@ macro(add_channel_server_library _module_prefix _module_name _channel_name _dyna if (${_module_prefix}_LIBS) target_link_libraries(${_module_name} PUBLIC ${${_module_prefix}_LIBS}) endif() + server_channel_install(${_module_name} ${FREERDP_ADDIN_PATH}) endmacro(add_channel_server_library) set(FILENAME "ChannelOptions.cmake") diff --git a/channels/rdpsnd/client/CMakeLists.txt b/channels/rdpsnd/client/CMakeLists.txt index 4c8c639e7..6f4bee3d2 100644 --- a/channels/rdpsnd/client/CMakeLists.txt +++ b/channels/rdpsnd/client/CMakeLists.txt @@ -20,10 +20,13 @@ define_channel_client("rdpsnd") set(${MODULE_PREFIX}_SRCS rdpsnd_main.c rdpsnd_main.h + $ ) set(${MODULE_PREFIX}_LIBS - winpr freerdp ${CMAKE_THREAD_LIBS_INIT} rdpsnd-common + winpr + freerdp + ${CMAKE_THREAD_LIBS_INIT} ) add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE "VirtualChannelEntryEx;DVCPluginEntry") diff --git a/channels/rdpsnd/common/CMakeLists.txt b/channels/rdpsnd/common/CMakeLists.txt index 7725c7c91..06647c34c 100644 --- a/channels/rdpsnd/common/CMakeLists.txt +++ b/channels/rdpsnd/common/CMakeLists.txt @@ -17,9 +17,9 @@ # limitations under the License. set(SRCS - rdpsnd_common.h - rdpsnd_common.c) + rdpsnd_common.h + rdpsnd_common.c) # Library currently header only -add_library(rdpsnd-common STATIC ${SRCS}) +add_library(rdpsnd-common OBJECT ${SRCS}) diff --git a/channels/rdpsnd/server/CMakeLists.txt b/channels/rdpsnd/server/CMakeLists.txt index ab983abf3..623d2f036 100644 --- a/channels/rdpsnd/server/CMakeLists.txt +++ b/channels/rdpsnd/server/CMakeLists.txt @@ -19,10 +19,11 @@ define_channel_server("rdpsnd") set(${MODULE_PREFIX}_SRCS rdpsnd_main.c - rdpsnd_main.h) + rdpsnd_main.h + $ +) set(${MODULE_PREFIX}_LIBS - rdpsnd-common ) add_channel_server_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} FALSE "VirtualChannelEntry") diff --git a/channels/urbdrc/client/CMakeLists.txt b/channels/urbdrc/client/CMakeLists.txt index 0e1f89ad2..178702475 100644 --- a/channels/urbdrc/client/CMakeLists.txt +++ b/channels/urbdrc/client/CMakeLists.txt @@ -26,7 +26,8 @@ set(${MODULE_PREFIX}_SRCS ) set(${MODULE_PREFIX}_LIBS - winpr freerdp + winpr + freerdp urbdrc-common ) if (UDEV_FOUND AND UDEV_LIBRARIES) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index e23ab35f6..8822a22be 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -107,6 +107,4 @@ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfi install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ClientConfigVersion.cmake DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR}) -if (BUILD_SHARED_LIBS) - install(EXPORT FreeRDP-ClientTargets DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR}) -endif() +install(EXPORT FreeRDP-ClientTargets DESTINATION ${FREERDP_CLIENT_CMAKE_INSTALL_DIR}) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index b8943ad77..d4a360dfe 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -90,6 +90,4 @@ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ServerConfi install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ServerConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ServerConfigVersion.cmake DESTINATION ${FREERDP_SERVER_CMAKE_INSTALL_DIR}) -if (BUILD_SHARED_LIBS) - install(EXPORT FreeRDP-ServerTargets DESTINATION ${FREERDP_SERVER_CMAKE_INSTALL_DIR}) -endif() +install(EXPORT FreeRDP-ServerTargets DESTINATION ${FREERDP_SERVER_CMAKE_INSTALL_DIR}) diff --git a/server/proxy/CMakeLists.txt b/server/proxy/CMakeLists.txt index 2cf51c749..4a23a4f57 100644 --- a/server/proxy/CMakeLists.txt +++ b/server/proxy/CMakeLists.txt @@ -39,6 +39,7 @@ set(${MODULE_PREFIX}_SRCS pf_modules.c pf_utils.h pf_utils.c + $ ) set(PROXY_APP_SRCS freerdp_proxy.c) @@ -73,7 +74,6 @@ endif() set(PRIVATE_LIBS freerdp-client freerdp-server - pf_channels ) set(PUBLIC_LIBS @@ -103,9 +103,7 @@ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ProxyConfig install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ProxyConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ProxyConfigVersion.cmake DESTINATION ${FREERDP_PROXY_CMAKE_INSTALL_DIR}) -if (BUILD_SHARED_LIBS) - install(EXPORT FreeRDP-ProxyTargets DESTINATION ${FREERDP_PROXY_CMAKE_INSTALL_DIR}) -endif() +install(EXPORT FreeRDP-ProxyTargets DESTINATION ${FREERDP_PROXY_CMAKE_INSTALL_DIR}) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/proxy") diff --git a/server/proxy/channels/CMakeLists.txt b/server/proxy/channels/CMakeLists.txt index 2912d1ff2..1915d83d2 100644 --- a/server/proxy/channels/CMakeLists.txt +++ b/server/proxy/channels/CMakeLists.txt @@ -14,4 +14,4 @@ if (WITH_PROXY_EMULATE_SMARTCARD) ) endif() -add_library(${MODULE_NAME} STATIC ${SOURCES}) +add_library(${MODULE_NAME} OBJECT ${SOURCES}) diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index 0a6693a54..c62a4eae6 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -377,6 +377,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ShadowConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FreeRDP-ShadowConfigVersion.cmake DESTINATION ${FREERDP_SERVER_CMAKE_INSTALL_DIR}) -if (BUILD_SHARED_LIBS) - install(EXPORT FreeRDP-ShadowTargets DESTINATION ${FREERDP_SERVER_CMAKE_INSTALL_DIR}) -endif() +install(EXPORT FreeRDP-ShadowTargets DESTINATION ${FREERDP_SERVER_CMAKE_INSTALL_DIR})