• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This file is copyrighted under the BSD-license for buildsystem files of KDE
2# copyright 2010, Patrick Spendrin <ps_ml@gmx.de>
3
4cmake_minimum_required(VERSION 3.1.3)
5
6project(expat
7    VERSION
8        2.2.9
9    LANGUAGES
10        C
11)
12
13set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org")
14set(PACKAGE_NAME "expat")
15set(PACKAGE_VERSION "${PROJECT_VERSION}")
16set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
17set(PACKAGE_TARNAME "${PACKAGE_NAME}")
18
19include(CMakePackageConfigHelpers)
20include(GNUInstallDirs)
21
22#
23# Configuration defaults
24#
25if(WINCE)
26    set(_EXPAT_BUILD_TOOLS_DEFAULT OFF)
27else()
28    set(_EXPAT_BUILD_TOOLS_DEFAULT ON)
29endif()
30if(MSVC OR NOT _EXPAT_BUILD_TOOLS_DEFAULT)
31    set(_EXPAT_BUILD_DOCS_DEFAULT OFF)
32else()
33    find_program(DOCBOOK_TO_MAN NAMES docbook2x-man db2x_docbook2man docbook2man docbook-to-man)
34    if(DOCBOOK_TO_MAN)
35        set(_EXPAT_BUILD_DOCS_DEFAULT ON)
36    else()
37        set(_EXPAT_BUILD_DOCS_DEFAULT OFF)
38    endif()
39endif()
40
41#
42# Configuration
43#
44option(EXPAT_BUILD_TOOLS "build the xmlwf tool for expat library" ${_EXPAT_BUILD_TOOLS_DEFAULT})
45option(EXPAT_BUILD_EXAMPLES "build the examples for expat library" ON)
46option(EXPAT_BUILD_TESTS "build the tests for expat library" ON)
47option(EXPAT_SHARED_LIBS "build a shared expat library" ON)
48option(EXPAT_BUILD_DOCS "build man page for xmlwf" ${_EXPAT_BUILD_DOCS_DEFAULT})
49option(EXPAT_BUILD_FUZZERS "build fuzzers for the expat library" OFF)
50option(EXPAT_WITH_LIBBSD "utilize libbsd (for arc4random_buf)" OFF)
51option(EXPAT_ENABLE_INSTALL "install expat files in cmake install target" ON)
52set(EXPAT_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point")
53mark_as_advanced(EXPAT_CONTEXT_BYTES)
54option(EXPAT_DTD "Define to make parameter entity parsing functionality available" ON)
55mark_as_advanced(EXPAT_DTD)
56option(EXPAT_NS "Define to make XML Namespaces functionality available" ON)
57mark_as_advanced(EXPAT_NS)
58option(EXPAT_WARNINGS_AS_ERRORS "Treat all compiler warnings as errors" OFF)
59if(NOT WIN32 OR _EXPAT_HELP)
60    option(EXPAT_DEV_URANDOM "Define to include code reading entropy from `/dev/urandom'." ON)
61    set(EXPAT_WITH_GETRANDOM "AUTO" CACHE STRING
62            "Make use of getrandom function (ON|OFF|AUTO) [default=AUTO]")
63    set(EXPAT_WITH_SYS_GETRANDOM "AUTO" CACHE STRING
64            "Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO]")
65    mark_as_advanced(EXPAT_DEV_URANDOM)
66endif()
67set(EXPAT_CHAR_TYPE "char" CACHE STRING "Character type to use (char|ushort|wchar_t) [default=char]")
68option(EXPAT_ATTR_INFO "Define to allow retrieving the byte offsets for attribute names and values" OFF)
69mark_as_advanced(EXPAT_ATTR_INFO)
70option(EXPAT_LARGE_SIZE "Make XML_GetCurrent* functions return <(unsigned) long long> rather than <(unsigned) long>" OFF)
71mark_as_advanced(EXPAT_LARGE_SIZE)
72option(EXPAT_MIN_SIZE "Get a smaller (but slower) parser (in particular avoid multiple copies of the tokenizer)" OFF)
73mark_as_advanced(EXPAT_MIN_SIZE)
74if(MSVC OR _EXPAT_HELP)
75    set(EXPAT_MSVC_STATIC_CRT OFF CACHE BOOL "Use /MT flag (static CRT) when compiling in MSVC")
76endif()
77
78#
79# Environment checks
80#
81if(EXPAT_WITH_LIBBSD)
82    find_library(LIB_BSD NAMES bsd)
83    if(NOT LIB_BSD)
84        message(SEND_ERROR "EXPAT_WITH_LIBBSD option is enabled, but libbsd was not found")
85    else()
86        set(HAVE_LIBBSD TRUE)
87    endif()
88endif()
89
90macro(_expat_copy_bool_int source_ref dest_ref)
91    if(${source_ref})
92        set(${dest_ref} 1)
93    else()
94        set(${dest_ref} 0)
95    endif()
96endmacro()
97
98if(EXPAT_LARGE_SIZE)
99    add_definitions(-DXML_LARGE_SIZE)
100endif()
101
102if(EXPAT_MIN_SIZE)
103    add_definitions(-DXML_MIN_SIZE)
104endif()
105
106if(EXPAT_CHAR_TYPE STREQUAL "char")
107    set(_EXPAT_UNICODE OFF)
108    set(_EXPAT_UNICODE_WCHAR_T OFF)
109elseif(EXPAT_CHAR_TYPE STREQUAL "ushort")
110    set(_EXPAT_UNICODE ON)
111    set(_EXPAT_UNICODE_WCHAR_T OFF)
112    if(EXPAT_BUILD_TOOLS)
113        message(SEND_ERROR "The xmlwf tool can not be built with option -DEXPAT_CHAR_TYPE=ushort. Please pass -DEXPAT_CHAR_TYPE=(char|wchar_t) or -DEXPAT_BUILD_TOOLS=OFF.")
114    endif()
115elseif(EXPAT_CHAR_TYPE STREQUAL "wchar_t")
116    set(_EXPAT_UNICODE ON)
117    set(_EXPAT_UNICODE_WCHAR_T ON)
118else()
119    message(SEND_ERROR "Option -DEXPAT_CHAR_TYPE=(char|ushort|wchar_t) cannot be \"${EXPAT_CHAR_TYPE}\".")
120endif()
121
122if(_EXPAT_UNICODE)
123    add_definitions(-DXML_UNICODE)              # for unsigned short
124    if(_EXPAT_UNICODE_WCHAR_T)
125        add_definitions(-DXML_UNICODE_WCHAR_T)  # for wchar_t
126    endif()
127endif()
128
129include(${CMAKE_CURRENT_LIST_DIR}/ConfigureChecks.cmake)
130
131macro(evaluate_detection_results use_ref have_ref thing_lower thing_title)
132    if(${use_ref} AND NOT (${use_ref} STREQUAL "AUTO") AND NOT ${have_ref})
133        message(SEND_ERROR
134                "Use of ${thing_lower} was enforced by ${use_ref}=ON but it could not be found.")
135    elseif(NOT ${use_ref} AND ${have_ref})
136        message("${thing_title} was found but it will not be used due to ${use_ref}=OFF.")
137        set(${have_ref} 0)
138    endif()
139endmacro()
140
141if(NOT WIN32)
142    evaluate_detection_results(EXPAT_WITH_GETRANDOM HAVE_GETRANDOM "function getrandom" "Function getrandom")
143    evaluate_detection_results(EXPAT_WITH_SYS_GETRANDOM HAVE_SYSCALL_GETRANDOM "syscall SYS_getrandom" "Syscall SYS_getrandom")
144endif()
145
146_expat_copy_bool_int(EXPAT_ATTR_INFO        XML_ATTR_INFO)
147_expat_copy_bool_int(EXPAT_DTD              XML_DTD)
148_expat_copy_bool_int(EXPAT_LARGE_SIZE       XML_LARGE_SIZE)
149_expat_copy_bool_int(EXPAT_MIN_SIZE         XML_MIN_SIZE)
150_expat_copy_bool_int(EXPAT_NS               XML_NS)
151if(NOT WIN32)
152    _expat_copy_bool_int(EXPAT_DEV_URANDOM  XML_DEV_URANDOM)
153endif()
154set(XML_CONTEXT_BYTES ${EXPAT_CONTEXT_BYTES})
155
156macro(expat_install)
157    if(EXPAT_ENABLE_INSTALL)
158        install(${ARGN})
159    endif()
160endmacro()
161
162configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h")
163add_definitions(-DHAVE_EXPAT_CONFIG_H)
164expat_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
165
166
167set(EXTRA_COMPILE_FLAGS)
168if(FLAG_NO_STRICT_ALIASING)
169    set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fno-strict-aliasing")
170endif()
171if(FLAG_VISIBILITY)
172  add_definitions(-DXML_ENABLE_VISIBILITY=1)
173  set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fvisibility=hidden")
174endif(FLAG_VISIBILITY)
175if (EXPAT_WARNINGS_AS_ERRORS)
176    if(MSVC)
177        add_definitions(/WX)
178    else(MSVC)
179        set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -Werror")
180    endif(MSVC)
181endif(EXPAT_WARNINGS_AS_ERRORS)
182set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_COMPILE_FLAGS}")
183set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}")
184
185if (MSVC)
186    if (EXPAT_MSVC_STATIC_CRT)
187        message("-- Using static CRT ${EXPAT_MSVC_STATIC_CRT}")
188        foreach(flag_var
189                CMAKE_CXX_FLAGS_DEBUG
190                CMAKE_CXX_FLAGS_RELEASE
191                CMAKE_CXX_FLAGS_MINSIZEREL
192                CMAKE_CXX_FLAGS_RELWITHDEBINFO
193                CMAKE_C_FLAGS_DEBUG
194                CMAKE_C_FLAGS_RELEASE
195                CMAKE_C_FLAGS_MINSIZEREL
196                CMAKE_C_FLAGS_RELWITHDEBINFO
197                )
198            string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
199        endforeach()
200    endif()
201endif()
202
203include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
204if(MSVC)
205    add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996)
206endif(MSVC)
207if(WIN32)
208    if(_EXPAT_UNICODE_WCHAR_T)
209        set(_POSTFIX_WIDE "w")
210    endif()
211
212    if(MSVC AND NOT EXPAT_SHARED_LIBS)
213        if(EXPAT_MSVC_STATIC_CRT)
214            set(_POSTFIX_CRT "MT")
215        else()
216            set(_POSTFIX_CRT "MD")
217        endif()
218    endif()
219
220    foreach(postfix_var
221            CMAKE_DEBUG_POSTFIX
222            CMAKE_RELEASE_POSTFIX
223            CMAKE_MINSIZEREL_POSTFIX
224            CMAKE_RELWITHDEBINFO_POSTFIX
225            )
226        if(postfix_var STREQUAL "CMAKE_DEBUG_POSTFIX")
227            set(_POSTFIX_DEBUG "d")
228        else()
229            set(_POSTFIX_DEBUG "")
230        endif()
231
232        set(${postfix_var} "${_POSTFIX_WIDE}${_POSTFIX_DEBUG}${_POSTFIX_CRT}" CACHE STRING "Windows binary postfix, e.g. libexpat<postfix=[w][d][MD|MT]>.lib")
233    endforeach()
234endif(WIN32)
235
236#
237# C library
238#
239set(expat_SRCS
240    lib/xmlparse.c
241    lib/xmlrole.c
242    lib/xmltok.c
243# NOTE: ISO C forbids an empty translation unit
244#   lib/xmltok_impl.c
245#   lib/xmltok_ns.c
246)
247
248if(EXPAT_SHARED_LIBS)
249    set(_SHARED SHARED)
250    if(MSVC)
251        set(expat_SRCS ${expat_SRCS} lib/libexpat.def)
252    endif(MSVC)
253else(EXPAT_SHARED_LIBS)
254    set(_SHARED STATIC)
255    if(WIN32)
256        add_definitions(-DXML_STATIC)
257    endif(WIN32)
258endif(EXPAT_SHARED_LIBS)
259
260# Avoid colliding with Expat.dll of Perl's XML::Parser::Expat
261if(WIN32 AND NOT MINGW)
262    set(_EXPAT_TARGET libexpat)
263else()
264    set(_EXPAT_TARGET expat)
265endif()
266
267add_library(${_EXPAT_TARGET} ${_SHARED} ${expat_SRCS})
268if(EXPAT_WITH_LIBBSD)
269    target_link_libraries(${_EXPAT_TARGET} ${LIB_BSD})
270endif()
271
272set(LIBCURRENT 7)    # sync
273set(LIBREVISION 11)  # with
274set(LIBAGE 6)        # configure.ac!
275math(EXPR LIBCURRENT_MINUS_AGE "${LIBCURRENT} - ${LIBAGE}")
276
277if(NOT WIN32)
278    set_property(TARGET ${_EXPAT_TARGET} PROPERTY VERSION ${LIBCURRENT_MINUS_AGE}.${LIBAGE}.${LIBREVISION})
279    set_property(TARGET ${_EXPAT_TARGET} PROPERTY SOVERSION ${LIBCURRENT_MINUS_AGE})
280    set_property(TARGET ${_EXPAT_TARGET} PROPERTY NO_SONAME ${NO_SONAME})
281endif(NOT WIN32)
282
283expat_install(TARGETS ${_EXPAT_TARGET} EXPORT expat
284                      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
285                      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
286                      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
287
288expat_install(FILES lib/expat.h lib/expat_external.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
289
290#
291# pkg-config file
292#
293if(NOT MSVC)
294    set(prefix ${CMAKE_INSTALL_PREFIX})
295    set(exec_prefix "\${prefix}")
296    set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
297    set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
298    configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc @ONLY)
299    expat_install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
300endif()
301
302#
303# C command line tool xmlwf
304#
305if(EXPAT_BUILD_TOOLS)
306    set(xmlwf_SRCS
307        xmlwf/xmlwf.c
308        xmlwf/xmlfile.c
309        xmlwf/codepage.c
310        xmlwf/readfilemap.c
311    )
312
313    add_executable(xmlwf ${xmlwf_SRCS})
314    set_property(TARGET xmlwf PROPERTY RUNTIME_OUTPUT_DIRECTORY xmlwf)
315    target_link_libraries(xmlwf ${_EXPAT_TARGET})
316    expat_install(TARGETS xmlwf DESTINATION ${CMAKE_INSTALL_BINDIR})
317
318    if(MINGW AND _EXPAT_UNICODE_WCHAR_T)
319        # https://gcc.gnu.org/onlinedocs/gcc/x86-Windows-Options.html
320        set_target_properties(xmlwf PROPERTIES LINK_FLAGS -municode)
321    endif()
322
323    if(EXPAT_BUILD_DOCS)
324        file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/doc)
325        add_custom_command(TARGET ${_EXPAT_TARGET} PRE_BUILD COMMAND "${DOCBOOK_TO_MAN}" "${PROJECT_SOURCE_DIR}/doc/xmlwf.xml" && mv "XMLWF.1" "${PROJECT_BINARY_DIR}/doc/xmlwf.1")
326        expat_install(FILES "${PROJECT_BINARY_DIR}/doc/xmlwf.1" DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
327    endif()
328endif()
329
330#
331# C code examples
332#
333if(EXPAT_BUILD_EXAMPLES)
334    add_executable(elements examples/elements.c)
335    set_property(TARGET elements PROPERTY RUNTIME_OUTPUT_DIRECTORY examples)
336    target_link_libraries(elements ${_EXPAT_TARGET})
337
338    add_executable(outline examples/outline.c)
339    set_property(TARGET outline PROPERTY RUNTIME_OUTPUT_DIRECTORY examples)
340    target_link_libraries(outline ${_EXPAT_TARGET})
341endif(EXPAT_BUILD_EXAMPLES)
342
343#
344# C/C++ test runners
345#
346if(EXPAT_BUILD_TESTS)
347    ## these are unittests that can be run on any platform
348    enable_language(CXX)
349    enable_testing()
350
351    set(test_SRCS
352        tests/chardata.c
353        tests/memcheck.c
354        tests/minicheck.c
355        tests/structdata.c
356    )
357
358    if(NOT MSVC)
359        if(MINGW)
360            set(host whatever-mingw32)  # for nothing but run.sh
361        endif()
362        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run.sh.in run.sh @ONLY)
363    endif()
364
365    function(expat_add_test _name _file)
366        if(MSVC)
367            add_test(NAME ${_name} COMMAND ${_file})
368        else()
369            add_test(NAME ${_name} COMMAND bash run.sh ${_file})
370        endif()
371    endfunction()
372
373    add_executable(runtests tests/runtests.c ${test_SRCS})
374    set_property(TARGET runtests PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
375    target_link_libraries(runtests ${_EXPAT_TARGET})
376    expat_add_test(runtests $<TARGET_FILE:runtests>)
377
378    add_executable(runtestspp tests/runtestspp.cpp ${test_SRCS})
379    set_property(TARGET runtestspp PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
380    target_link_libraries(runtestspp ${_EXPAT_TARGET})
381    expat_add_test(runtestspp $<TARGET_FILE:runtestspp>)
382endif(EXPAT_BUILD_TESTS)
383
384if(EXPAT_BUILD_FUZZERS)
385    if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
386        message(SEND_ERROR
387            "Building fuzz targets without Clang (but ${CMAKE_C_COMPILER_ID}) "
388            "is not supported. Please set "
389            "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++.")
390    endif()
391
392    string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "-fsanitize" sanitizer_present)
393    if(${sanitizer_present} EQUAL "-1")
394        message(WARNING
395            "There was no sanitizer present when building the fuzz targets. "
396            "This is likely in error - consider adding "
397            "-DCMAKE_C_FLAGS='-fsanitize=<sanitizer>' and "
398            "-DCMAKE_CXX_FLAGS='-fsanitize=<sanitizer>' and "
399            "-DCMAKE_STATIC_LINKER_FLAGS='-fsanitize=<sanitizer>' and "
400            "-DCMAKE_EXE_LINKER_FLAGS='-fsanitize=<sanitizer>' to your cmake "
401            "execution.")
402    endif()
403
404    set(encoding_types UTF-16 UTF-8 ISO-8859-1 US-ASCII UTF-16BE UTF-16LE)
405    set(fuzz_targets xml_parse_fuzzer xml_parsebuffer_fuzzer)
406
407    add_library(fuzzpat STATIC ${expat_SRCS})
408    target_compile_options(fuzzpat PRIVATE -fsanitize=fuzzer-no-link)
409
410    foreach(fuzz_target ${fuzz_targets})
411        foreach(encoding_type ${encoding_types})
412            set(target_name ${fuzz_target}_${encoding_type})
413            add_executable(${target_name} fuzz/${fuzz_target}.c)
414            target_link_libraries(${target_name} fuzzpat)
415            target_compile_definitions(${target_name}
416                PRIVATE ENCODING_FOR_FUZZING=${encoding_type})
417            target_compile_options(${target_name} PRIVATE -fsanitize=fuzzer-no-link)
418            # NOTE: Avoiding target_link_options here only because it needs CMake >=3.13
419            set_target_properties(${target_name} PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
420            set_property(
421                TARGET ${target_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY fuzz)
422        endforeach()
423    endforeach()
424endif(EXPAT_BUILD_FUZZERS)
425
426#
427# Custom target "run-xmltest"
428#
429if(EXPAT_BUILD_TOOLS AND NOT MSVC)
430    add_custom_target(
431        xmlts-zip-downloaded
432        COMMAND
433            sh -c 'test -f xmlts.zip || wget --output-document=xmlts.zip https://www.w3.org/XML/Test/xmlts20080827.zip'
434        BYPRODUCTS
435            tests/xmlts.zip
436        WORKING_DIRECTORY
437            tests/)
438
439    add_custom_target(
440        xmlts-zip-extracted
441        COMMAND
442            sh -c 'test -d xmlconf || unzip -q xmlts.zip'
443        BYPRODUCTS
444            tests/xmlconf
445        WORKING_DIRECTORY
446            tests/)
447    add_dependencies(xmlts-zip-extracted xmlts-zip-downloaded)
448
449    add_custom_target(
450        xmltest-sh-been-run
451        COMMAND
452            sh -c '${CMAKE_CURRENT_SOURCE_DIR}/tests/xmltest.sh "bash ${CMAKE_CURRENT_BINARY_DIR}/run.sh $<TARGET_FILE:xmlwf>" 2>&1 | tee tests/xmltest.log'
453        BYPRODUCTS
454            tests/xmltest.log)
455    add_dependencies(xmltest-sh-been-run xmlts-zip-extracted xmlwf)
456
457    add_custom_target(
458        xmltest-log-fixed
459        COMMAND
460            ${CMAKE_CURRENT_SOURCE_DIR}/fix-xmltest-log.sh tests/xmltest.log
461        DEPENDS
462            tests/xmltest.log)
463    add_dependencies(xmltest-log-fixed xmltest-sh-been-run)
464
465    add_custom_target(
466        xmltest-log-verified
467        COMMAND
468            diff -u ${CMAKE_CURRENT_SOURCE_DIR}/tests/xmltest.log.expected tests/xmltest.log)
469    add_dependencies(xmltest-log-verified xmltest-log-fixed)
470
471    add_custom_target(run-xmltest)
472    add_dependencies(run-xmltest xmltest-log-verified)
473endif()
474
475#
476# Documentation
477#
478configure_file(Changes changelog COPYONLY)
479expat_install(
480    FILES
481        AUTHORS
482        ${CMAKE_CURRENT_BINARY_DIR}/changelog
483    DESTINATION
484        ${CMAKE_INSTALL_DOCDIR})
485
486#
487# CMake files for find_package(expat [..] CONFIG [..])
488#
489configure_package_config_file(
490        cmake/expat-config.cmake.in
491        cmake/expat-config.cmake
492    INSTALL_DESTINATION
493        ${CMAKE_INSTALL_LIBDIR}/cmake/expat-${PROJECT_VERSION}/
494)
495write_basic_package_version_file(
496    cmake/expat-config-version.cmake
497    COMPATIBILITY SameMajorVersion  # i.e. semver
498)
499export(
500    TARGETS
501        ${_EXPAT_TARGET}
502    FILE
503        cmake/expat-targets.cmake  # not going to be installed
504)
505expat_install(
506    FILES
507        ${CMAKE_CURRENT_BINARY_DIR}/cmake/expat-config.cmake
508        ${CMAKE_CURRENT_BINARY_DIR}/cmake/expat-config-version.cmake
509    DESTINATION
510        ${CMAKE_INSTALL_LIBDIR}/cmake/expat-${PROJECT_VERSION}/
511)
512expat_install(
513    EXPORT
514        expat
515    DESTINATION
516        ${CMAKE_INSTALL_LIBDIR}/cmake/expat-${PROJECT_VERSION}/
517    NAMESPACE
518        expat::
519)
520
521#
522# Summary
523#
524if(EXPAT_CHAR_TYPE STREQUAL "char")
525    set(_EXPAT_CHAR_TYPE_SUMMARY "char (UTF-8)")
526elseif(EXPAT_CHAR_TYPE STREQUAL "ushort")
527    set(_EXPAT_CHAR_TYPE_SUMMARY "ushort (unsigned short, UTF-16)")
528elseif(EXPAT_CHAR_TYPE STREQUAL "wchar_t")
529    if(WIN32)
530        set(_EXPAT_CHAR_TYPE_SUMMARY "wchar_t (UTF-16)")
531    else()
532        set(_EXPAT_CHAR_TYPE_SUMMARY "wchar_t (UTF-32)  // not implemented")
533    endif()
534else()
535    set(_EXPAT_CHAR_TYPE_SUMMARY "ERROR")
536endif()
537string(TOUPPER "${CMAKE_BUILD_TYPE}" _EXPAT_BUILD_TYPE_UPPER)
538
539message(STATUS "===========================================================================")
540message(STATUS "")
541message(STATUS "Configuration")
542message(STATUS "  Prefix ..................... ${CMAKE_INSTALL_PREFIX}")
543message(STATUS "  Build type ................. ${CMAKE_BUILD_TYPE}")
544message(STATUS "  Shared libraries ........... ${EXPAT_SHARED_LIBS}")
545if(MSVC)
546    message(STATUS "  Static CRT ................. ${EXPAT_MSVC_STATIC_CRT}")
547endif()
548message(STATUS "  Character type ............. ${_EXPAT_CHAR_TYPE_SUMMARY}")
549if(WIN32)
550    message(STATUS "  Binary postfix ............. ${CMAKE_${_EXPAT_BUILD_TYPE_UPPER}_POSTFIX}")
551endif()
552message(STATUS "")
553message(STATUS "  Build documentation ........ ${EXPAT_BUILD_DOCS}")
554message(STATUS "  Build examples ............. ${EXPAT_BUILD_EXAMPLES}")
555message(STATUS "  Build fuzzers .............. ${EXPAT_BUILD_FUZZERS}")
556message(STATUS "  Build tests ................ ${EXPAT_BUILD_TESTS}")
557message(STATUS "  Build tools (xmlwf) ........ ${EXPAT_BUILD_TOOLS}")
558message(STATUS "  Install files .............. ${EXPAT_ENABLE_INSTALL}")
559message(STATUS "")
560message(STATUS "  Features")
561message(STATUS "    // Advanced options, changes not advised")
562message(STATUS "    Attributes info .......... ${EXPAT_ATTR_INFO}")
563message(STATUS "    Context bytes ............ ${EXPAT_CONTEXT_BYTES}")
564message(STATUS "    DTD support .............. ${EXPAT_DTD}")
565message(STATUS "    Large size ............... ${EXPAT_LARGE_SIZE}")
566message(STATUS "    Minimum size ............. ${EXPAT_MIN_SIZE}")
567message(STATUS "    Namespace support ........ ${EXPAT_NS}")
568message(STATUS "")
569message(STATUS "  Entropy sources")
570if(WIN32)
571    message(STATUS "    rand_s ................... ON")
572else()
573    message(STATUS "    getrandom ................ ${HAVE_GETRANDOM}")
574    message(STATUS "    syscall SYS_getrandom .... ${HAVE_SYSCALL_GETRANDOM}")
575    message(STATUS "    libbsd ................... ${EXPAT_WITH_LIBBSD}")
576    message(STATUS "    /dev/random .............. ${EXPAT_DEV_URANDOM}")
577endif()
578message(STATUS "")
579if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
580    message(STATUS "Continue with")
581    message(STATUS "  make")
582    if(EXPAT_BUILD_TESTS)
583        message(STATUS "  make test")
584    endif()
585    if(EXPAT_ENABLE_INSTALL)
586        message(STATUS "  sudo make install")
587    endif()
588    message(STATUS "")
589endif()
590message(STATUS "===========================================================================")
591