---
source: src/patch/parse.rs
expression: patches
input_file: src/patch/test-data/usecmake.patch
---
Ok(
    [
        Patch {
            original: Some(
                Filename(
                    "CMakeLists.txt",
                ),
            ),
            modified: Some(
                Filename(
                    "CMakeLists.txt",
                ),
            ),
            hunks: [
                Hunk {
                    old_range: HunkRange {
                        start: 0,
                        len: 0,
                    },
                    new_range: HunkRange {
                        start: 1,
                        len: 134,
                    },
                    function_context: None,
                    lines: [
                        Insert(
                            "# Copyright Mathieu Malaterre <malat@debian.org>\n",
                        ),
                        Insert(
                            "# BSD (Same as jxrlib)\n",
                        ),
                        Insert(
                            "cmake_minimum_required(VERSION 2.8)\n",
                        ),
                        Insert(
                            "project(jxrlib C)\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "# Need shared libs for ABI\n",
                        ),
                        Insert(
                            "set(BUILD_SHARED_LIBS ON)\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "# helper macro to preserve original Makefile convention\n",
                        ),
                        Insert(
                            "macro(JXR_MAKE_OBJ SET_NAME)\n",
                        ),
                        Insert(
                            "  foreach(src ${SRC_${SET_NAME}})\n",
                        ),
                        Insert(
                            "    list(APPEND OBJ_${SET_NAME} ${DIR_${SET_NAME}}/${src})\n",
                        ),
                        Insert(
                            "  endforeach()\n",
                        ),
                        Insert(
                            "endmacro()\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "include(TestBigEndian)\n",
                        ),
                        Insert(
                            "test_big_endian(ISBIGENDIAN)\n",
                        ),
                        Insert(
                            "if(ISBIGENDIAN)\n",
                        ),
                        Insert(
                            "  set(DEF_ENDIAN _BIG__ENDIAN_)\n",
                        ),
                        Insert(
                            "endif()\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "set(DIR_SYS image/sys)\n",
                        ),
                        Insert(
                            "set(DIR_DEC image/decode)\n",
                        ),
                        Insert(
                            "set(DIR_ENC image/encode)\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "set(DIR_GLUE jxrgluelib)\n",
                        ),
                        Insert(
                            "set(DIR_TEST jxrtestlib)\n",
                        ),
                        Insert(
                            "set(DIR_EXEC jxrencoderdecoder)\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "if(NOT JXRLIB_INSTALL_BIN_DIR)\n",
                        ),
                        Insert(
                            "  set(JXRLIB_INSTALL_BIN_DIR \"bin\")\n",
                        ),
                        Insert(
                            "endif()\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "if(NOT JXRLIB_INSTALL_LIB_DIR)\n",
                        ),
                        Insert(
                            "  set(JXRLIB_INSTALL_LIB_DIR \"lib\")\n",
                        ),
                        Insert(
                            "endif()\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "if(NOT JXRLIB_INSTALL_INCLUDE_DIR)\n",
                        ),
                        Insert(
                            "  set(JXRLIB_INSTALL_INCLUDE_DIR \"include/jxrlib\")\n",
                        ),
                        Insert(
                            "endif()\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "include_directories(\n",
                        ),
                        Insert(
                            "  common/include\n",
                        ),
                        Insert(
                            "  ${DIR_SYS}\n",
                        ),
                        Insert(
                            "  ${DIR_GLUE}\n",
                        ),
                        Insert(
                            "  ${DIR_TEST}\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "# where is strlcpy ?\n",
                        ),
                        Insert(
                            "include(CheckSymbolExists)\n",
                        ),
                        Insert(
                            "check_symbol_exists(strlcpy \"string.h\" HAVE_STRLCPY)\n",
                        ),
                        Insert(
                            "#set(CMAKE_REQUIRED_LIBRARIES bsd)\n",
                        ),
                        Insert(
                            "#CHECK_SYMBOL_EXISTS(strlcpy \"string.h\" HAVE_STRLCPY4)\n",
                        ),
                        Insert(
                            "# on linux, strlcpy is in -lbsd:\n",
                        ),
                        Insert(
                            "#if(NOT HAVE_STRLCPY)\n",
                        ),
                        Insert(
                            "#  include(CheckLibraryExists)\n",
                        ),
                        Insert(
                            "#  find_library(BSD_LIBRARY bsd)\n",
                        ),
                        Insert(
                            "#  check_library_exists(bsd \"strlcpy\" ${BSD_LIBRARY} HAVE_STRLCPY_BSD)\n",
                        ),
                        Insert(
                            "#endif()\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "# JPEG-XR\n",
                        ),
                        Insert(
                            "set(SRC_SYS adapthuff.c image.c strcodec.c strPredQuant.c strTransform.c perfTimerANSI.c)\n",
                        ),
                        Insert(
                            "JXR_MAKE_OBJ(SYS)\n",
                        ),
                        Insert(
                            "set(SRC_DEC decode.c postprocess.c segdec.c strdec.c strInvTransform.c strPredQuantDec.c JXRTranscode.c)\n",
                        ),
                        Insert(
                            "JXR_MAKE_OBJ(DEC)\n",
                        ),
                        Insert(
                            "set(SRC_ENC encode.c segenc.c strenc.c strFwdTransform.c strPredQuantEnc.c)\n",
                        ),
                        Insert(
                            "JXR_MAKE_OBJ(ENC)\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "add_library(jpegxr ${OBJ_ENC} ${OBJ_DEC} ${OBJ_SYS})\n",
                        ),
                        Insert(
                            "set_property(TARGET jpegxr\n",
                        ),
                        Insert(
                            "  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "set_property(TARGET jpegxr PROPERTY LINK_INTERFACE_LIBRARIES \"\")\n",
                        ),
                        Insert(
                            "set_property(TARGET jpegxr PROPERTY COMPILE_FLAGS -w)\n",
                        ),
                        Insert(
                            "# VERSION/SOVERSION\n",
                        ),
                        Insert(
                            "set_property(TARGET jpegxr PROPERTY VERSION 1.1)\n",
                        ),
                        Insert(
                            "set_property(TARGET jpegxr PROPERTY SOVERSION 0)\n",
                        ),
                        Insert(
                            "install(TARGETS jpegxr\n",
                        ),
                        Insert(
                            "  EXPORT JXRLibTargets\n",
                        ),
                        Insert(
                            "  RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR} COMPONENT Applications\n",
                        ),
                        Insert(
                            "  LIBRARY DESTINATION ${JXRLIB_INSTALL_LIB_DIR} COMPONENT Libraries\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "#\u{a0}JXR-GLUE\n",
                        ),
                        Insert(
                            "set(SRC_GLUE JXRGlue.c JXRMeta.c JXRGluePFC.c JXRGlueJxr.c)\n",
                        ),
                        Insert(
                            "JXR_MAKE_OBJ(GLUE)\n",
                        ),
                        Insert(
                            "set(SRC_TEST JXRTest.c JXRTestBmp.c JXRTestHdr.c JXRTestPnm.c JXRTestTif.c JXRTestYUV.c)\n",
                        ),
                        Insert(
                            "JXR_MAKE_OBJ(TEST)\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "add_library(jxrglue ${OBJ_GLUE} ${OBJ_TEST})\n",
                        ),
                        Insert(
                            "set_property(TARGET jxrglue\n",
                        ),
                        Insert(
                            "  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "set_property(TARGET jxrglue PROPERTY LINK_INTERFACE_LIBRARIES \"\")\n",
                        ),
                        Insert(
                            "set_property(TARGET jxrglue PROPERTY COMPILE_FLAGS -w)\n",
                        ),
                        Insert(
                            "# VERSION/SOVERSION\n",
                        ),
                        Insert(
                            "set_property(TARGET jxrglue PROPERTY VERSION 1.1)\n",
                        ),
                        Insert(
                            "set_property(TARGET jxrglue PROPERTY SOVERSION 0)\n",
                        ),
                        Insert(
                            "install(TARGETS jxrglue\n",
                        ),
                        Insert(
                            "  EXPORT JXRLibTargets\n",
                        ),
                        Insert(
                            "  RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR} COMPONENT Applications\n",
                        ),
                        Insert(
                            "  LIBRARY DESTINATION ${JXRLIB_INSTALL_LIB_DIR} COMPONENT Libraries\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "#if(HAVE_STRLCPY_BSD)\n",
                        ),
                        Insert(
                            "#\ttarget_link_libraries(jxrglue ${BSD_LIBRARY})\n",
                        ),
                        Insert(
                            "#endif()\n",
                        ),
                        Insert(
                            "target_link_libraries(jxrglue jpegxr m)\n",
                        ),
                        Insert(
                            "# Enc app files\n",
                        ),
                        Insert(
                            "set(ENCAPP JxrEncApp)\n",
                        ),
                        Insert(
                            "add_executable(${ENCAPP} ${DIR_EXEC}/${ENCAPP}.c)\n",
                        ),
                        Insert(
                            "set_property(TARGET ${ENCAPP}\n",
                        ),
                        Insert(
                            "  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "set_property(TARGET ${ENCAPP} PROPERTY COMPILE_FLAGS -w)\n",
                        ),
                        Insert(
                            "target_link_libraries(${ENCAPP} jxrglue) # jpegxr)\n",
                        ),
                        Insert(
                            "install(TARGETS ${ENCAPP} RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR})\n",
                        ),
                        Insert(
                            "# Dec app files\n",
                        ),
                        Insert(
                            "set(DECAPP JxrDecApp)\n",
                        ),
                        Insert(
                            "add_executable(${DECAPP} ${DIR_EXEC}/${DECAPP}.c)\n",
                        ),
                        Insert(
                            "set_property(TARGET ${DECAPP}\n",
                        ),
                        Insert(
                            "  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "set_property(TARGET ${DECAPP} PROPERTY COMPILE_FLAGS -w)\n",
                        ),
                        Insert(
                            "target_link_libraries(${DECAPP} jxrglue) # jpegxr)\n",
                        ),
                        Insert(
                            "install(TARGETS ${DECAPP} RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR})\n",
                        ),
                        Insert(
                            "\n",
                        ),
                        Insert(
                            "# install rules\n",
                        ),
                        Insert(
                            "install(FILES jxrgluelib/JXRGlue.h jxrgluelib/JXRMeta.h jxrtestlib/JXRTest.h\n",
                        ),
                        Insert(
                            "  image/sys/windowsmediaphoto.h\n",
                        ),
                        Insert(
                            "  DESTINATION ${JXRLIB_INSTALL_INCLUDE_DIR} COMPONENT Headers\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                        Insert(
                            "install(DIRECTORY common/include/ DESTINATION ${JXRLIB_INSTALL_INCLUDE_DIR}\n",
                        ),
                        Insert(
                            "  FILES_MATCHING PATTERN \"*.h\"\n",
                        ),
                        Insert(
                            ")\n",
                        ),
                    ],
                },
            ],
        },
    ],
)
