From 92e453754b344f0205b48a716d2c9e2352a842aa Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 18 Oct 2023 15:21:32 +0200 Subject: [PATCH] [CMake] add public headers to targets Add all public headers to the respective library targets. This helps an IDE to show the headers grouped to the correct target. --- include/CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++++++ winpr/include/CMakeLists.txt | 26 +++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index aafc273d1..4f5ad315a 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,6 +22,47 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/build-config.h.in ${CMAKE_CURR configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/buildflags.h) +file(GLOB_RECURSE PUBLIC_COMMON_HEADERS + LIST_DIRECTORIES false + "freerdp/*.h" +) +file(GLOB_RECURSE PUBLIC_COMMON_BIN_HEADERS + LIST_DIRECTORIES false + "${CMAKE_CURRENT_BINARY_DIR}/freerdp/*.h" +) +list(SORT PUBLIC_COMMON_HEADERS) + +set(PUBLIC_SERVER_HEADERS ${PUBLIC_COMMON_HEADERS}) +list(FILTER PUBLIC_SERVER_HEADERS INCLUDE REGEX ".*freerdp/server.*") + +set(PUBLIC_PROXY_HEADERS ${PUBLIC_SERVER_HEADERS}) +list(FILTER PUBLIC_SERVER_HEADERS EXCLUDE REGEX ".*freerdp/server/proxy.*") +list(FILTER PUBLIC_PROXY_HEADERS INCLUDE REGEX ".*freerdp/server/proxy.*") +if (WITH_SERVER) + set_property(TARGET freerdp-server APPEND PROPERTY SOURCES + ${PUBLIC_SERVER_HEADERS} + ) +endif() +if (WITH_PROXY) + set_property(TARGET freerdp-server-proxy APPEND PROPERTY SOURCES + ${PUBLIC_PROXY_HEADERS} + ) +endif() + +if (WITH_CLIENT_COMMON) + set(PUBLIC_CLIENT_HEADERS ${PUBLIC_COMMON_HEADERS}) + list(FILTER PUBLIC_CLIENT_HEADERS INCLUDE REGEX ".*freerdp/client.*") + set_property( TARGET freerdp-client APPEND PROPERTY SOURCES + ${PUBLIC_CLIENT_HEADERS} + ) +endif() + +list(FILTER PUBLIC_COMMON_HEADERS EXCLUDE REGEX ".*freerdp/server.*") +list(FILTER PUBLIC_COMMON_HEADERS EXCLUDE REGEX ".*freerdp/client.*") +list(APPEND PUBLIC_COMMON_HEADERS ${PUBLIC_COMMON_BIN_HEADERS}) +set_property(TARGET freerdp APPEND PROPERTY SOURCES + ${PUBLIC_COMMON_HEADERS} +) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/freerdp DESTINATION ${FREERDP_INCLUDE_DIR} diff --git a/winpr/include/CMakeLists.txt b/winpr/include/CMakeLists.txt index a64166439..5dc488581 100644 --- a/winpr/include/CMakeLists.txt +++ b/winpr/include/CMakeLists.txt @@ -21,6 +21,32 @@ configure_file(config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/build- configure_file(config/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/buildflags.h) configure_file(config/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/config.h) +file(GLOB_RECURSE WINPR_PUBLIC_COMMON_HEADERS + LIST_DIRECTORIES false + "winpr/*.h" +) + +set(WINPR_PUBLIC_TOOLS_HEADERS ${WINPR_PUBLIC_COMMON_HEADERS}) +list(FILTER WINPR_PUBLIC_TOOLS_HEADERS INCLUDE REGEX ".*winpr/tools.*") +list(FILTER WINPR_PUBLIC_COMMON_HEADERS EXCLUDE REGEX ".*winpr/tools.*") + +file(GLOB_RECURSE WINPR_PUBLIC_COMMON_BIN_HEADERS + LIST_DIRECTORIES false + "${CMAKE_CURRENT_BINARY_DIR}/*.h" +) +list(APPEND WINPR_PUBLIC_COMMON_HEADERS ${WINPR_PUBLIC_COMMON_BIN_HEADERS}) +list(SORT WINPR_PUBLIC_COMMON_HEADERS) + +set_property(TARGET winpr APPEND PROPERTY SOURCES + ${WINPR_PUBLIC_COMMON_HEADERS} +) + +if (WITH_WINPR_TOOLS) + set_property(TARGET winpr-tools APPEND PROPERTY SOURCES + ${WINPR_PUBLIC_TOOLS_HEADERS} + ) +endif() + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${WINPR_INCLUDE_DIR} FILES_MATCHING PATTERN "*.h")