CMake: Only install headers required by the used toolkit

See #22714
This commit is contained in:
Maarten Bent
2025-01-03 17:11:18 +01:00
parent 9dfb25adcf
commit 0c725cdaea
3 changed files with 24 additions and 5 deletions
+14 -2
View File
@@ -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(<target_name> [IS_BASE;IS_PLUGIN;IS_MONO] <src_files>...)
+9 -3
View File
@@ -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"
+1
View File
@@ -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)