[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.
This commit is contained in:
akallabeth 2023-10-18 15:21:32 +02:00 committed by Martin Fleisz
parent 9835a916ae
commit 92e453754b
2 changed files with 67 additions and 0 deletions

View File

@ -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}

View File

@ -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")