[cmake] cleaning_configure_file

add a wrapper to automatically add generated files to clean target
This commit is contained in:
akallabeth 2024-10-02 22:37:35 +02:00
parent c86a78bef7
commit cfc37caeb8
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
23 changed files with 67 additions and 44 deletions

View File

@ -32,10 +32,11 @@ set(${MODULE_PREFIX}_LIBS
include_directories(..)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(SYSTEM ${OSS_INCLUDE_DIRS})
configure_file(
cleaning_configure_file(
${CMAKE_SOURCE_DIR}/cmake/oss-includes.h.in
${CMAKE_CURRENT_BINARY_DIR}/oss-includes.h
@ONLY
)
add_channel_client_subsystem_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} "" TRUE "")

View File

@ -143,7 +143,7 @@ foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
endforeach()
string(APPEND CLIENT_STATIC_ADDIN_TABLE "\n\t{ NULL, NULL, { .cse = NULL }, NULL }\n};")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tables.c.in ${CMAKE_CURRENT_BINARY_DIR}/tables.c)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tables.c.in ${CMAKE_CURRENT_BINARY_DIR}/tables.c)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp winpr)

View File

@ -32,7 +32,7 @@ set(${MODULE_PREFIX}_LIBS
include_directories(..)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(SYSTEM ${OSS_INCLUDE_DIRS})
configure_file(
cleaning_configure_file(
${CMAKE_SOURCE_DIR}/cmake/oss-includes.h.in
${CMAKE_CURRENT_BINARY_DIR}/oss-includes.h
@ONLY

View File

@ -95,7 +95,7 @@ endif()
list(JOIN FREERDP_CLIENT_PC_PRIVATE_LIBS " " FREERDP_CLIENT_PC_PRIVATE_LIBS)
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-client.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-client.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-client${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
export(PACKAGE freerdp-client)

View File

@ -69,7 +69,7 @@ else()
)
endif()
configure_file(sdl_config.hpp.in sdl_config.hpp @ONLY)
cleaning_configure_file(sdl_config.hpp.in sdl_config.hpp @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(sdl-common-aad-view STATIC

View File

@ -33,12 +33,12 @@ macro(convert_to_bin FILE FILE_TYPE)
file_to_hex_array("${FILE}" FILEDATA)
configure_file(resource.hpp.in
cleaning_configure_file(resource.hpp.in
${FILE_BIN_DIR}/${TARGET_NAME}.hpp
@ONLY
)
configure_file(resource.cpp.in
cleaning_configure_file(resource.cpp.in
${FILE_BIN_DIR}/${TARGET_NAME}.cpp
@ONLY
)

View File

@ -1,5 +1,7 @@
set(add_resource_macro_internal_dir ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "")
include(CleaningConfigureFile)
macro(AddTargetWithResourceFile nameAndTarget is_exe version sources)
list(LENGTH ${nameAndTarget} target_length)
if (target_length GREATER 1)
@ -53,7 +55,7 @@ macro(AddTargetWithResourceFile nameAndTarget is_exe version sources)
endif()
endif()
configure_file(
cleaning_configure_file(
${add_resource_macro_internal_dir}/WindowsDLLVersion.rc.in
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@ONLY

View File

@ -0,0 +1,14 @@
# Little helper that adds the generated file to the
# files to be cleaned in the current directory.
#
# Handy if the generated files might have changed
#
function(cleaning_configure_file SRC DST)
configure_file(${SRC} ${DST} ${ARGN})
set_property(
DIRECTORY
APPEND
PROPERTY ADDITIONAL_CLEAN_FILES ${DST}
)
endfunction()

View File

@ -42,3 +42,4 @@ include(ConfigureRPATH)
include(ClangTidy)
include(AddTargetWithResourceFile)
include(DisableCompilerWarnings)
include(CleaningConfigureFile)

View File

@ -30,6 +30,8 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
include(CleaningConfigureFile)
if(__get_git_revision_description)
return()
endif()
@ -63,9 +65,9 @@ function(get_git_head_revision _refspecvar _hashvar)
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
cleaning_configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
cleaning_configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")

View File

@ -13,6 +13,8 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
include(CleaningConfigureFile)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
@ -22,14 +24,14 @@ if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
cleaning_configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
cleaning_configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
set(HEAD_HASH "${HEAD_REF}")
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
cleaning_configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)

View File

@ -1,5 +1,6 @@
include(GNUInstallDirs)
include(FindDocBookXSL)
include(CleaningConfigureFile)
function(install_freerdp_man manpage section)
if(WITH_MANPAGES)
@ -14,7 +15,7 @@ function(generate_and_install_freerdp_man_from_template name_base section api)
else()
set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}.${section}")
endif()
configure_file(${name_base}.${section}.in ${manpage})
cleaning_configure_file(${name_base}.${section}.in ${manpage})
install_freerdp_man(${manpage} ${section})
endif()
endfunction()
@ -27,12 +28,12 @@ function(generate_and_install_freerdp_man_from_xml target section dependencies)
set(manpage "${name_base}.${section}")
# We need the variable ${MAN_TODAY} to contain the current date in ISO
# format to replace it in the configure_file step.
# format to replace it in the cleaning_configure_file step.
include(today)
TODAY(MAN_TODAY)
configure_file(${template}.xml.in ${manpage}.xml @ONLY IMMEDIATE)
cleaning_configure_file(${template}.xml.in ${manpage}.xml @ONLY IMMEDIATE)
foreach(DEP IN LISTS dependencies)
get_filename_component(DNAME "${DEP}" NAME)
@ -41,7 +42,7 @@ function(generate_and_install_freerdp_man_from_xml target section dependencies)
if (EXISTS ${SRC})
message("generating ${DST} from ${SRC}")
configure_file(${SRC} ${DST} @ONLY IMMEDIATE)
cleaning_configure_file(${SRC} ${DST} @ONLY IMMEDIATE)
else()
message("using ${DST} from ${SRC}")
endif()

View File

@ -38,10 +38,10 @@ if (WIN32)
string(REPLACE "\\" "\\\\" NATIVE_FREERDP_PROXY_PLUGINDIR "${NATIVE_FREERDP_PROXY_PLUGINDIR}")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/version.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/build-config.h)
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)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/version.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/build-config.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/config.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/buildflags.h)
file(STRINGS freerdp/settings_types_private.h SETTINGS_KEYS REGEX "ALIGN64[ \ta-zA-Z0-9]*")
@ -127,7 +127,7 @@ string(REPLACE ";" ",\n\t" SETTINGS_KEYS_UINT64 "${SETTINGS_KEYS_UINT64}")
string(REPLACE ";" ",\n\t" SETTINGS_KEYS_STRING "${SETTINGS_KEYS_STRING}")
string(REPLACE ";" ",\n\t" SETTINGS_KEYS_POINTER "${SETTINGS_KEYS_POINTER}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/settings_keys.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/settings_keys.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/settings_keys.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/settings_keys.h)
file(GLOB_RECURSE PUBLIC_COMMON_HEADERS
LIST_DIRECTORIES false

View File

@ -227,7 +227,7 @@ if(WITH_SMARTCARD_EMULATE)
list(APPEND FREERDP_PC_PRIVATE_LIBS "-lz")
endif()
list(JOIN FREERDP_PC_PRIVATE_LIBS " " FREERDP_PC_PRIVATE_LIBS)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
## cmake project

View File

@ -72,7 +72,7 @@ if (WITH_OPENCL)
file_to_hex_array(${FILENAME} FILEDATA)
set(HDR_FILE "${CMAKE_CURRENT_BINARY_DIR}/opencl/primitives-opencl-program.h")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opencl/primitives.h.in" ${HDR_FILE} @ONLY)
cleaning_configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opencl/primitives.h.in" ${HDR_FILE} @ONLY)
list(APPEND PRIMITIVES_OPENCL_SRCS ${HDR_FILE})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/opencl)

View File

@ -28,13 +28,13 @@ ENDFOREACH()
include(pkg-config-install-prefix)
string(REPLACE ";" " " RDTK_BUILD_CONFIG "${RDTK_BUILD_CONFIG_LIST}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/version.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/buildflags.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/build-config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/config.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/version.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/buildflags.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/build-config.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/rdtk/config.h)
if (NOT RDTK_FORCE_STATIC_BUILD)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rdtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rdtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/rdtk${RDTK_VERSION_MAJOR}.pc @ONLY)
set(RDTK_INSTALL_INCLUDE_DIR ${RDTK_INCLUDE_DIR}/rdtk)
install(FILES

View File

@ -73,7 +73,7 @@ foreach(FREERDP_SERVER ${FREERDP_EXTRA_SERVERS})
endforeach()
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-server${FREERDP_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-server${FREERDP_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-server${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
export(PACKAGE freerdp-server)

View File

@ -71,7 +71,7 @@ set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Proxy")
# pkg-config
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-proxy.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-proxy.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
export(PACKAGE freerdp-proxy)

View File

@ -143,7 +143,7 @@ install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ser
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/shadow")
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-shadow.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-shadow.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc @ONLY)
generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${FREERDP_API_VERSION}")

View File

@ -33,14 +33,14 @@ FOREACH(var ${res})
ENDIF()
ENDFOREACH()
string(REPLACE ";" " " UWAC_BUILD_CONFIG "${UWAC_BUILD_CONFIG_LIST}")
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/version.h)
configure_file(buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/buildflags.h)
configure_file(build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/build-config.h)
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/config.h)
cleaning_configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/version.h)
cleaning_configure_file(buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/buildflags.h)
cleaning_configure_file(build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/build-config.h)
cleaning_configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/config.h)
if (NOT UWAC_FORCE_STATIC_BUILD)
include(pkg-config-install-prefix)
configure_file(uwac.pc.in ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(uwac.pc.in ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc @ONLY)
set(UWAC_INSTALL_INCLUDE_DIR ${UWAC_INCLUDE_DIR}/uwac)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/uwac${UWAC_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})

View File

@ -355,5 +355,5 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/WinPRConfig.cmake ${CMAKE_CURRENT_BINA
install(EXPORT WinPRTargets DESTINATION ${WINPR_CMAKE_INSTALL_DIR})
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})

View File

@ -15,11 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
configure_file(config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/version.h)
configure_file(config/wtypes.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/wtypes.h)
configure_file(config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/build-config.h)
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)
cleaning_configure_file(config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/version.h)
cleaning_configure_file(config/wtypes.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/wtypes.h)
cleaning_configure_file(config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/build-config.h)
cleaning_configure_file(config/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/buildflags.h)
cleaning_configure_file(config/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/config.h)
file(GLOB_RECURSE WINPR_PUBLIC_COMMON_HEADERS
LIST_DIRECTORIES false

View File

@ -103,7 +103,7 @@ add_subdirectory(makecert-cli)
add_subdirectory(hash-cli)
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr-tools.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr-tools${WINPR_TOOLS_VERSION_MAJOR}.pc @ONLY)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr-tools.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr-tools${WINPR_TOOLS_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr-tools${WINPR_TOOLS_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR})
export(PACKAGE ${MODULE_NAME})