Submitted By:            Douglas R. Reno <renodr at linuxfromscratch dot org>
Date:                    2025-04-02
Initial Package Version: 5.8.0
Upstream Status:         Submitted
Origin:                  Self
Description:             Fixes building tidy-html5 5.8.0 with CMake 4.0. CMake
                         4.0 removes a lot of deprecated syntax from previous
                         versions, and is no longer compatible with files
                         designed to work with versions lower than 3.5. To fix
                         this, I updated the minimum required to include any
                         version up to 4.0 (similar to what other projects
                         have done), and then adjusted the custom commands for
                         manual pages to use the correct syntax.
                         Submitted upstream as:
                         https://github.com/htacg/tidy-html5/pull/1140
                         https://github.com/htacg/tidy-html5/issues/1139

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a01240e..20997e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@
 # @date    Consult git log.
 ##############################################################################
 
-cmake_minimum_required (VERSION 2.8.12)
+cmake_minimum_required (VERSION 2.8.12...4.0)
 
 set(LIB_NAME tidy)
 set(LIBTIDY_DESCRIPTION "${LIB_NAME} - HTML syntax checker")
@@ -528,6 +528,7 @@ if (UNIX AND SUPPORT_CONSOLE_APP)
  
         # Run the built EXE to generate xml output .
         add_custom_command(
+            POST_BUILD
             TARGET man
             COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-help > ${TIDYHELP}
             COMMENT "Generate ${TIDYHELP}"
@@ -536,6 +537,7 @@ if (UNIX AND SUPPORT_CONSOLE_APP)
 
         # Run the built EXE to generate more xml output.
         add_custom_command(
+            POST_BUILD
             TARGET man
             COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-config > ${TIDYCONFIG}
             COMMENT "Generate ${TIDYCONFIG}"
@@ -544,8 +546,8 @@ if (UNIX AND SUPPORT_CONSOLE_APP)
 
         # Run xsltproc to generate the install files.
         add_custom_command(
+            POST_BUILD
             TARGET man
-            DEPENDS ${TIDYHELP}
             COMMAND xsltproc ARGS ${TIDY1XSL} ${TIDYHELP} > ${CMAKE_CURRENT_BINARY_DIR}/${TIDY_MANFILE}
             COMMENT "Generate ${TIDY_MANFILE}"
             VERBATIM
