Warning, /frameworks/kdoctools/cmake/FindDocBookXML4.cmake is written in an unsupported language. File is not indexed.

0001 # Try to find DocBook XML 4.x DTD.
0002 # By default it will find version 4.5. A different version can be specified
0003 # as parameter for find_package().
0004 # Once done, it will define:
0005 #
0006 #  DocBookXML4_FOUND - system has the requested DocBook4 XML DTDs
0007 #  DocBookXML4_DTD_VERSION - the version of requested DocBook4
0008 #     XML DTD
0009 #  DocBookXML4_DTD_DIR - the directory containing the definition of
0010 #     the DocBook4 XML
0011 
0012 # SPDX-FileCopyrightText: 2010, 2014 Luigi Toscano <luigi.toscano@tiscali.it>
0013 #
0014 # SPDX-License-Identifier: BSD-3-Clause
0015 
0016 if (NOT DocBookXML_FIND_VERSION)
0017      set(DocBookXML_FIND_VERSION "4.5")
0018 endif ()
0019 
0020 set (DocBookXML4_DTD_VERSION ${DocBookXML_FIND_VERSION}
0021      CACHE INTERNAL "Required version of DocBook4 XML DTDs")
0022 
0023 include(FeatureSummary)
0024 set_package_properties(DocBookXML4 PROPERTIES DESCRIPTION "DocBook XML 4"
0025                        URL "http://www.oasis-open.org/docbook/xml/${DocBookXML4_DTD_VERSION}"
0026                       )
0027 
0028 function (locate_version version found_dir)
0029 
0030     set (DTD_PATH_LIST
0031         ${CMAKE_INSTALL_DATAROOTDIR}/xml/docbook/schema/dtd/${version}
0032         ${CMAKE_INSTALL_DATAROOTDIR}/xml/docbook/xml-dtd-${version}
0033         ${CMAKE_INSTALL_DATAROOTDIR}/sgml/docbook/xml-dtd-${version}
0034         ${CMAKE_INSTALL_DATAROOTDIR}/xml/docbook/${version}
0035         # for building on Mac with docbook installed by homebrew
0036         opt/docbook/docbook/xml/${version}
0037         # for building with Nix package manager
0038         xml/dtd/docbook
0039     )
0040 
0041     find_path (searched_dir docbookx.dtd
0042         PATHS ${CMAKE_SYSTEM_PREFIX_PATH}
0043         PATH_SUFFIXES ${DTD_PATH_LIST}
0044     )
0045 
0046     if (NOT searched_dir)
0047         # hacks for systems that use the package version in the DTD dirs,
0048         # e.g. Fedora, OpenSolaris
0049         set (DTD_PATH_LIST)
0050         foreach (DTD_PREFIX_ITER ${CMAKE_SYSTEM_PREFIX_PATH})
0051             file(GLOB DTD_SUFFIX_ITER RELATIVE ${DTD_PREFIX_ITER}
0052                 ${DTD_PREFIX_ITER}/share/sgml/docbook/xml-dtd-${version}-*
0053             )
0054             if (DTD_SUFFIX_ITER)
0055                 list (APPEND DTD_PATH_LIST ${DTD_SUFFIX_ITER})
0056             endif ()
0057         endforeach ()
0058 
0059         find_path (searched_dir docbookx.dtd
0060             PATHS ${CMAKE_SYSTEM_PREFIX_PATH}
0061             PATH_SUFFIXES ${DTD_PATH_LIST}
0062         )
0063     endif ()
0064     if (searched_dir)
0065         set (${found_dir} ${searched_dir} PARENT_SCOPE)
0066     else()
0067         message(WARNING "${found_dir}: Could not find docbookx.dtd in ${CMAKE_SYSTEM_PREFIX_PATH} with suffixes ${DTD_PATH_LIST}")
0068     endif()
0069 endfunction()
0070 
0071 
0072 locate_version (${DocBookXML4_DTD_VERSION} DocBookXML4_DTD_DIR)
0073 
0074 include(FindPackageHandleStandardArgs)
0075 find_package_handle_standard_args (DocBookXML4
0076     REQUIRED_VARS DocBookXML4_DTD_DIR DocBookXML4_DTD_VERSION
0077     FOUND_VAR DocBookXML4_FOUND)
0078 
0079 mark_as_advanced (DocBookXML4_DTD_DIR DocBookXML4_DTD_VERSION)