--- CMakeLists.txt.orig 2023-12-23 01:33:41 +++ CMakeLists.txt 2023-12-29 23:44:53 @@ -373,34 +373,41 @@ endif() # JPEGXL_ENABLE_DOXYGEN if(JPEGXL_ENABLE_MANPAGES) - find_program(ASCIIDOC a2x) if(ASCIIDOC) - file(STRINGS "${ASCIIDOC}" ASCIIDOC_SHEBANG LIMIT_COUNT 1) - if(ASCIIDOC_SHEBANG MATCHES "sh$" OR MINGW) - set(ASCIIDOC_PY_FOUND ON) - # Run the program directly and set ASCIIDOC as empty. - set(ASCIIDOC_PY "${ASCIIDOC}") - set(ASCIIDOC "") - elseif(ASCIIDOC_SHEBANG MATCHES "python2") - find_package(Python2 COMPONENTS Interpreter) - set(ASCIIDOC_PY_FOUND "${Python2_Interpreter_FOUND}") - set(ASCIIDOC_PY Python2::Interpreter) - elseif(ASCIIDOC_SHEBANG MATCHES "python3") - find_package(Python3 COMPONENTS Interpreter) - set(ASCIIDOC_PY_FOUND "${Python3_Interpreter_FOUND}") - set(ASCIIDOC_PY Python3::Interpreter) - else() - find_package(Python COMPONENTS Interpreter QUIET) - if(NOT Python_Interpreter_FOUND) - find_program(ASCIIDOC_PY python) - if(ASCIIDOC_PY) - set(ASCIIDOC_PY_FOUND ON) - endif() + set(ASCIIDOC_PY_FOUND ON) + set(ASCIIDOC_PY "${ASCIIDOC}") + set(ASCIIDOC "") + else() + find_program(ASCIIDOC a2x) + if(ASCIIDOC) + file(STRINGS "${ASCIIDOC}" ASCIIDOC_SHEBANG LIMIT_COUNT 1) + if(ASCIIDOC_SHEBANG MATCHES "/sh|/bash" OR MINGW) + set(ASCIIDOC_PY_FOUND ON) + # Run the program directly and set ASCIIDOC as empty. + set(ASCIIDOC_PY "${ASCIIDOC}") + set(ASCIIDOC "") + elseif(ASCIIDOC_SHEBANG MATCHES "python2") + find_package(Python2 COMPONENTS Interpreter) + set(ASCIIDOC_PY_FOUND "${Python2_Interpreter_FOUND}") + set(ASCIIDOC_PY Python2::Interpreter) + elseif(ASCIIDOC_SHEBANG MATCHES "python3") + find_package(Python3 COMPONENTS Interpreter) + set(ASCIIDOC_PY_FOUND "${Python3_Interpreter_FOUND}") + set(ASCIIDOC_PY Python3::Interpreter) else() - set(ASCIIDOC_PY_FOUND "${Python_Interpreter_FOUND}") - set(ASCIIDOC_PY Python::Interpreter) - endif() - endif() + find_package(Python COMPONENTS Interpreter QUIET) + if(NOT Python_Interpreter_FOUND) + find_program(ASCIIDOC_PY python) + if(ASCIIDOC_PY) + set(ASCIIDOC_PY_FOUND ON) + endif() + else() + set(ASCIIDOC_PY_FOUND "${Python_Interpreter_FOUND}") + set(ASCIIDOC_PY Python::Interpreter) + endif() + endif() # ASCIIDOC_SHEBANG + endif() # ASCIIDOC + endif() # ASCIIDOC if (ASCIIDOC_PY_FOUND) set(MANPAGE_FILES "") @@ -422,9 +429,6 @@ add_custom_target(manpages ALL DEPENDS ${MANPAGES}) install(FILES ${MANPAGE_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endif() # ASCIIDOC_PY_FOUND - else() - message(WARNING "asciidoc was not found, the man pages will not be installed.") - endif() # ASCIIDOC endif() # JPEGXL_ENABLE_MANPAGES # Example usage code.