From 0c725cdaea3bcce97c76f8b7937df3a6da924795 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 4 Sep 2024 17:21:52 +0200 Subject: [PATCH] CMake: Only install headers required by the used toolkit See #22714 --- build/cmake/functions.cmake | 16 ++++++++++++++-- build/cmake/install.cmake | 12 +++++++++--- build/cmake/lib/CMakeLists.txt | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 8c2be7edbb..81d67dfb0b 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -21,6 +21,12 @@ else() endif() +# List of libraries added via wx_add_library() to use for wx-config +# and headers added via wx_append_sources() to use for install. +set(wxLIB_TARGETS) +set(wxINSTALL_HEADERS) + + # This function adds a list of headers to a variable while prepending # include/ to the path macro(wx_add_headers src_var) @@ -52,6 +58,14 @@ macro(wx_append_sources src_var source_base_name) endif() if(DEFINED ${source_base_name}_HDR) wx_add_headers(${src_var} ${${source_base_name}_HDR}) + + list(APPEND wxINSTALL_HEADERS ${${source_base_name}_HDR}) + set(wxINSTALL_HEADERS ${wxINSTALL_HEADERS} PARENT_SCOPE) + endif() + + if(DEFINED ${source_base_name}_RSC) + list(APPEND wxINSTALL_HEADERS ${${source_base_name}_RSC}) + set(wxINSTALL_HEADERS ${wxINSTALL_HEADERS} PARENT_SCOPE) endif() endmacro() @@ -436,8 +450,6 @@ macro(wx_get_install_dir artifact default) endif() endmacro() -# List of libraries added via wx_add_library() to use for wx-config -set(wxLIB_TARGETS) # Add a wxWidgets library # wx_add_library( [IS_BASE;IS_PLUGIN;IS_MONO] ...) diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake index 384c6837b8..a02e0eb3ac 100644 --- a/build/cmake/install.cmake +++ b/build/cmake/install.cmake @@ -12,9 +12,15 @@ if(NOT wxBUILD_INSTALL) endif() install(CODE "message(STATUS \"Installing: Headers...\")") -install( - DIRECTORY "${wxSOURCE_DIR}/include/wx" - DESTINATION "${wxINSTALL_INCLUDE_DIR}") + +foreach(header ${wxINSTALL_HEADERS}) + get_filename_component(path "${header}" PATH) + install( + FILES "${wxSOURCE_DIR}/include/${header}" + DESTINATION "${wxINSTALL_INCLUDE_DIR}/${path}" + ) +endforeach() + if(MSVC) install( DIRECTORY "${wxSOURCE_DIR}/include/msvc" diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index bd234dc13c..04d830d7de 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -110,3 +110,4 @@ endif() # Propagate variable(s) to parent scope set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE) +set(wxINSTALL_HEADERS ${wxINSTALL_HEADERS} PARENT_SCOPE)