cmake: move modules into the "cmake/" top level dir Our custom CMake module currently live in "cmake/Modules". As the "cmake/" directory doesn't contain anything except the "Modules" directory, it doesn't really make sense to have the additional intermediate directory. So let's instead move the modules one level up into the "cmake/" top level directory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3819547..82def8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ IF(POLICY CMP0054)
ENDIF()
# Add find modules to the path
-SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
diff --git a/cmake/AddCFlagIfSupported.cmake b/cmake/AddCFlagIfSupported.cmake
new file mode 100644
index 0000000..b7aaa79
--- /dev/null
+++ b/cmake/AddCFlagIfSupported.cmake
@@ -0,0 +1,30 @@
+# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
+# ADD_C_FLAG_IF_SUPPORTED(<flag>)
+# <flag> - the compiler flag to test
+# This internally calls the CHECK_C_COMPILER_FLAG macro.
+
+INCLUDE(CheckCCompilerFlag)
+
+MACRO(ADD_C_FLAG _FLAG)
+ STRING(TOUPPER ${_FLAG} UPCASE)
+ STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
+ CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
+
+ IF(IS_${UPCASE_PRETTY}_SUPPORTED)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
+ ENDIF()
+ENDMACRO()
+
+MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
+ STRING(TOUPPER ${_FLAG} UPCASE)
+ STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
+ CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
+
+ IF(IS_${UPCASE_PRETTY}_SUPPORTED)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/CheckPrototypeDefinition.c.in b/cmake/CheckPrototypeDefinition.c.in
new file mode 100644
index 0000000..a97344a
--- /dev/null
+++ b/cmake/CheckPrototypeDefinition.c.in
@@ -0,0 +1,29 @@
+@CHECK_PROTOTYPE_DEFINITION_HEADER@
+
+static void cmakeRequireSymbol(int dummy, ...) {
+ (void) dummy;
+}
+
+static void checkSymbol(void) {
+#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
+ cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
+#endif
+}
+
+@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
+ return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
+}
+
+#ifdef __CLASSIC_C__
+int main() {
+ int ac;
+ char*av[];
+#else
+int main(int ac, char *av[]) {
+#endif
+ checkSymbol();
+ if (ac > 1000) {
+ return *av[0];
+ }
+ return 0;
+}
diff --git a/cmake/CheckPrototypeDefinition.cmake b/cmake/CheckPrototypeDefinition.cmake
new file mode 100644
index 0000000..244b9b5
--- /dev/null
+++ b/cmake/CheckPrototypeDefinition.cmake
@@ -0,0 +1,96 @@
+# - Check if the protoype we expect is correct.
+# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
+# FUNCTION - The name of the function (used to check if prototype exists)
+# PROTOTYPE- The prototype to check.
+# RETURN - The return value of the function.
+# HEADER - The header files required.
+# VARIABLE - The variable to store the result.
+# Example:
+# check_prototype_definition(getpwent_r
+# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
+# "NULL"
+# "unistd.h;pwd.h"
+# SOLARIS_GETPWENT_R)
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2010-2011 Andreas Schneider <asn@cryptomilk.org>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+#
+
+get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
+
+ if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+ set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
+
+ set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ if (CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_PROTOTYPE_DEFINITION_LIBS
+ "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+ else(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_PROTOTYPE_DEFINITION_LIBS)
+ endif(CMAKE_REQUIRED_LIBRARIES)
+ if (CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_SYMBOL_EXISTS_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_SYMBOL_EXISTS_INCLUDES)
+ endif(CMAKE_REQUIRED_INCLUDES)
+
+ foreach(_FILE ${_HEADER})
+ set(CHECK_PROTOTYPE_DEFINITION_HEADER
+ "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
+ endforeach(_FILE)
+
+ set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
+ set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
+ set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
+
+ configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in"
+ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
+
+ file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
+
+ try_compile(${_VARIABLE}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
+ "${CHECK_PROTOTYPE_DEFINITION_LIBS}"
+ "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ if (${_VARIABLE})
+ set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
+ "${OUTPUT}\n\n")
+ else (${_VARIABLE})
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+ set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
+ "${OUTPUT}\n\n${_SOURCE}\n\n")
+ endif (${_VARIABLE})
+ endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+
+endfunction(CHECK_PROTOTYPE_DEFINITION)
diff --git a/cmake/EnableWarnings.cmake b/cmake/EnableWarnings.cmake
new file mode 100644
index 0000000..b61ed7e
--- /dev/null
+++ b/cmake/EnableWarnings.cmake
@@ -0,0 +1,15 @@
+MACRO(ENABLE_WARNINGS flag)
+ ADD_C_FLAG_IF_SUPPORTED(-W${flag})
+ENDMACRO()
+
+MACRO(DISABLE_WARNINGS flag)
+ ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
+ENDMACRO()
+
+IF(ENABLE_WERROR)
+ IF(MSVC)
+ ADD_COMPILE_OPTIONS(-WX)
+ ELSE()
+ ADD_C_FLAG_IF_SUPPORTED(-Werror)
+ ENDIF()
+ENDIF()
diff --git a/cmake/FindCoreFoundation.cmake b/cmake/FindCoreFoundation.cmake
new file mode 100644
index 0000000..191aa59
--- /dev/null
+++ b/cmake/FindCoreFoundation.cmake
@@ -0,0 +1,26 @@
+# Find CoreFoundation.framework
+# This will define :
+#
+# COREFOUNDATION_FOUND
+# COREFOUNDATION_LIBRARIES
+# COREFOUNDATION_LDFLAGS
+#
+
+FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
+FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
+IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
+ IF (NOT CoreFoundation_FIND_QUIETLY)
+ MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
+ ENDIF()
+ SET(COREFOUNDATION_FOUND TRUE)
+ SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
+ENDIF ()
+
+IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
+ MESSAGE(FATAL_ERROR "CoreFoundation not found")
+ENDIF()
+
+MARK_AS_ADVANCED(
+ COREFOUNDATION_INCLUDE_DIR
+ COREFOUNDATION_LIBRARIES
+)
diff --git a/cmake/FindGSSAPI.cmake b/cmake/FindGSSAPI.cmake
new file mode 100644
index 0000000..37357c4
--- /dev/null
+++ b/cmake/FindGSSAPI.cmake
@@ -0,0 +1,324 @@
+# - Try to find GSSAPI
+# Once done this will define
+#
+# KRB5_CONFIG - Path to krb5-config
+# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
+#
+# Read-Only variables:
+# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
+# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
+# GSSAPI_FOUND - system has GSSAPI
+# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
+# GSSAPI_LIBRARIES - Link these to use GSSAPI
+# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
+#
+#=============================================================================
+# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+#
+
+find_path(GSSAPI_ROOT_DIR
+ NAMES
+ include/gssapi.h
+ include/gssapi/gssapi.h
+ HINTS
+ ${_GSSAPI_ROOT_HINTS}
+ PATHS
+ ${_GSSAPI_ROOT_PATHS}
+)
+mark_as_advanced(GSSAPI_ROOT_DIR)
+
+if (UNIX)
+ find_program(KRB5_CONFIG
+ NAMES
+ krb5-config
+ PATHS
+ ${GSSAPI_ROOT_DIR}/bin
+ /opt/local/bin)
+ mark_as_advanced(KRB5_CONFIG)
+
+ if (KRB5_CONFIG)
+ # Check if we have MIT KRB5
+ execute_process(
+ COMMAND
+ ${KRB5_CONFIG} --vendor
+ RESULT_VARIABLE
+ _GSSAPI_VENDOR_RESULT
+ OUTPUT_VARIABLE
+ _GSSAPI_VENDOR_STRING)
+
+ if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
+ set(GSSAPI_FLAVOR_MIT TRUE)
+ else()
+ execute_process(
+ COMMAND
+ ${KRB5_CONFIG} --libs gssapi
+ RESULT_VARIABLE
+ _GSSAPI_LIBS_RESULT
+ OUTPUT_VARIABLE
+ _GSSAPI_LIBS_STRING)
+
+ if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
+ set(GSSAPI_FLAVOR_HEIMDAL TRUE)
+ endif()
+ endif()
+
+ # Get the include dir
+ execute_process(
+ COMMAND
+ ${KRB5_CONFIG} --cflags gssapi
+ RESULT_VARIABLE
+ _GSSAPI_INCLUDE_RESULT
+ OUTPUT_VARIABLE
+ _GSSAPI_INCLUDE_STRING)
+ string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
+ string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
+ endif()
+
+ if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
+ # Check for HEIMDAL
+ find_package(PkgConfig)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(_GSSAPI heimdal-gssapi)
+ endif (PKG_CONFIG_FOUND)
+
+ if (_GSSAPI_FOUND)
+ set(GSSAPI_FLAVOR_HEIMDAL TRUE)
+ else()
+ find_path(_GSSAPI_ROKEN
+ NAMES
+ roken.h
+ PATHS
+ ${GSSAPI_ROOT_DIR}/include
+ ${_GSSAPI_INCLUDEDIR})
+ if (_GSSAPI_ROKEN)
+ set(GSSAPI_FLAVOR_HEIMDAL TRUE)
+ endif()
+ endif ()
+ endif()
+endif (UNIX)
+
+find_path(GSSAPI_INCLUDE_DIR
+ NAMES
+ gssapi.h
+ gssapi/gssapi.h
+ PATHS
+ ${GSSAPI_ROOT_DIR}/include
+ ${_GSSAPI_INCLUDEDIR}
+)
+
+if (GSSAPI_FLAVOR_MIT)
+ find_library(GSSAPI_LIBRARY
+ NAMES
+ gssapi_krb5
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(KRB5_LIBRARY
+ NAMES
+ krb5
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(K5CRYPTO_LIBRARY
+ NAMES
+ k5crypto
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(COM_ERR_LIBRARY
+ NAMES
+ com_err
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ if (GSSAPI_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${GSSAPI_LIBRARY}
+ )
+ endif (GSSAPI_LIBRARY)
+
+ if (KRB5_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${KRB5_LIBRARY}
+ )
+ endif (KRB5_LIBRARY)
+
+ if (K5CRYPTO_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${K5CRYPTO_LIBRARY}
+ )
+ endif (K5CRYPTO_LIBRARY)
+
+ if (COM_ERR_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${COM_ERR_LIBRARY}
+ )
+ endif (COM_ERR_LIBRARY)
+endif (GSSAPI_FLAVOR_MIT)
+
+if (GSSAPI_FLAVOR_HEIMDAL)
+ find_library(GSSAPI_LIBRARY
+ NAMES
+ gssapi
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(KRB5_LIBRARY
+ NAMES
+ krb5
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(HCRYPTO_LIBRARY
+ NAMES
+ hcrypto
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(COM_ERR_LIBRARY
+ NAMES
+ com_err
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(HEIMNTLM_LIBRARY
+ NAMES
+ heimntlm
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(HX509_LIBRARY
+ NAMES
+ hx509
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(ASN1_LIBRARY
+ NAMES
+ asn1
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(WIND_LIBRARY
+ NAMES
+ wind
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(ROKEN_LIBRARY
+ NAMES
+ roken
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ if (GSSAPI_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${GSSAPI_LIBRARY}
+ )
+ endif (GSSAPI_LIBRARY)
+
+ if (KRB5_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${KRB5_LIBRARY}
+ )
+ endif (KRB5_LIBRARY)
+
+ if (HCRYPTO_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${HCRYPTO_LIBRARY}
+ )
+ endif (HCRYPTO_LIBRARY)
+
+ if (COM_ERR_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${COM_ERR_LIBRARY}
+ )
+ endif (COM_ERR_LIBRARY)
+
+ if (HEIMNTLM_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${HEIMNTLM_LIBRARY}
+ )
+ endif (HEIMNTLM_LIBRARY)
+
+ if (HX509_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${HX509_LIBRARY}
+ )
+ endif (HX509_LIBRARY)
+
+ if (ASN1_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${ASN1_LIBRARY}
+ )
+ endif (ASN1_LIBRARY)
+
+ if (WIND_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${WIND_LIBRARY}
+ )
+ endif (WIND_LIBRARY)
+
+ if (ROKEN_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${WIND_LIBRARY}
+ )
+ endif (ROKEN_LIBRARY)
+endif (GSSAPI_FLAVOR_HEIMDAL)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
+
+if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
+ set(GSSAPI_FOUND TRUE)
+endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
+
+# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
+mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
diff --git a/cmake/FindGSSFramework.cmake b/cmake/FindGSSFramework.cmake
new file mode 100644
index 0000000..dcf7249
--- /dev/null
+++ b/cmake/FindGSSFramework.cmake
@@ -0,0 +1,28 @@
+# Find GSS.framework
+# This will define :
+#
+# GSSFRAMEWORK_FOUND
+# GSSFRAMEWORK_INCLUDE_DIR
+# GSSFRAMEWORK_LIBRARIES
+# GSSFRAMEWORK_LDFLAGS
+#
+
+FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
+FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS)
+IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
+ IF (NOT CoreFoundation_FIND_QUIETLY)
+ MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
+ ENDIF()
+ SET(GSSFRAMEWORK_FOUND TRUE)
+ SET(GSSFRAMEWORK_LDFLAGS "-framework GSS")
+ENDIF ()
+
+IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
+ MESSAGE(FATAL_ERROR "CoreFoundation not found")
+ENDIF()
+
+MARK_AS_ADVANCED(
+ GSSFRAMEWORK_INCLUDE_DIR
+ GSSFRAMEWORK_LIBRARIES
+ GSSFRAMEWORK_LDFLAGS
+)
diff --git a/cmake/FindHTTP_Parser.cmake b/cmake/FindHTTP_Parser.cmake
new file mode 100644
index 0000000..d92bf75
--- /dev/null
+++ b/cmake/FindHTTP_Parser.cmake
@@ -0,0 +1,39 @@
+# - Try to find http-parser
+#
+# Defines the following variables:
+#
+# HTTP_PARSER_FOUND - system has http-parser
+# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
+# HTTP_PARSER_LIBRARIES - Link these to use http-parser
+# HTTP_PARSER_VERSION_MAJOR - major version
+# HTTP_PARSER_VERSION_MINOR - minor version
+# HTTP_PARSER_VERSION_STRING - the version of http-parser found
+
+# Find the header and library
+FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
+FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
+
+# Found the header, read version
+if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
+ FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
+ IF (HTTP_PARSER_H)
+ STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
+ STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
+ SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
+ ENDIF()
+ UNSET(HTTP_PARSER_H)
+ENDIF()
+
+# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
+# to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
+
+# Hide advanced variables
+MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
+
+# Set standard variables
+IF (HTTP_PARSER_FOUND)
+ SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
+ set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
+ENDIF()
diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake
new file mode 100644
index 0000000..3c66cda
--- /dev/null
+++ b/cmake/FindIconv.cmake
@@ -0,0 +1,45 @@
+# - Try to find Iconv
+# Once done this will define
+#
+# ICONV_FOUND - system has Iconv
+# ICONV_INCLUDE_DIR - the Iconv include directory
+# ICONV_LIBRARIES - Link these to use Iconv
+#
+
+IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+ # Already in cache, be silent
+ SET(ICONV_FIND_QUIETLY TRUE)
+ENDIF()
+
+FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
+CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
+FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
+
+IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
+ SET(ICONV_FOUND TRUE)
+ SET(ICONV_LIBRARIES "")
+ IF(NOT ICONV_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Iconv: provided by libc")
+ ENDIF(NOT ICONV_FIND_QUIETLY)
+ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
+ SET(ICONV_FOUND TRUE)
+ # split iconv into -L and -l linker options, so we can
+ # set them for pkg-config
+ GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
+ GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
+ STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
+ SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
+
+ IF(NOT ICONV_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
+ ENDIF(NOT ICONV_FIND_QUIETLY)
+ELSE()
+ IF(Iconv_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Iconv")
+ ENDIF(Iconv_FIND_REQUIRED)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ ICONV_INCLUDE_DIR
+ ICONV_LIBRARIES
+)
diff --git a/cmake/FindPCRE.cmake b/cmake/FindPCRE.cmake
new file mode 100644
index 0000000..74ed61e
--- /dev/null
+++ b/cmake/FindPCRE.cmake
@@ -0,0 +1,38 @@
+# Copyright (C) 2007-2009 LuaDist.
+# Created by Peter Kapec <kapecp@gmail.com>
+# Redistribution and use of this file is allowed according to the terms of the MIT license.
+# For details see the COPYRIGHT file distributed with LuaDist.
+# Note:
+# Searching headers and libraries is very simple and is NOT as powerful as scripts
+# distributed with CMake, because LuaDist defines directories to search for.
+# Everyone is encouraged to contact the author with improvements. Maybe this file
+# becomes part of CMake distribution sometimes.
+
+# - Find pcre
+# Find the native PCRE headers and libraries.
+#
+# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
+# PCRE_LIBRARIES - List of libraries when using pcre.
+# PCRE_FOUND - True if pcre found.
+
+# Look for the header file.
+FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
+
+# Look for the library.
+FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
+FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
+
+# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
+
+# Copy the results to the output variables.
+IF(PCRE_FOUND)
+ SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
+ SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
+ELSE(PCRE_FOUND)
+ SET(PCRE_LIBRARIES)
+ SET(PCRE_INCLUDE_DIRS)
+ENDIF(PCRE_FOUND)
+
+MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake
new file mode 100644
index 0000000..f8c5639
--- /dev/null
+++ b/cmake/FindPCRE2.cmake
@@ -0,0 +1,37 @@
+# Copyright (C) 2007-2009 LuaDist.
+# Created by Peter Kapec <kapecp@gmail.com>
+# Redistribution and use of this file is allowed according to the terms of the MIT license.
+# For details see the COPYRIGHT file distributed with LuaDist.
+# Note:
+# Searching headers and libraries is very simple and is NOT as powerful as scripts
+# distributed with CMake, because LuaDist defines directories to search for.
+# Everyone is encouraged to contact the author with improvements. Maybe this file
+# becomes part of CMake distribution sometimes.
+
+# - Find pcre
+# Find the native PCRE2 headers and libraries.
+#
+# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
+# PCRE2_LIBRARIES - List of libraries when using pcre.
+# PCRE2_FOUND - True if pcre found.
+
+# Look for the header file.
+FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
+
+# Look for the library.
+FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
+
+# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
+
+# Copy the results to the output variables.
+IF(PCRE2_FOUND)
+ SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
+ SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
+ELSE(PCRE2_FOUND)
+ SET(PCRE2_LIBRARIES)
+ SET(PCRE2_INCLUDE_DIRS)
+ENDIF(PCRE2_FOUND)
+
+MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
diff --git a/cmake/FindPkgLibraries.cmake b/cmake/FindPkgLibraries.cmake
new file mode 100644
index 0000000..49311c3
--- /dev/null
+++ b/cmake/FindPkgLibraries.cmake
@@ -0,0 +1,28 @@
+INCLUDE(FindPkgConfig)
+
+# This function will find and set up a pkg-config based module.
+# If a pc-file was found, it will resolve library paths to
+# absolute paths. Furthermore, the function will automatically
+# fall back to use static libraries in case no dynamic libraries
+# were found.
+FUNCTION(FIND_PKGLIBRARIES prefix package)
+ PKG_CHECK_MODULES(${prefix} ${package})
+ IF(NOT ${prefix}_FOUND)
+ RETURN()
+ ENDIF()
+
+ FOREACH(LIBRARY ${${prefix}_LIBRARIES})
+ FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
+ IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
+ MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
+ ENDIF()
+ LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
+ ENDFOREACH(LIBRARY)
+
+ SET(${prefix}_FOUND 1 PARENT_SCOPE)
+ SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
+ SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
+ SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
+
+ MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
+ENDFUNCTION()
diff --git a/cmake/FindSecurity.cmake b/cmake/FindSecurity.cmake
new file mode 100644
index 0000000..a538c02
--- /dev/null
+++ b/cmake/FindSecurity.cmake
@@ -0,0 +1,28 @@
+# Find Security.framework
+# This will define :
+#
+# SECURITY_FOUND
+# SECURITY_LIBRARIES
+# SECURITY_LDFLAGS
+# SECURITY_HAS_SSLCREATECONTEXT
+#
+
+FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
+FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
+IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
+ IF (NOT Security_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}")
+ ENDIF()
+ SET(SECURITY_FOUND TRUE)
+ SET(SECURITY_LDFLAGS "-framework Security")
+ CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
+ENDIF ()
+
+IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
+ MESSAGE(FATAL_ERROR "Security not found")
+ENDIF()
+
+MARK_AS_ADVANCED(
+ SECURITY_INCLUDE_DIR
+ SECURITY_LIBRARIES
+)
diff --git a/cmake/FindStatNsec.cmake b/cmake/FindStatNsec.cmake
new file mode 100644
index 0000000..a4a09fa
--- /dev/null
+++ b/cmake/FindStatNsec.cmake
@@ -0,0 +1,26 @@
+INCLUDE(FeatureSummary)
+
+CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
+ HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
+ HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
+ HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
+
+IF (HAVE_STRUCT_STAT_ST_MTIM)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
+ HAVE_STRUCT_STAT_NSEC LANGUAGE C)
+ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
+ HAVE_STRUCT_STAT_NSEC LANGUAGE C)
+ELSE ()
+ SET( HAVE_STRUCT_STAT_NSEC ON )
+ENDIF()
+
+IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
+ OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
+ELSE()
+ SET(USE_NSEC OFF)
+ENDIF()
+
+ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
diff --git a/cmake/FindmbedTLS.cmake b/cmake/FindmbedTLS.cmake
new file mode 100644
index 0000000..9329755
--- /dev/null
+++ b/cmake/FindmbedTLS.cmake
@@ -0,0 +1,93 @@
+# - Try to find mbedTLS
+# Once done this will define
+#
+# Read-Only variables
+# MBEDTLS_FOUND - system has mbedTLS
+# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
+# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
+# MBEDTLS_LIBRARIES - Link these to use mbedTLS
+# MBEDTLS_LIBRARY - path to mbedTLS library
+# MBEDX509_LIBRARY - path to mbedTLS X.509 library
+# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
+#
+# Hint
+# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
+
+SET(_MBEDTLS_ROOT_HINTS
+ ${MBEDTLS_ROOT_DIR}
+ ENV MBEDTLS_ROOT_DIR
+)
+
+SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
+ HINTS ${_MBEDTLS_ROOT_HINTS}
+ PATHS ${_MBEDTLS_ROOT_PATHS}
+)
+
+FIND_PATH(MBEDTLS_INCLUDE_DIR
+ NAMES mbedtls/version.h
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES include
+)
+
+IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
+ # Already in cache, be silent
+ SET(MBEDTLS_FIND_QUIETLY TRUE)
+ENDIF()
+
+FIND_LIBRARY(MBEDTLS_LIBRARY
+ NAMES mbedtls libmbedtls
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES library
+)
+FIND_LIBRARY(MBEDX509_LIBRARY
+ NAMES mbedx509 libmbedx509
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES library
+)
+FIND_LIBRARY(MBEDCRYPTO_LIBRARY
+ NAMES mbedcrypto libmbedcrypto
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES library
+)
+
+IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
+ SET(MBEDTLS_FOUND TRUE)
+ENDIF()
+
+IF(MBEDTLS_FOUND)
+ # split mbedTLS into -L and -l linker options, so we can set them for pkg-config
+ GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
+ GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
+ GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
+ GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
+ STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
+ STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
+ STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
+ SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
+
+ IF(NOT MBEDTLS_FIND_QUIETLY)
+ MESSAGE(STATUS "Found mbedTLS:")
+ FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
+ STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
+ IF (MBEDTLSMATCH)
+ STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
+ MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
+ ENDIF(MBEDTLSMATCH)
+ MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
+ MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
+ MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
+ ENDIF(NOT MBEDTLS_FIND_QUIETLY)
+ELSE(MBEDTLS_FOUND)
+ IF(MBEDTLS_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find mbedTLS")
+ ENDIF(MBEDTLS_FIND_REQUIRED)
+ENDIF(MBEDTLS_FOUND)
+
+MARK_AS_ADVANCED(
+ MBEDTLS_INCLUDE_DIR
+ MBEDTLS_LIBRARY_DIR
+ MBEDTLS_LIBRARIES
+ MBEDTLS_LIBRARY
+ MBEDX509_LIBRARY
+ MBEDCRYPTO_LIBRARY
+)
diff --git a/cmake/IdeSplitSources.cmake b/cmake/IdeSplitSources.cmake
new file mode 100644
index 0000000..e2e09b4
--- /dev/null
+++ b/cmake/IdeSplitSources.cmake
@@ -0,0 +1,22 @@
+# This function splits the sources files up into their appropriate
+# subdirectories. This is especially useful for IDEs like Xcode and
+# Visual Studio, so that you can navigate into the libgit2_clar project,
+# and see the folders within the tests folder (instead of just seeing all
+# source and tests in a single folder.)
+FUNCTION(IDE_SPLIT_SOURCES target)
+ IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
+ GET_TARGET_PROPERTY(sources ${target} SOURCES)
+ FOREACH(source ${sources})
+ IF(source MATCHES ".*/")
+ STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
+ IF(rel)
+ STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
+ IF(rel)
+ STRING(REPLACE "/" "\\\\" rel ${rel})
+ SOURCE_GROUP(${rel} FILES ${source})
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ ENDIF()
+ENDFUNCTION()
diff --git a/cmake/Modules/AddCFlagIfSupported.cmake b/cmake/Modules/AddCFlagIfSupported.cmake
deleted file mode 100644
index b7aaa79..0000000
--- a/cmake/Modules/AddCFlagIfSupported.cmake
+++ /dev/null
@@ -1,30 +0,0 @@
-# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
-# ADD_C_FLAG_IF_SUPPORTED(<flag>)
-# <flag> - the compiler flag to test
-# This internally calls the CHECK_C_COMPILER_FLAG macro.
-
-INCLUDE(CheckCCompilerFlag)
-
-MACRO(ADD_C_FLAG _FLAG)
- STRING(TOUPPER ${_FLAG} UPCASE)
- STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
- STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
- CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
-
- IF(IS_${UPCASE_PRETTY}_SUPPORTED)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
- ELSE()
- MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
- ENDIF()
-ENDMACRO()
-
-MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
- STRING(TOUPPER ${_FLAG} UPCASE)
- STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
- STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
- CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
-
- IF(IS_${UPCASE_PRETTY}_SUPPORTED)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
- ENDIF()
-ENDMACRO()
diff --git a/cmake/Modules/CheckPrototypeDefinition.c.in b/cmake/Modules/CheckPrototypeDefinition.c.in
deleted file mode 100644
index a97344a..0000000
--- a/cmake/Modules/CheckPrototypeDefinition.c.in
+++ /dev/null
@@ -1,29 +0,0 @@
-@CHECK_PROTOTYPE_DEFINITION_HEADER@
-
-static void cmakeRequireSymbol(int dummy, ...) {
- (void) dummy;
-}
-
-static void checkSymbol(void) {
-#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
- cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
-#endif
-}
-
-@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
- return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
-}
-
-#ifdef __CLASSIC_C__
-int main() {
- int ac;
- char*av[];
-#else
-int main(int ac, char *av[]) {
-#endif
- checkSymbol();
- if (ac > 1000) {
- return *av[0];
- }
- return 0;
-}
diff --git a/cmake/Modules/CheckPrototypeDefinition.cmake b/cmake/Modules/CheckPrototypeDefinition.cmake
deleted file mode 100644
index 244b9b5..0000000
--- a/cmake/Modules/CheckPrototypeDefinition.cmake
+++ /dev/null
@@ -1,96 +0,0 @@
-# - Check if the protoype we expect is correct.
-# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
-# FUNCTION - The name of the function (used to check if prototype exists)
-# PROTOTYPE- The prototype to check.
-# RETURN - The return value of the function.
-# HEADER - The header files required.
-# VARIABLE - The variable to store the result.
-# Example:
-# check_prototype_definition(getpwent_r
-# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
-# "NULL"
-# "unistd.h;pwd.h"
-# SOLARIS_GETPWENT_R)
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-
-#=============================================================================
-# Copyright 2005-2009 Kitware, Inc.
-# Copyright 2010-2011 Andreas Schneider <asn@cryptomilk.org>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-#
-
-get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
-function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
-
- if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
- set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
-
- set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
- if (CMAKE_REQUIRED_LIBRARIES)
- set(CHECK_PROTOTYPE_DEFINITION_LIBS
- "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
- else(CMAKE_REQUIRED_LIBRARIES)
- set(CHECK_PROTOTYPE_DEFINITION_LIBS)
- endif(CMAKE_REQUIRED_LIBRARIES)
- if (CMAKE_REQUIRED_INCLUDES)
- set(CMAKE_SYMBOL_EXISTS_INCLUDES
- "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
- else(CMAKE_REQUIRED_INCLUDES)
- set(CMAKE_SYMBOL_EXISTS_INCLUDES)
- endif(CMAKE_REQUIRED_INCLUDES)
-
- foreach(_FILE ${_HEADER})
- set(CHECK_PROTOTYPE_DEFINITION_HEADER
- "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
- endforeach(_FILE)
-
- set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
- set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
- set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
-
- configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in"
- "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
-
- file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
-
- try_compile(${_VARIABLE}
- ${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
- "${CHECK_PROTOTYPE_DEFINITION_LIBS}"
- "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
- OUTPUT_VARIABLE OUTPUT)
-
- if (${_VARIABLE})
- set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
- message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
- "${OUTPUT}\n\n")
- else (${_VARIABLE})
- message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
- set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
- "${OUTPUT}\n\n${_SOURCE}\n\n")
- endif (${_VARIABLE})
- endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
-
-endfunction(CHECK_PROTOTYPE_DEFINITION)
diff --git a/cmake/Modules/EnableWarnings.cmake b/cmake/Modules/EnableWarnings.cmake
deleted file mode 100644
index b61ed7e..0000000
--- a/cmake/Modules/EnableWarnings.cmake
+++ /dev/null
@@ -1,15 +0,0 @@
-MACRO(ENABLE_WARNINGS flag)
- ADD_C_FLAG_IF_SUPPORTED(-W${flag})
-ENDMACRO()
-
-MACRO(DISABLE_WARNINGS flag)
- ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
-ENDMACRO()
-
-IF(ENABLE_WERROR)
- IF(MSVC)
- ADD_COMPILE_OPTIONS(-WX)
- ELSE()
- ADD_C_FLAG_IF_SUPPORTED(-Werror)
- ENDIF()
-ENDIF()
diff --git a/cmake/Modules/FindCoreFoundation.cmake b/cmake/Modules/FindCoreFoundation.cmake
deleted file mode 100644
index 191aa59..0000000
--- a/cmake/Modules/FindCoreFoundation.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-# Find CoreFoundation.framework
-# This will define :
-#
-# COREFOUNDATION_FOUND
-# COREFOUNDATION_LIBRARIES
-# COREFOUNDATION_LDFLAGS
-#
-
-FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
-FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
-IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
- IF (NOT CoreFoundation_FIND_QUIETLY)
- MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
- ENDIF()
- SET(COREFOUNDATION_FOUND TRUE)
- SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
-ENDIF ()
-
-IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
- MESSAGE(FATAL_ERROR "CoreFoundation not found")
-ENDIF()
-
-MARK_AS_ADVANCED(
- COREFOUNDATION_INCLUDE_DIR
- COREFOUNDATION_LIBRARIES
-)
diff --git a/cmake/Modules/FindGSSAPI.cmake b/cmake/Modules/FindGSSAPI.cmake
deleted file mode 100644
index 37357c4..0000000
--- a/cmake/Modules/FindGSSAPI.cmake
+++ /dev/null
@@ -1,324 +0,0 @@
-# - Try to find GSSAPI
-# Once done this will define
-#
-# KRB5_CONFIG - Path to krb5-config
-# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
-#
-# Read-Only variables:
-# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
-# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
-# GSSAPI_FOUND - system has GSSAPI
-# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
-# GSSAPI_LIBRARIES - Link these to use GSSAPI
-# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
-#
-#=============================================================================
-# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-#
-
-find_path(GSSAPI_ROOT_DIR
- NAMES
- include/gssapi.h
- include/gssapi/gssapi.h
- HINTS
- ${_GSSAPI_ROOT_HINTS}
- PATHS
- ${_GSSAPI_ROOT_PATHS}
-)
-mark_as_advanced(GSSAPI_ROOT_DIR)
-
-if (UNIX)
- find_program(KRB5_CONFIG
- NAMES
- krb5-config
- PATHS
- ${GSSAPI_ROOT_DIR}/bin
- /opt/local/bin)
- mark_as_advanced(KRB5_CONFIG)
-
- if (KRB5_CONFIG)
- # Check if we have MIT KRB5
- execute_process(
- COMMAND
- ${KRB5_CONFIG} --vendor
- RESULT_VARIABLE
- _GSSAPI_VENDOR_RESULT
- OUTPUT_VARIABLE
- _GSSAPI_VENDOR_STRING)
-
- if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
- set(GSSAPI_FLAVOR_MIT TRUE)
- else()
- execute_process(
- COMMAND
- ${KRB5_CONFIG} --libs gssapi
- RESULT_VARIABLE
- _GSSAPI_LIBS_RESULT
- OUTPUT_VARIABLE
- _GSSAPI_LIBS_STRING)
-
- if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
- set(GSSAPI_FLAVOR_HEIMDAL TRUE)
- endif()
- endif()
-
- # Get the include dir
- execute_process(
- COMMAND
- ${KRB5_CONFIG} --cflags gssapi
- RESULT_VARIABLE
- _GSSAPI_INCLUDE_RESULT
- OUTPUT_VARIABLE
- _GSSAPI_INCLUDE_STRING)
- string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
- string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
- endif()
-
- if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
- # Check for HEIMDAL
- find_package(PkgConfig)
- if (PKG_CONFIG_FOUND)
- pkg_check_modules(_GSSAPI heimdal-gssapi)
- endif (PKG_CONFIG_FOUND)
-
- if (_GSSAPI_FOUND)
- set(GSSAPI_FLAVOR_HEIMDAL TRUE)
- else()
- find_path(_GSSAPI_ROKEN
- NAMES
- roken.h
- PATHS
- ${GSSAPI_ROOT_DIR}/include
- ${_GSSAPI_INCLUDEDIR})
- if (_GSSAPI_ROKEN)
- set(GSSAPI_FLAVOR_HEIMDAL TRUE)
- endif()
- endif ()
- endif()
-endif (UNIX)
-
-find_path(GSSAPI_INCLUDE_DIR
- NAMES
- gssapi.h
- gssapi/gssapi.h
- PATHS
- ${GSSAPI_ROOT_DIR}/include
- ${_GSSAPI_INCLUDEDIR}
-)
-
-if (GSSAPI_FLAVOR_MIT)
- find_library(GSSAPI_LIBRARY
- NAMES
- gssapi_krb5
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(KRB5_LIBRARY
- NAMES
- krb5
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(K5CRYPTO_LIBRARY
- NAMES
- k5crypto
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(COM_ERR_LIBRARY
- NAMES
- com_err
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- if (GSSAPI_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${GSSAPI_LIBRARY}
- )
- endif (GSSAPI_LIBRARY)
-
- if (KRB5_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${KRB5_LIBRARY}
- )
- endif (KRB5_LIBRARY)
-
- if (K5CRYPTO_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${K5CRYPTO_LIBRARY}
- )
- endif (K5CRYPTO_LIBRARY)
-
- if (COM_ERR_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${COM_ERR_LIBRARY}
- )
- endif (COM_ERR_LIBRARY)
-endif (GSSAPI_FLAVOR_MIT)
-
-if (GSSAPI_FLAVOR_HEIMDAL)
- find_library(GSSAPI_LIBRARY
- NAMES
- gssapi
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(KRB5_LIBRARY
- NAMES
- krb5
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(HCRYPTO_LIBRARY
- NAMES
- hcrypto
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(COM_ERR_LIBRARY
- NAMES
- com_err
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(HEIMNTLM_LIBRARY
- NAMES
- heimntlm
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(HX509_LIBRARY
- NAMES
- hx509
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(ASN1_LIBRARY
- NAMES
- asn1
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(WIND_LIBRARY
- NAMES
- wind
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(ROKEN_LIBRARY
- NAMES
- roken
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- if (GSSAPI_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${GSSAPI_LIBRARY}
- )
- endif (GSSAPI_LIBRARY)
-
- if (KRB5_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${KRB5_LIBRARY}
- )
- endif (KRB5_LIBRARY)
-
- if (HCRYPTO_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${HCRYPTO_LIBRARY}
- )
- endif (HCRYPTO_LIBRARY)
-
- if (COM_ERR_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${COM_ERR_LIBRARY}
- )
- endif (COM_ERR_LIBRARY)
-
- if (HEIMNTLM_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${HEIMNTLM_LIBRARY}
- )
- endif (HEIMNTLM_LIBRARY)
-
- if (HX509_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${HX509_LIBRARY}
- )
- endif (HX509_LIBRARY)
-
- if (ASN1_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${ASN1_LIBRARY}
- )
- endif (ASN1_LIBRARY)
-
- if (WIND_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${WIND_LIBRARY}
- )
- endif (WIND_LIBRARY)
-
- if (ROKEN_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${WIND_LIBRARY}
- )
- endif (ROKEN_LIBRARY)
-endif (GSSAPI_FLAVOR_HEIMDAL)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
-
-if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
- set(GSSAPI_FOUND TRUE)
-endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
-
-# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
-mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
diff --git a/cmake/Modules/FindGSSFramework.cmake b/cmake/Modules/FindGSSFramework.cmake
deleted file mode 100644
index dcf7249..0000000
--- a/cmake/Modules/FindGSSFramework.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Find GSS.framework
-# This will define :
-#
-# GSSFRAMEWORK_FOUND
-# GSSFRAMEWORK_INCLUDE_DIR
-# GSSFRAMEWORK_LIBRARIES
-# GSSFRAMEWORK_LDFLAGS
-#
-
-FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
-FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS)
-IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
- IF (NOT CoreFoundation_FIND_QUIETLY)
- MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
- ENDIF()
- SET(GSSFRAMEWORK_FOUND TRUE)
- SET(GSSFRAMEWORK_LDFLAGS "-framework GSS")
-ENDIF ()
-
-IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
- MESSAGE(FATAL_ERROR "CoreFoundation not found")
-ENDIF()
-
-MARK_AS_ADVANCED(
- GSSFRAMEWORK_INCLUDE_DIR
- GSSFRAMEWORK_LIBRARIES
- GSSFRAMEWORK_LDFLAGS
-)
diff --git a/cmake/Modules/FindHTTP_Parser.cmake b/cmake/Modules/FindHTTP_Parser.cmake
deleted file mode 100644
index d92bf75..0000000
--- a/cmake/Modules/FindHTTP_Parser.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-# - Try to find http-parser
-#
-# Defines the following variables:
-#
-# HTTP_PARSER_FOUND - system has http-parser
-# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
-# HTTP_PARSER_LIBRARIES - Link these to use http-parser
-# HTTP_PARSER_VERSION_MAJOR - major version
-# HTTP_PARSER_VERSION_MINOR - minor version
-# HTTP_PARSER_VERSION_STRING - the version of http-parser found
-
-# Find the header and library
-FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
-FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
-
-# Found the header, read version
-if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
- FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
- IF (HTTP_PARSER_H)
- STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
- STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
- SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
- ENDIF()
- UNSET(HTTP_PARSER_H)
-ENDIF()
-
-# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
-# to TRUE if all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
-
-# Hide advanced variables
-MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
-
-# Set standard variables
-IF (HTTP_PARSER_FOUND)
- SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
- set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
-ENDIF()
diff --git a/cmake/Modules/FindIconv.cmake b/cmake/Modules/FindIconv.cmake
deleted file mode 100644
index 3c66cda..0000000
--- a/cmake/Modules/FindIconv.cmake
+++ /dev/null
@@ -1,45 +0,0 @@
-# - Try to find Iconv
-# Once done this will define
-#
-# ICONV_FOUND - system has Iconv
-# ICONV_INCLUDE_DIR - the Iconv include directory
-# ICONV_LIBRARIES - Link these to use Iconv
-#
-
-IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
- # Already in cache, be silent
- SET(ICONV_FIND_QUIETLY TRUE)
-ENDIF()
-
-FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
-CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
-FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
-
-IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
- SET(ICONV_FOUND TRUE)
- SET(ICONV_LIBRARIES "")
- IF(NOT ICONV_FIND_QUIETLY)
- MESSAGE(STATUS "Found Iconv: provided by libc")
- ENDIF(NOT ICONV_FIND_QUIETLY)
-ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
- SET(ICONV_FOUND TRUE)
- # split iconv into -L and -l linker options, so we can
- # set them for pkg-config
- GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
- GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
- STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
- SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
-
- IF(NOT ICONV_FIND_QUIETLY)
- MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
- ENDIF(NOT ICONV_FIND_QUIETLY)
-ELSE()
- IF(Iconv_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find Iconv")
- ENDIF(Iconv_FIND_REQUIRED)
-ENDIF()
-
-MARK_AS_ADVANCED(
- ICONV_INCLUDE_DIR
- ICONV_LIBRARIES
-)
diff --git a/cmake/Modules/FindPCRE.cmake b/cmake/Modules/FindPCRE.cmake
deleted file mode 100644
index 74ed61e..0000000
--- a/cmake/Modules/FindPCRE.cmake
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2007-2009 LuaDist.
-# Created by Peter Kapec <kapecp@gmail.com>
-# Redistribution and use of this file is allowed according to the terms of the MIT license.
-# For details see the COPYRIGHT file distributed with LuaDist.
-# Note:
-# Searching headers and libraries is very simple and is NOT as powerful as scripts
-# distributed with CMake, because LuaDist defines directories to search for.
-# Everyone is encouraged to contact the author with improvements. Maybe this file
-# becomes part of CMake distribution sometimes.
-
-# - Find pcre
-# Find the native PCRE headers and libraries.
-#
-# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
-# PCRE_LIBRARIES - List of libraries when using pcre.
-# PCRE_FOUND - True if pcre found.
-
-# Look for the header file.
-FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
-
-# Look for the library.
-FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
-FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
-
-# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
-
-# Copy the results to the output variables.
-IF(PCRE_FOUND)
- SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
- SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
-ELSE(PCRE_FOUND)
- SET(PCRE_LIBRARIES)
- SET(PCRE_INCLUDE_DIRS)
-ENDIF(PCRE_FOUND)
-
-MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
diff --git a/cmake/Modules/FindPCRE2.cmake b/cmake/Modules/FindPCRE2.cmake
deleted file mode 100644
index f8c5639..0000000
--- a/cmake/Modules/FindPCRE2.cmake
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2007-2009 LuaDist.
-# Created by Peter Kapec <kapecp@gmail.com>
-# Redistribution and use of this file is allowed according to the terms of the MIT license.
-# For details see the COPYRIGHT file distributed with LuaDist.
-# Note:
-# Searching headers and libraries is very simple and is NOT as powerful as scripts
-# distributed with CMake, because LuaDist defines directories to search for.
-# Everyone is encouraged to contact the author with improvements. Maybe this file
-# becomes part of CMake distribution sometimes.
-
-# - Find pcre
-# Find the native PCRE2 headers and libraries.
-#
-# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
-# PCRE2_LIBRARIES - List of libraries when using pcre.
-# PCRE2_FOUND - True if pcre found.
-
-# Look for the header file.
-FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
-
-# Look for the library.
-FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
-
-# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
-
-# Copy the results to the output variables.
-IF(PCRE2_FOUND)
- SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
- SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
-ELSE(PCRE2_FOUND)
- SET(PCRE2_LIBRARIES)
- SET(PCRE2_INCLUDE_DIRS)
-ENDIF(PCRE2_FOUND)
-
-MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
diff --git a/cmake/Modules/FindPkgLibraries.cmake b/cmake/Modules/FindPkgLibraries.cmake
deleted file mode 100644
index 49311c3..0000000
--- a/cmake/Modules/FindPkgLibraries.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-INCLUDE(FindPkgConfig)
-
-# This function will find and set up a pkg-config based module.
-# If a pc-file was found, it will resolve library paths to
-# absolute paths. Furthermore, the function will automatically
-# fall back to use static libraries in case no dynamic libraries
-# were found.
-FUNCTION(FIND_PKGLIBRARIES prefix package)
- PKG_CHECK_MODULES(${prefix} ${package})
- IF(NOT ${prefix}_FOUND)
- RETURN()
- ENDIF()
-
- FOREACH(LIBRARY ${${prefix}_LIBRARIES})
- FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
- IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
- MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
- ENDIF()
- LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
- ENDFOREACH(LIBRARY)
-
- SET(${prefix}_FOUND 1 PARENT_SCOPE)
- SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
- SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
- SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
-
- MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
-ENDFUNCTION()
diff --git a/cmake/Modules/FindSecurity.cmake b/cmake/Modules/FindSecurity.cmake
deleted file mode 100644
index a538c02..0000000
--- a/cmake/Modules/FindSecurity.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Find Security.framework
-# This will define :
-#
-# SECURITY_FOUND
-# SECURITY_LIBRARIES
-# SECURITY_LDFLAGS
-# SECURITY_HAS_SSLCREATECONTEXT
-#
-
-FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
-FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
-IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
- IF (NOT Security_FIND_QUIETLY)
- MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}")
- ENDIF()
- SET(SECURITY_FOUND TRUE)
- SET(SECURITY_LDFLAGS "-framework Security")
- CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
-ENDIF ()
-
-IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
- MESSAGE(FATAL_ERROR "Security not found")
-ENDIF()
-
-MARK_AS_ADVANCED(
- SECURITY_INCLUDE_DIR
- SECURITY_LIBRARIES
-)
diff --git a/cmake/Modules/FindStatNsec.cmake b/cmake/Modules/FindStatNsec.cmake
deleted file mode 100644
index a4a09fa..0000000
--- a/cmake/Modules/FindStatNsec.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-INCLUDE(FeatureSummary)
-
-CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
- HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
-CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
- HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
-CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
- HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
-
-IF (HAVE_STRUCT_STAT_ST_MTIM)
- CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
- HAVE_STRUCT_STAT_NSEC LANGUAGE C)
-ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
- CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
- HAVE_STRUCT_STAT_NSEC LANGUAGE C)
-ELSE ()
- SET( HAVE_STRUCT_STAT_NSEC ON )
-ENDIF()
-
-IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
- OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
-ELSE()
- SET(USE_NSEC OFF)
-ENDIF()
-
-ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
diff --git a/cmake/Modules/FindmbedTLS.cmake b/cmake/Modules/FindmbedTLS.cmake
deleted file mode 100644
index 9329755..0000000
--- a/cmake/Modules/FindmbedTLS.cmake
+++ /dev/null
@@ -1,93 +0,0 @@
-# - Try to find mbedTLS
-# Once done this will define
-#
-# Read-Only variables
-# MBEDTLS_FOUND - system has mbedTLS
-# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
-# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
-# MBEDTLS_LIBRARIES - Link these to use mbedTLS
-# MBEDTLS_LIBRARY - path to mbedTLS library
-# MBEDX509_LIBRARY - path to mbedTLS X.509 library
-# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
-#
-# Hint
-# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
-
-SET(_MBEDTLS_ROOT_HINTS
- ${MBEDTLS_ROOT_DIR}
- ENV MBEDTLS_ROOT_DIR
-)
-
-SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
- HINTS ${_MBEDTLS_ROOT_HINTS}
- PATHS ${_MBEDTLS_ROOT_PATHS}
-)
-
-FIND_PATH(MBEDTLS_INCLUDE_DIR
- NAMES mbedtls/version.h
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES include
-)
-
-IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
- # Already in cache, be silent
- SET(MBEDTLS_FIND_QUIETLY TRUE)
-ENDIF()
-
-FIND_LIBRARY(MBEDTLS_LIBRARY
- NAMES mbedtls libmbedtls
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES library
-)
-FIND_LIBRARY(MBEDX509_LIBRARY
- NAMES mbedx509 libmbedx509
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES library
-)
-FIND_LIBRARY(MBEDCRYPTO_LIBRARY
- NAMES mbedcrypto libmbedcrypto
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES library
-)
-
-IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
- SET(MBEDTLS_FOUND TRUE)
-ENDIF()
-
-IF(MBEDTLS_FOUND)
- # split mbedTLS into -L and -l linker options, so we can set them for pkg-config
- GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
- GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
- GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
- GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
- STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
- STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
- STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
- SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
-
- IF(NOT MBEDTLS_FIND_QUIETLY)
- MESSAGE(STATUS "Found mbedTLS:")
- FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
- STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
- IF (MBEDTLSMATCH)
- STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
- MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
- ENDIF(MBEDTLSMATCH)
- MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
- MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
- MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
- ENDIF(NOT MBEDTLS_FIND_QUIETLY)
-ELSE(MBEDTLS_FOUND)
- IF(MBEDTLS_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find mbedTLS")
- ENDIF(MBEDTLS_FIND_REQUIRED)
-ENDIF(MBEDTLS_FOUND)
-
-MARK_AS_ADVANCED(
- MBEDTLS_INCLUDE_DIR
- MBEDTLS_LIBRARY_DIR
- MBEDTLS_LIBRARIES
- MBEDTLS_LIBRARY
- MBEDX509_LIBRARY
- MBEDCRYPTO_LIBRARY
-)
diff --git a/cmake/Modules/IdeSplitSources.cmake b/cmake/Modules/IdeSplitSources.cmake
deleted file mode 100644
index e2e09b4..0000000
--- a/cmake/Modules/IdeSplitSources.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-# This function splits the sources files up into their appropriate
-# subdirectories. This is especially useful for IDEs like Xcode and
-# Visual Studio, so that you can navigate into the libgit2_clar project,
-# and see the folders within the tests folder (instead of just seeing all
-# source and tests in a single folder.)
-FUNCTION(IDE_SPLIT_SOURCES target)
- IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
- GET_TARGET_PROPERTY(sources ${target} SOURCES)
- FOREACH(source ${sources})
- IF(source MATCHES ".*/")
- STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
- IF(rel)
- STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
- IF(rel)
- STRING(REPLACE "/" "\\\\" rel ${rel})
- SOURCE_GROUP(${rel} FILES ${source})
- ENDIF()
- ENDIF()
- ENDIF()
- ENDFOREACH()
- ENDIF()
-ENDFUNCTION()
diff --git a/cmake/Modules/PkgBuildConfig.cmake b/cmake/Modules/PkgBuildConfig.cmake
deleted file mode 100644
index 54c5e29..0000000
--- a/cmake/Modules/PkgBuildConfig.cmake
+++ /dev/null
@@ -1,77 +0,0 @@
-# pkg-config file generation
-#
-
-function(pkg_build_config)
- set(options)
- set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
- set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
-
- cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME)
- set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME})
- endif()
- if (NOT DEFINED PKGCONFIG_FILENAME)
- message(FATAL_ERROR "Missing FILENAME argument")
- endif()
- set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc")
-
- if (NOT DEFINED PKGCONFIG_DESCRIPTION)
- message(FATAL_ERROR "Missing DESCRIPTION argument")
- endif()
-
- if (NOT DEFINED PKGCONFIG_VERSION)
- message(FATAL_ERROR "Missing VERSION argument")
- endif()
-
- # Write .pc "header"
- file(WRITE "${PKGCONFIG_FILE}"
- "prefix=\"${CMAKE_INSTALL_PREFIX}\"\n"
- "libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n"
- "includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n"
- "\n"
- "Name: ${PKGCONFIG_NAME}\n"
- "Description: ${PKGCONFIG_DESCRIPTION}\n"
- "Version: ${PKGCONFIG_VERSION}\n"
- )
-
- # Prepare Libs
- if(NOT DEFINED PKGCONFIG_LIBS_SELF)
- set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}")
- endif()
-
- if(NOT DEFINED PKGCONFIG_LIBS)
- set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}")
- else()
- list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}")
- endif()
-
- list(REMOVE_DUPLICATES PKGCONFIG_LIBS)
- string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}")
- file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n")
-
- # Prepare Libs.private
- if(DEFINED PKGCONFIG_PRIVATE_LIBS)
- list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS)
- string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}")
- file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n")
- endif()
-
- # Prepare Requires.private
- if(DEFINED PKGCONFIG_REQUIRES)
- list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES)
- string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")
- file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n")
- endif()
-
- # Prepare Cflags
- if(DEFINED PKGCONFIG_CFLAGS)
- string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}")
- else()
- set(PKGCONFIG_CFLAGS "")
- endif()
- file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
-
- # Install .pc file
- install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endfunction()
diff --git a/cmake/Modules/SanitizeBool.cmake b/cmake/Modules/SanitizeBool.cmake
deleted file mode 100644
index b5b99a6..0000000
--- a/cmake/Modules/SanitizeBool.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-FUNCTION(SanitizeBool VAR)
- STRING(TOLOWER "${${VAR}}" VALUE)
- IF(VALUE STREQUAL "on")
- SET(${VAR} "ON" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "yes")
- SET(${VAR} "ON" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "true")
- SET(${VAR} "ON" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "1")
- SET(${VAR} "ON" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "off")
- SET(${VAR} "OFF" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "no")
- SET(${VAR} "OFF" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "false")
- SET(${VAR} "OFF" PARENT_SCOPE)
- ELSEIF(VALUE STREQUAL "0")
- SET(${VAR} "OFF" PARENT_SCOPE)
- ENDIF()
-ENDFUNCTION()
diff --git a/cmake/Modules/SelectGSSAPI.cmake b/cmake/Modules/SelectGSSAPI.cmake
deleted file mode 100644
index 0a42eee..0000000
--- a/cmake/Modules/SelectGSSAPI.cmake
+++ /dev/null
@@ -1,48 +0,0 @@
-INCLUDE(SanitizeBool)
-
-# We try to find any packages our backends might use
-FIND_PACKAGE(GSSAPI)
-IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- INCLUDE(FindGSSFramework)
-ENDIF()
-
-IF(USE_GSSAPI)
- # Auto-select GSS backend
- SanitizeBool(USE_GSSAPI)
- IF (USE_GSSAPI STREQUAL ON)
- IF (GSSFRAMEWORK_FOUND)
- SET(USE_GSSAPI "GSS.framework")
- ELSEIF(GSSAPI_FOUND)
- SET(USE_GSSAPI "gssapi")
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
- "Please pass the backend name explicitly (-DUSE_GSS=backend)")
- ENDIF()
- ENDIF()
-
- # Check that we can find what's required for the selected backend
- IF (USE_GSSAPI STREQUAL "GSS.framework")
- IF (NOT GSSFRAMEWORK_FOUND)
- MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
- ENDIF()
-
- LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})
-
- SET(GIT_GSSFRAMEWORK 1)
- ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
- ELSEIF (USE_GSSAPI STREQUAL "gssapi")
- IF (NOT GSSAPI_FOUND)
- MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
- ENDIF()
-
- LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})
-
- SET(GIT_GSSAPI 1)
- ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
- ELSE()
- MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
- ENDIF()
-ELSE()
- SET(GIT_GSSAPI 0)
- ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
-ENDIF()
diff --git a/cmake/Modules/SelectHTTPSBackend.cmake b/cmake/Modules/SelectHTTPSBackend.cmake
deleted file mode 100644
index afbeac4..0000000
--- a/cmake/Modules/SelectHTTPSBackend.cmake
+++ /dev/null
@@ -1,120 +0,0 @@
-INCLUDE(SanitizeBool)
-
-# We try to find any packages our backends might use
-FIND_PACKAGE(OpenSSL)
-FIND_PACKAGE(mbedTLS)
-IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- FIND_PACKAGE(Security)
- FIND_PACKAGE(CoreFoundation)
-ENDIF()
-
-IF(USE_HTTPS)
- # Auto-select TLS backend
- SanitizeBool(USE_HTTPS)
- IF (USE_HTTPS STREQUAL ON)
- IF (SECURITY_FOUND)
- IF (SECURITY_HAS_SSLCREATECONTEXT)
- SET(USE_HTTPS "SecureTransport")
- ELSE()
- MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
- SET(USE_HTTPS "OpenSSL")
- ENDIF()
- ELSEIF (WINHTTP)
- SET(USE_HTTPS "WinHTTP")
- ELSEIF(OPENSSL_FOUND)
- SET(USE_HTTPS "OpenSSL")
- ELSEIF(MBEDTLS_FOUND)
- SET(USE_HTTPS "mbedTLS")
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
- "Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
- ENDIF()
- ENDIF()
-
- # Check that we can find what's required for the selected backend
- IF (USE_HTTPS STREQUAL "SecureTransport")
- IF (NOT COREFOUNDATION_FOUND)
- MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
- ENDIF()
- IF (NOT SECURITY_FOUND)
- MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
- ENDIF()
- IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
- MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
- ENDIF()
-
- SET(GIT_SECURE_TRANSPORT 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
- LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
- ELSEIF (USE_HTTPS STREQUAL "OpenSSL")
- IF (NOT OPENSSL_FOUND)
- MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
- ENDIF()
-
- SET(GIT_OPENSSL 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
- LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
- ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
- IF (NOT MBEDTLS_FOUND)
- MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
- ENDIF()
-
- IF(NOT CERT_LOCATION)
- MESSAGE(STATUS "Auto-detecting default certificates location")
- IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
- # Check for an Homebrew installation
- SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
- ELSE()
- SET(OPENSSL_CMD "openssl")
- ENDIF()
- EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
- IF(OPENSSL_DIR)
- STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
-
- SET(OPENSSL_CA_LOCATIONS
- "ca-bundle.pem" # OpenSUSE Leap 42.1
- "cert.pem" # Ubuntu 14.04, FreeBSD
- "certs/ca-certificates.crt" # Ubuntu 16.04
- "certs/ca.pem" # Debian 7
- )
- FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
- SET(LOC "${OPENSSL_DIR}${SUFFIX}")
- IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
- SET(CERT_LOCATION ${LOC})
- ENDIF()
- ENDFOREACH()
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
- ENDIF()
- ENDIF()
-
- IF(CERT_LOCATION)
- IF(NOT EXISTS ${CERT_LOCATION})
- MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
- ENDIF()
- ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
- ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
- ENDIF()
-
- SET(GIT_MBEDTLS 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
- # mbedTLS has no pkgconfig file, hence we can't require it
- # https://github.com/ARMmbed/mbedtls/issues/228
- # For now, pass its link flags as our own
- LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
- ELSEIF (USE_HTTPS STREQUAL "WinHTTP")
- # WinHTTP setup was handled in the WinHTTP-specific block above
- ELSE()
- MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
- ENDIF()
-
- SET(GIT_HTTPS 1)
- ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
-ELSE()
- SET(GIT_HTTPS 0)
- ADD_FEATURE_INFO(HTTPS NO "")
-ENDIF()
diff --git a/cmake/Modules/SelectHashes.cmake b/cmake/Modules/SelectHashes.cmake
deleted file mode 100644
index 06672ab..0000000
--- a/cmake/Modules/SelectHashes.cmake
+++ /dev/null
@@ -1,61 +0,0 @@
-# Select a hash backend
-
-INCLUDE(SanitizeBool)
-
-# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
-
-SanitizeBool(USE_SHA1)
-IF(USE_SHA1 STREQUAL ON)
- SET(USE_SHA1 "CollisionDetection")
-ELSEIF(USE_SHA1 STREQUAL "HTTPS")
- IF(USE_HTTPS STREQUAL "SecureTransport")
- SET(USE_SHA1 "CommonCrypto")
- ELSEIF(USE_HTTPS STREQUAL "WinHTTP")
- SET(USE_SHA1 "Win32")
- ELSEIF(USE_HTTPS)
- SET(USE_SHA1 ${USE_HTTPS})
- ELSE()
- SET(USE_SHA1 "CollisionDetection")
- ENDIF()
-ENDIF()
-
-IF(USE_SHA1 STREQUAL "CollisionDetection")
- SET(GIT_SHA1_COLLISIONDETECT 1)
- ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
- ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
- ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
- FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
-ELSEIF(USE_SHA1 STREQUAL "OpenSSL")
- # OPENSSL_FOUND should already be set, we're checking USE_HTTPS
-
- SET(GIT_SHA1_OPENSSL 1)
- IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
- ELSE()
- LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
- ENDIF()
- FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
-ELSEIF(USE_SHA1 STREQUAL "CommonCrypto")
- SET(GIT_SHA1_COMMON_CRYPTO 1)
- FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
-ELSEIF(USE_SHA1 STREQUAL "mbedTLS")
- SET(GIT_SHA1_MBEDTLS 1)
- FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
- # mbedTLS has no pkgconfig file, hence we can't require it
- # https://github.com/ARMmbed/mbedtls/issues/228
- # For now, pass its link flags as our own
- LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
-ELSEIF(USE_SHA1 STREQUAL "Win32")
- SET(GIT_SHA1_WIN32 1)
- FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
-ELSEIF(USE_SHA1 STREQUAL "Generic")
- FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
-ELSE()
- MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
-ENDIF()
-
-list(SORT SRC_SHA1)
-
-ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")
diff --git a/cmake/PkgBuildConfig.cmake b/cmake/PkgBuildConfig.cmake
new file mode 100644
index 0000000..54c5e29
--- /dev/null
+++ b/cmake/PkgBuildConfig.cmake
@@ -0,0 +1,77 @@
+# pkg-config file generation
+#
+
+function(pkg_build_config)
+ set(options)
+ set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
+ set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
+
+ cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME)
+ set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME})
+ endif()
+ if (NOT DEFINED PKGCONFIG_FILENAME)
+ message(FATAL_ERROR "Missing FILENAME argument")
+ endif()
+ set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc")
+
+ if (NOT DEFINED PKGCONFIG_DESCRIPTION)
+ message(FATAL_ERROR "Missing DESCRIPTION argument")
+ endif()
+
+ if (NOT DEFINED PKGCONFIG_VERSION)
+ message(FATAL_ERROR "Missing VERSION argument")
+ endif()
+
+ # Write .pc "header"
+ file(WRITE "${PKGCONFIG_FILE}"
+ "prefix=\"${CMAKE_INSTALL_PREFIX}\"\n"
+ "libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n"
+ "includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n"
+ "\n"
+ "Name: ${PKGCONFIG_NAME}\n"
+ "Description: ${PKGCONFIG_DESCRIPTION}\n"
+ "Version: ${PKGCONFIG_VERSION}\n"
+ )
+
+ # Prepare Libs
+ if(NOT DEFINED PKGCONFIG_LIBS_SELF)
+ set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}")
+ endif()
+
+ if(NOT DEFINED PKGCONFIG_LIBS)
+ set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}")
+ else()
+ list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}")
+ endif()
+
+ list(REMOVE_DUPLICATES PKGCONFIG_LIBS)
+ string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}")
+ file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n")
+
+ # Prepare Libs.private
+ if(DEFINED PKGCONFIG_PRIVATE_LIBS)
+ list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS)
+ string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}")
+ file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n")
+ endif()
+
+ # Prepare Requires.private
+ if(DEFINED PKGCONFIG_REQUIRES)
+ list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES)
+ string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")
+ file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n")
+ endif()
+
+ # Prepare Cflags
+ if(DEFINED PKGCONFIG_CFLAGS)
+ string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}")
+ else()
+ set(PKGCONFIG_CFLAGS "")
+ endif()
+ file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
+
+ # Install .pc file
+ install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+endfunction()
diff --git a/cmake/SanitizeBool.cmake b/cmake/SanitizeBool.cmake
new file mode 100644
index 0000000..b5b99a6
--- /dev/null
+++ b/cmake/SanitizeBool.cmake
@@ -0,0 +1,20 @@
+FUNCTION(SanitizeBool VAR)
+ STRING(TOLOWER "${${VAR}}" VALUE)
+ IF(VALUE STREQUAL "on")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "yes")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "true")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "1")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "off")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "no")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "false")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "0")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ENDIF()
+ENDFUNCTION()
diff --git a/cmake/SelectGSSAPI.cmake b/cmake/SelectGSSAPI.cmake
new file mode 100644
index 0000000..0a42eee
--- /dev/null
+++ b/cmake/SelectGSSAPI.cmake
@@ -0,0 +1,48 @@
+INCLUDE(SanitizeBool)
+
+# We try to find any packages our backends might use
+FIND_PACKAGE(GSSAPI)
+IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ INCLUDE(FindGSSFramework)
+ENDIF()
+
+IF(USE_GSSAPI)
+ # Auto-select GSS backend
+ SanitizeBool(USE_GSSAPI)
+ IF (USE_GSSAPI STREQUAL ON)
+ IF (GSSFRAMEWORK_FOUND)
+ SET(USE_GSSAPI "GSS.framework")
+ ELSEIF(GSSAPI_FOUND)
+ SET(USE_GSSAPI "gssapi")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
+ "Please pass the backend name explicitly (-DUSE_GSS=backend)")
+ ENDIF()
+ ENDIF()
+
+ # Check that we can find what's required for the selected backend
+ IF (USE_GSSAPI STREQUAL "GSS.framework")
+ IF (NOT GSSFRAMEWORK_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
+ ENDIF()
+
+ LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})
+
+ SET(GIT_GSSFRAMEWORK 1)
+ ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
+ ELSEIF (USE_GSSAPI STREQUAL "gssapi")
+ IF (NOT GSSAPI_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
+ ENDIF()
+
+ LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})
+
+ SET(GIT_GSSAPI 1)
+ ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
+ ENDIF()
+ELSE()
+ SET(GIT_GSSAPI 0)
+ ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
+ENDIF()
diff --git a/cmake/SelectHTTPSBackend.cmake b/cmake/SelectHTTPSBackend.cmake
new file mode 100644
index 0000000..afbeac4
--- /dev/null
+++ b/cmake/SelectHTTPSBackend.cmake
@@ -0,0 +1,120 @@
+INCLUDE(SanitizeBool)
+
+# We try to find any packages our backends might use
+FIND_PACKAGE(OpenSSL)
+FIND_PACKAGE(mbedTLS)
+IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ FIND_PACKAGE(Security)
+ FIND_PACKAGE(CoreFoundation)
+ENDIF()
+
+IF(USE_HTTPS)
+ # Auto-select TLS backend
+ SanitizeBool(USE_HTTPS)
+ IF (USE_HTTPS STREQUAL ON)
+ IF (SECURITY_FOUND)
+ IF (SECURITY_HAS_SSLCREATECONTEXT)
+ SET(USE_HTTPS "SecureTransport")
+ ELSE()
+ MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
+ SET(USE_HTTPS "OpenSSL")
+ ENDIF()
+ ELSEIF (WINHTTP)
+ SET(USE_HTTPS "WinHTTP")
+ ELSEIF(OPENSSL_FOUND)
+ SET(USE_HTTPS "OpenSSL")
+ ELSEIF(MBEDTLS_FOUND)
+ SET(USE_HTTPS "mbedTLS")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
+ "Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
+ ENDIF()
+ ENDIF()
+
+ # Check that we can find what's required for the selected backend
+ IF (USE_HTTPS STREQUAL "SecureTransport")
+ IF (NOT COREFOUNDATION_FOUND)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
+ ENDIF()
+ IF (NOT SECURITY_FOUND)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
+ ENDIF()
+ IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
+ ENDIF()
+
+ SET(GIT_SECURE_TRANSPORT 1)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
+ LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
+ ELSEIF (USE_HTTPS STREQUAL "OpenSSL")
+ IF (NOT OPENSSL_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
+ ENDIF()
+
+ SET(GIT_OPENSSL 1)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
+ LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
+ LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
+ ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
+ IF (NOT MBEDTLS_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
+ ENDIF()
+
+ IF(NOT CERT_LOCATION)
+ MESSAGE(STATUS "Auto-detecting default certificates location")
+ IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
+ # Check for an Homebrew installation
+ SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
+ ELSE()
+ SET(OPENSSL_CMD "openssl")
+ ENDIF()
+ EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
+ IF(OPENSSL_DIR)
+ STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
+
+ SET(OPENSSL_CA_LOCATIONS
+ "ca-bundle.pem" # OpenSUSE Leap 42.1
+ "cert.pem" # Ubuntu 14.04, FreeBSD
+ "certs/ca-certificates.crt" # Ubuntu 16.04
+ "certs/ca.pem" # Debian 7
+ )
+ FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
+ SET(LOC "${OPENSSL_DIR}${SUFFIX}")
+ IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
+ SET(CERT_LOCATION ${LOC})
+ ENDIF()
+ ENDFOREACH()
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
+ ENDIF()
+ ENDIF()
+
+ IF(CERT_LOCATION)
+ IF(NOT EXISTS ${CERT_LOCATION})
+ MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
+ ENDIF()
+ ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
+ ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
+ ENDIF()
+
+ SET(GIT_MBEDTLS 1)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
+ # mbedTLS has no pkgconfig file, hence we can't require it
+ # https://github.com/ARMmbed/mbedtls/issues/228
+ # For now, pass its link flags as our own
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
+ ELSEIF (USE_HTTPS STREQUAL "WinHTTP")
+ # WinHTTP setup was handled in the WinHTTP-specific block above
+ ELSE()
+ MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
+ ENDIF()
+
+ SET(GIT_HTTPS 1)
+ ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
+ELSE()
+ SET(GIT_HTTPS 0)
+ ADD_FEATURE_INFO(HTTPS NO "")
+ENDIF()
diff --git a/cmake/SelectHashes.cmake b/cmake/SelectHashes.cmake
new file mode 100644
index 0000000..06672ab
--- /dev/null
+++ b/cmake/SelectHashes.cmake
@@ -0,0 +1,61 @@
+# Select a hash backend
+
+INCLUDE(SanitizeBool)
+
+# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
+
+SanitizeBool(USE_SHA1)
+IF(USE_SHA1 STREQUAL ON)
+ SET(USE_SHA1 "CollisionDetection")
+ELSEIF(USE_SHA1 STREQUAL "HTTPS")
+ IF(USE_HTTPS STREQUAL "SecureTransport")
+ SET(USE_SHA1 "CommonCrypto")
+ ELSEIF(USE_HTTPS STREQUAL "WinHTTP")
+ SET(USE_SHA1 "Win32")
+ ELSEIF(USE_HTTPS)
+ SET(USE_SHA1 ${USE_HTTPS})
+ ELSE()
+ SET(USE_SHA1 "CollisionDetection")
+ ENDIF()
+ENDIF()
+
+IF(USE_SHA1 STREQUAL "CollisionDetection")
+ SET(GIT_SHA1_COLLISIONDETECT 1)
+ ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
+ ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
+ ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
+ FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
+ELSEIF(USE_SHA1 STREQUAL "OpenSSL")
+ # OPENSSL_FOUND should already be set, we're checking USE_HTTPS
+
+ SET(GIT_SHA1_OPENSSL 1)
+ IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
+ ELSE()
+ LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
+ ENDIF()
+ FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
+ELSEIF(USE_SHA1 STREQUAL "CommonCrypto")
+ SET(GIT_SHA1_COMMON_CRYPTO 1)
+ FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
+ELSEIF(USE_SHA1 STREQUAL "mbedTLS")
+ SET(GIT_SHA1_MBEDTLS 1)
+ FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
+ # mbedTLS has no pkgconfig file, hence we can't require it
+ # https://github.com/ARMmbed/mbedtls/issues/228
+ # For now, pass its link flags as our own
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
+ELSEIF(USE_SHA1 STREQUAL "Win32")
+ SET(GIT_SHA1_WIN32 1)
+ FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
+ELSEIF(USE_SHA1 STREQUAL "Generic")
+ FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
+ELSE()
+ MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
+ENDIF()
+
+list(SORT SRC_SHA1)
+
+ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")