call OptimizeHeaders script explicitly from component installation targets

fixes headers optimization when installing from component target, e.g. when
making package from the provided Debian package files

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-06-25 14:59:50 +03:00
parent 4e0b42ea5d
commit 014b7c0725
3 changed files with 21 additions and 13 deletions

View file

@ -1083,10 +1083,19 @@ katie_string_unwrap("${KATIE_COMPONENTS}" KATIE_COMPONENTS "Kt")
katie_string_unwrap("${KATIE_TOOLS}" KATIE_TOOLS)
# custom install targets to make packaging easier
add_custom_target(install-devel
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=Devel -P cmake_install.cmake
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if(KATIE_UNIFDEF)
add_custom_target(install-devel
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=Devel -P cmake_install.cmake
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
# installing from script does not execute other scripts
COMMAND "${CMAKE_COMMAND}" -DUNIFDEF_EXECUTABLE="${KATIE_UNIFDEF}" -DHEADERS_DIRECTORY="${KATIE_HEADERS_PATH}" -P "${CMAKE_SOURCE_DIR}/cmake/modules/OptimizeHeaders.cmake"
)
else()
add_custom_target(install-devel
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=Devel -P cmake_install.cmake
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
endif()
add_custom_target(install-runtime
DEPENDS ${KATIE_COMPONENTS}

View file

@ -308,7 +308,6 @@ macro(KATIE_OPTIMIZE_HEADERS DIR)
install(
CODE "set(UNIFDEF_EXECUTABLE \"${KATIE_UNIFDEF}\")"
CODE "set(HEADERS_DIRECTORY \"${DIR}\")"
CODE "set(HEADERS_DEFINITIONS \"${ARGN}\")"
SCRIPT "${CMAKE_SOURCE_DIR}/cmake/modules/OptimizeHeaders.cmake"
)
endif()

View file

@ -1,16 +1,16 @@
# Copyright (C) 2015, Ivailo Monev, <xakepa10@gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# UNIFDEF_EXECUTABLE, HEADERS_DIRECTORY and HEADERS_DEFINITIONS origin from the macro call
# UNIFDEF_EXECUTABLE and HEADERS_DIRECTORY origin from the macro call
file(GLOB headers "$ENV{DESTDIR}/${HEADERS_DIRECTORY}/*.h")
set(headers_directory "$ENV{DESTDIR}/${HEADERS_DIRECTORY}")
file(GLOB_RECURSE headers "${headers_directory}/*.h")
set(bootstrap
set(unifdef_arguments
# bootstrap
-UQT_BOOTSTRAPPED
-UQT_MOC
)
set(notsupported
# not supported
-UQT_NO_QOBJECT
-UQT_NO_COMPRESS
-UQT_NO_THREAD
@ -32,9 +32,9 @@ set(notsupported
-UQT_NO_TEXTCODEC
)
message(STATUS "Optimizing header in: $ENV{DESTDIR}/${HEADERS_DIRECTORY}")
message(STATUS "Optimizing header in: ${headers_directory}")
execute_process(
COMMAND ${UNIFDEF_EXECUTABLE} -m ${bootstrap} ${notsupported} ${HEADERS_DEFINITIONS} ${headers}
COMMAND ${UNIFDEF_EXECUTABLE} -m ${unifdef_arguments} ${headers}
RESULT_VARIABLE unifdef_result
ERROR_VARIABLE unifdef_output
OUTPUT_VARIABLE unifdef_output