Merge pull request #6084 from libgit2/ethomson/cmake cmake: cleanups and consistency
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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81ef04f..f7b2e71 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,142 +1,141 @@
# CMake build script for the libgit2 project
-#
-# Building (out of source build):
-# > mkdir build && cd build
-# > cmake .. [-DSETTINGS=VALUE]
-# > cmake --build .
-#
-# Testing:
-# > ctest -V
-#
-# Install:
-# > cmake --build . --target install
+# See `README.md` for build instructions.
-CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
+cmake_minimum_required(VERSION 3.5.1)
project(libgit2 VERSION "1.3.0" LANGUAGES C)
# Add find modules to the path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
-INCLUDE(CheckLibraryExists)
-INCLUDE(CheckFunctionExists)
-INCLUDE(CheckSymbolExists)
-INCLUDE(CheckStructHasMember)
-INCLUDE(CheckPrototypeDefinition) # Added in CMake 3.0
-INCLUDE(AddCFlagIfSupported)
-INCLUDE(FindPkgLibraries)
-INCLUDE(FindThreads)
-INCLUDE(FindStatNsec)
-INCLUDE(Findfutimens)
-INCLUDE(GNUInstallDirs)
-INCLUDE(IdeSplitSources)
-INCLUDE(FeatureSummary)
-INCLUDE(EnableWarnings)
+# Modules
+
+include(CheckLibraryExists)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+include(CheckPrototypeDefinition)
+include(AddCFlagIfSupported)
+include(FindPkgLibraries)
+include(FindThreads)
+include(FindStatNsec)
+include(Findfutimens)
+include(GNUInstallDirs)
+include(IdeSplitSources)
+include(FeatureSummary)
+include(EnableWarnings)
+#
# Build options
#
-OPTION(SONAME "Set the (SO)VERSION of the target" ON)
-OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
-OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
-OPTION(BUILD_TESTS "Build Tests using the Clar suite" ON)
-OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
-OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
-OPTION(ENABLE_TRACE "Enables tracing support" ON)
-OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
-OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
-OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
-OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
-OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
-OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
-OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
-OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
-OPTION(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
-OPTION(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
-OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
-OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
- SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
-OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
- SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
-
-IF (UNIX)
- IF (NOT USE_HTTPS)
- OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF )
- ELSE()
- OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." ON )
- ENDIF()
-ENDIF()
-
-IF (UNIX AND NOT APPLE)
- OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
-ENDIF()
-
-IF (APPLE)
- OPTION(USE_ICONV "Link with and use iconv library" ON)
-ENDIF()
-
-IF(MSVC)
+
+# Optional subsystems
+option(THREADSAFE "Build libgit2 as threadsafe" ON)
+option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
+option(BUILD_TESTS "Build Tests using the Clar suite" ON)
+option(BUILD_EXAMPLES "Build library usage example apps" OFF)
+option(BUILD_FUZZERS "Build the fuzz targets" OFF)
+
+# Backend selection
+option(USE_SSH "Link with libssh2 to enable SSH support" ON)
+option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
+option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
+option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
+ set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
+ set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
+option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
+
+# Debugging options
+option(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
+option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
+option(DEBUG_POOL "Enable debug pool allocator" OFF)
+option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
+option(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
+
+# Output options
+option(SONAME "Set the (SO)VERSION of the target" ON)
+option(LIBGIT2_FILENAME "Name of the produced binary" OFF)
+option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
+
+# Compilation options
+option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
+
+if(UNIX)
+ # NTLM client requires crypto libraries from the system HTTPS stack
+ if(NOT USE_HTTPS)
+ option(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF)
+ else()
+ option(USE_NTLMCLIENT "Enable NTLM support on Unix." ON)
+ endif()
+
+ option(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
+endif()
+
+if(APPLE)
+ option(USE_ICONV "Link with and use iconv library" ON)
+endif()
+
+if(MSVC)
# This option must match the settings used in your program, in particular if you
# are linking statically
- OPTION(STATIC_CRT "Link the static CRT libraries" ON)
+ option(STATIC_CRT "Link the static CRT libraries" ON)
# If you want to embed a copy of libssh2 into libgit2, pass a
# path to libssh2
- OPTION(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
-ENDIF()
+ option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
+ # Enable leak checking using the debugging C runtime.
+ option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
+endif()
-IF(WIN32)
+if(WIN32)
# By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
- OPTION(WINHTTP "Use Win32 WinHTTP routines" ON)
-ENDIF()
+ option(WINHTTP "Use Win32 WinHTTP routines" ON)
+endif()
-IF(MSVC)
- # Enable leak checking using the debugging C runtime.
- OPTION(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
-ENDIF()
-IF (DEPRECATE_HARD)
- ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
-ENDIF()
+#
+# Compiler / linker flags
+#
-# Platform specific compilation flags
-IF (MSVC)
- IF (STDCALL)
- MESSAGE(FATAL_ERROR "The STDCALL option is no longer supported; libgit2 is now always built as a cdecl library. If you're using PInvoke, please add the CallingConventions.Cdecl attribute for support.")
- ENDIF()
+if(DEPRECATE_HARD)
+ add_definitions(-DGIT_DEPRECATE_HARD)
+endif()
- ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
- ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
- ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
+# Platform specific compilation flags
+if(MSVC)
+ add_definitions(-D_SCL_SECURE_NO_WARNINGS)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
+ add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
- STRING(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ string(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# /GF - String pooling
# /MP - Parallel build
- SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
+ set(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
# /Gd - explicitly set cdecl calling convention
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
- IF (NOT (MSVC_VERSION LESS 1900))
+ if(NOT (MSVC_VERSION LESS 1900))
# /guard:cf - Enable Control Flow Guard
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
- ENDIF()
-
- IF (STATIC_CRT)
- SET(CRT_FLAG_DEBUG "/MTd")
- SET(CRT_FLAG_RELEASE "/MT")
- ELSE()
- SET(CRT_FLAG_DEBUG "/MDd")
- SET(CRT_FLAG_RELEASE "/MD")
- ENDIF()
-
- IF (WIN32_LEAKCHECK)
- SET(GIT_WIN32_LEAKCHECK 1)
- SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
- SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
- ENDIF()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
+ endif()
+
+ if(STATIC_CRT)
+ set(CRT_FLAG_DEBUG "/MTd")
+ set(CRT_FLAG_RELEASE "/MT")
+ else()
+ set(CRT_FLAG_DEBUG "/MDd")
+ set(CRT_FLAG_RELEASE "/MD")
+ endif()
+
+ if(WIN32_LEAKCHECK)
+ set(GIT_WIN32_LEAKCHECK 1)
+ set(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
+ set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
+ endif()
# /Zi - Create debugging information
# /Od - Disable optimization
@@ -144,7 +143,7 @@ IF (MSVC)
# /MTd - Statically link the multithreaded debug version of the CRT
# /MDd - Dynamically link the multithreaded debug version of the CRT
# /RTC1 - Run time checks
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
# /DNDEBUG - Disables asserts
# /MT - Statically link the multithreaded release version of the CRT
@@ -153,76 +152,80 @@ IF (MSVC)
# /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off)
# /GL - Link time code generation (whole program optimization)
# /Gy - Function-level linking
- SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
+ set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /Oy- - Disable frame pointer omission (FPO)
- SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
# /O1 - Optimize for size
- SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
+ set(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /IGNORE:4221 - Ignore empty compilation units
- SET(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
+ set(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
# /DYNAMICBASE - Address space load randomization (ASLR)
# /NXCOMPAT - Data execution prevention (DEP)
# /LARGEADDRESSAWARE - >2GB user address space on x86
# /VERSION - Embed version information in PE header
- SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
+ set(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
- IF (NOT (MSVC_VERSION LESS 1900))
+ if(NOT (MSVC_VERSION LESS 1900))
# /GUARD:CF - Enable Control Flow Guard
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
- ENDIF()
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
+ endif()
# /DEBUG - Create a PDB
# /LTCG - Link time code generation (whole program optimization)
# /OPT:REF /OPT:ICF - Fold out duplicate code at link step
# /INCREMENTAL:NO - Required to use /LTCG
# /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug)
- SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
- SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
- SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
- SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
+ set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
+ set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
# Same linker settings for DLL as EXE
- SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
- SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
- SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
- SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
- SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
-ELSE ()
- IF (ENABLE_REPRODUCIBLE_BUILDS)
- SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
- SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
- SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
- ENDIF()
-
- SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
-
- ENABLE_WARNINGS(all)
- ENABLE_WARNINGS(extra)
-
- IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
- SET(CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
- ENDIF()
-
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
-
- IF (MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
- STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
- ELSEIF (BUILD_SHARED_LIBS)
- ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
-
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
- ENDIF ()
-
- IF (MINGW)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
+ set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
+else()
+ if(ENABLE_REPRODUCIBLE_BUILDS)
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
+ endif()
+
+ if(NOT BUILD_SHARED_LIBS)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+ endif()
+
+ set(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
+
+ enable_warnings(all)
+ enable_warnings(extra)
+
+ if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ set(CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
+ endif()
+
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
+
+ if(MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
+ string(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
+ elseif(BUILD_SHARED_LIBS)
+ add_c_flag_IF_SUPPORTED(-fvisibility=hidden)
+
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+ endif()
+
+ if(MINGW)
# MinGW >= 3.14 uses the C99-style stdio functions
# automatically, but forks like mingw-w64 still want
# us to define this in order to use them
- ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
- ENDIF ()
+ add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
+ endif()
enable_warnings(documentation)
disable_warnings(documentation-deprecated-sync)
@@ -247,60 +250,59 @@ ELSE ()
enable_warnings(format)
enable_warnings(format-security)
endif()
-ENDIF()
+endif()
# Ensure that MinGW provides the correct header files.
-IF (WIN32 AND NOT CYGWIN)
- ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0600)
-ENDIF()
+if(WIN32 AND NOT CYGWIN)
+ add_definitions(-DWIN32 -D_WIN32_WINNT=0x0600)
+endif()
-IF( NOT CMAKE_CONFIGURATION_TYPES )
+if(NOT CMAKE_CONFIGURATION_TYPES)
# Build Debug by default
- IF (NOT CMAKE_BUILD_TYPE)
- SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
- ENDIF ()
-ELSE()
+ if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
+ endif()
+else()
# Using a multi-configuration generator eg MSVC or Xcode
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
-ENDIF()
+endif()
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
# The actual sanitizer link target will be added when linking the fuzz
# targets.
- SET(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
- ADD_C_FLAG(-fsanitize=fuzzer-no-link)
- UNSET(CMAKE_REQUIRED_FLAGS)
-ENDIF ()
-
-ADD_SUBDIRECTORY(src)
-
-# Tests
-IF (NOT MSVC)
- IF (NOT BUILD_SHARED_LIBS)
- SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
- ENDIF()
-ENDIF ()
-
-IF (BUILD_TESTS)
- ENABLE_TESTING()
- ADD_SUBDIRECTORY(tests)
-ENDIF ()
-
-IF (BUILD_EXAMPLES)
- ADD_SUBDIRECTORY(examples)
-ENDIF ()
-
-IF(BUILD_FUZZERS)
- IF(NOT USE_STANDALONE_FUZZERS)
- IF(BUILD_EXAMPLES)
- MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
- ENDIF()
- IF(BUILD_TESTS)
- MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
- ENDIF()
- ENDIF()
- ADD_SUBDIRECTORY(fuzzers)
-ENDIF()
-
-FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
-FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
+ set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
+ add_c_flag(-fsanitize=fuzzer-no-link)
+ unset(CMAKE_REQUIRED_FLAGS)
+endif()
+
+#
+# Subdirectories
+#
+
+add_subdirectory(src)
+
+if(BUILD_TESTS)
+ enable_testing()
+ add_subdirectory(tests)
+endif()
+
+if(BUILD_EXAMPLES)
+ add_subdirectory(examples)
+endif()
+
+if(BUILD_FUZZERS)
+ if(NOT USE_STANDALONE_FUZZERS)
+ if(BUILD_EXAMPLES)
+ message(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
+ endif()
+ if(BUILD_TESTS)
+ message(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
+ endif()
+ endif()
+ add_subdirectory(fuzzers)
+endif()
+
+# Summary
+
+feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
+feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
diff --git a/deps/chromium-zlib/CMakeLists.txt b/deps/chromium-zlib/CMakeLists.txt
index bbb35d4..55d6794 100644
--- a/deps/chromium-zlib/CMakeLists.txt
+++ b/deps/chromium-zlib/CMakeLists.txt
@@ -4,18 +4,18 @@
# TODO: The Chromium build file (in deps/chromium-zlib/zlib/BUILD.gn) supports
# more platforms (like ARM with NEON), more can be enabled as needed.
-CMAKE_MINIMUM_REQUIRED(VERSION 3.11)
+cmake_minimum_required(VERSION 3.11)
include(FetchContent)
include(FindGit)
# Ensure that the git binary is present to download the sources.
find_package(Git)
-IF(NOT Git_FOUND)
+if(NOT Git_FOUND)
message(FATAL_ERROR "git is required to download the Chromium zlib sources")
-ENDIF()
+endif()
-FetchContent_Populate(chromium_zlib_src
+fetchcontent_populate(chromium_zlib_src
GIT_REPOSITORY https://chromium.googlesource.com/chromium/src/third_party/zlib.git
GIT_TAG 2c183c9f93a328bfb3121284da13cf89a0f7e64a
QUIET
@@ -31,8 +31,8 @@ disable_warnings(missing-declarations)
# -O3 is also set by the Chromium configuration and has been deemed safe enough
# for them.
-SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
-SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
+set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
# Common definitions.
add_definitions(
diff --git a/deps/ntlmclient/CMakeLists.txt b/deps/ntlmclient/CMakeLists.txt
index 3e0d2c8..9c5e23d 100644
--- a/deps/ntlmclient/CMakeLists.txt
+++ b/deps/ntlmclient/CMakeLists.txt
@@ -1,37 +1,37 @@
-FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h")
-LIST(SORT SRC_NTLMCLIENT)
+file(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h")
+list(SORT SRC_NTLMCLIENT)
-ADD_DEFINITIONS(-DNTLM_STATIC=1)
+add_definitions(-DNTLM_STATIC=1)
-DISABLE_WARNINGS(implicit-fallthrough)
+disable_warnings(implicit-fallthrough)
-IF(USE_ICONV)
- ADD_DEFINITIONS(-DUNICODE_ICONV=1)
- FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h")
-ELSE()
- ADD_DEFINITIONS(-DUNICODE_BUILTIN=1)
- FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h")
-ENDIF()
+if(USE_ICONV)
+ add_definitions(-DUNICODE_ICONV=1)
+ file(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h")
+else()
+ add_definitions(-DUNICODE_BUILTIN=1)
+ file(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h")
+endif()
-IF(USE_HTTPS STREQUAL "SecureTransport")
- ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO)
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h")
+if(USE_HTTPS STREQUAL "SecureTransport")
+ add_definitions(-DCRYPT_COMMONCRYPTO)
+ set(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h")
# CC_MD4 has been deprecated in macOS 10.15.
- SET_SOURCE_FILES_PROPERTIES("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
-ELSEIF(USE_HTTPS STREQUAL "OpenSSL")
- ADD_DEFINITIONS(-DCRYPT_OPENSSL)
- INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
-ELSEIF(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
- ADD_DEFINITIONS(-DCRYPT_OPENSSL)
- ADD_DEFINITIONS(-DCRYPT_OPENSSL_DYNAMIC)
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
-ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
- ADD_DEFINITIONS(-DCRYPT_MBEDTLS)
- INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIR})
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h")
-ELSE()
- MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto")
-ENDIF()
+ set_source_files_properties("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
+elseif(USE_HTTPS STREQUAL "OpenSSL")
+ add_definitions(-DCRYPT_OPENSSL)
+ include_directories(${OPENSSL_INCLUDE_DIR})
+ set(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
+elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
+ add_definitions(-DCRYPT_OPENSSL)
+ add_definitions(-DCRYPT_OPENSSL_DYNAMIC)
+ set(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
+elseif(USE_HTTPS STREQUAL "mbedTLS")
+ add_definitions(-DCRYPT_MBEDTLS)
+ include_directories(${MBEDTLS_INCLUDE_DIR})
+ set(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h")
+else()
+ message(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto")
+endif()
-ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
+add_library(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
diff --git a/deps/pcre/CMakeLists.txt b/deps/pcre/CMakeLists.txt
index aff2d75..431dda0 100644
--- a/deps/pcre/CMakeLists.txt
+++ b/deps/pcre/CMakeLists.txt
@@ -1,95 +1,95 @@
-INCLUDE(CheckIncludeFile)
-INCLUDE(CheckFunctionExists)
-INCLUDE(CheckTypeSize)
-
-CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
-CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
-CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
-CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
-CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
-CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
-CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
-
-CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
-CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
-CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
-CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
-CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
-CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
-
-CHECK_TYPE_SIZE("long long" LONG_LONG)
-CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
-
-DISABLE_WARNINGS(unused-function)
-DISABLE_WARNINGS(implicit-fallthrough)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckTypeSize)
+
+check_include_file(dirent.h HAVE_DIRENT_H)
+check_include_file(stdint.h HAVE_STDINT_H)
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+check_include_file(sys/stat.h HAVE_SYS_STAT_H)
+check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
+check_include_file(windows.h HAVE_WINDOWS_H)
+
+check_function_exists(bcopy HAVE_BCOPY)
+check_function_exists(memmove HAVE_MEMMOVE)
+check_function_exists(strerror HAVE_STRERROR)
+check_function_exists(strtoll HAVE_STRTOLL)
+check_function_exists(strtoq HAVE_STRTOQ)
+check_function_exists(_strtoi64 HAVE__STRTOI64)
+
+check_type_size("long long" LONG_LONG)
+check_type_size("unsigned long long" UNSIGNED_LONG_LONG)
+
+disable_warnings(unused-function)
+disable_warnings(implicit-fallthrough)
# User-configurable options
-SET(SUPPORT_PCRE8 1)
-SET(PCRE_LINK_SIZE "2")
-SET(PCRE_PARENS_NEST_LIMIT "250")
-SET(PCRE_MATCH_LIMIT "10000000")
-SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT")
-SET(PCRE_NEWLINE "LF")
-SET(NO_RECURSE 1)
-SET(PCRE_POSIX_MALLOC_THRESHOLD "10")
-SET(BSR_ANYCRLF 0)
-
-IF (MINGW)
- OPTION(NON_STANDARD_LIB_PREFIX
- "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
- OFF)
-
- OPTION(NON_STANDARD_LIB_SUFFIX
- "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
- OFF)
-ENDIF(MINGW)
+set(SUPPORT_PCRE8 1)
+set(PCRE_LINK_SIZE "2")
+set(PCRE_PARENS_NEST_LIMIT "250")
+set(PCRE_MATCH_LIMIT "10000000")
+set(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT")
+set(PCRE_NEWLINE "LF")
+set(NO_RECURSE 1)
+set(PCRE_POSIX_MALLOC_THRESHOLD "10")
+set(BSR_ANYCRLF 0)
+
+if(MINGW)
+ option(NON_STANDARD_LIB_PREFIX
+ "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
+ OFF)
+
+ option(NON_STANDARD_LIB_SUFFIX
+ "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
+ OFF)
+endif(MINGW)
# Prepare build configuration
-SET(pcre_have_long_long 0)
-SET(pcre_have_ulong_long 0)
-
-IF(HAVE_LONG_LONG)
- SET(pcre_have_long_long 1)
-ENDIF(HAVE_LONG_LONG)
-
-IF(HAVE_UNSIGNED_LONG_LONG)
- SET(pcre_have_ulong_long 1)
-ENDIF(HAVE_UNSIGNED_LONG_LONG)
-
-SET(NEWLINE "")
-
-IF(PCRE_NEWLINE STREQUAL "LF")
- SET(NEWLINE "10")
-ENDIF(PCRE_NEWLINE STREQUAL "LF")
-IF(PCRE_NEWLINE STREQUAL "CR")
- SET(NEWLINE "13")
-ENDIF(PCRE_NEWLINE STREQUAL "CR")
-IF(PCRE_NEWLINE STREQUAL "CRLF")
- SET(NEWLINE "3338")
-ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
-IF(PCRE_NEWLINE STREQUAL "ANY")
- SET(NEWLINE "-1")
-ENDIF(PCRE_NEWLINE STREQUAL "ANY")
-IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
- SET(NEWLINE "-2")
-ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
-
-IF(NEWLINE STREQUAL "")
- MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
-ENDIF(NEWLINE STREQUAL "")
+set(pcre_have_long_long 0)
+set(pcre_have_ulong_long 0)
+
+if(HAVE_LONG_LONG)
+ set(pcre_have_long_long 1)
+endif(HAVE_LONG_LONG)
+
+if(HAVE_UNSIGNED_LONG_LONG)
+ set(pcre_have_ulong_long 1)
+endif(HAVE_UNSIGNED_LONG_LONG)
+
+set(NEWLINE "")
+
+if(PCRE_NEWLINE STREQUAL "LF")
+ set(NEWLINE "10")
+endif(PCRE_NEWLINE STREQUAL "LF")
+if(PCRE_NEWLINE STREQUAL "CR")
+ set(NEWLINE "13")
+endif(PCRE_NEWLINE STREQUAL "CR")
+if(PCRE_NEWLINE STREQUAL "CRLF")
+ set(NEWLINE "3338")
+endif(PCRE_NEWLINE STREQUAL "CRLF")
+if(PCRE_NEWLINE STREQUAL "ANY")
+ set(NEWLINE "-1")
+endif(PCRE_NEWLINE STREQUAL "ANY")
+if(PCRE_NEWLINE STREQUAL "ANYCRLF")
+ set(NEWLINE "-2")
+endif(PCRE_NEWLINE STREQUAL "ANYCRLF")
+
+if(NEWLINE STREQUAL "")
+ message(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
+endif(NEWLINE STREQUAL "")
# Output files
-CONFIGURE_FILE(config.h.in
+configure_file(config.h.in
${PROJECT_BINARY_DIR}/src/pcre/config.h
@ONLY)
# Source code
-SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h)
+set(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h)
-SET(PCRE_SOURCES
+set(PCRE_SOURCES
pcre_byte_order.c
pcre_chartables.c
pcre_compile.c
@@ -113,28 +113,28 @@ SET(PCRE_SOURCES
pcre_xclass.c
)
-SET(PCREPOSIX_HEADERS pcreposix.h)
+set(PCREPOSIX_HEADERS pcreposix.h)
-SET(PCREPOSIX_SOURCES pcreposix.c)
+set(PCREPOSIX_SOURCES pcreposix.c)
# Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
# This code was taken from the CMake wiki, not from WebM.
# Build setup
-ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+add_definitions(-DHAVE_CONFIG_H)
-IF(MSVC)
- ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
-ENDIF(MSVC)
+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
+endif(MSVC)
-SET(CMAKE_INCLUDE_CURRENT_DIR 1)
+set(CMAKE_INCLUDE_CURRENT_DIR 1)
-SET(targets)
+set(targets)
# Libraries
# pcre
-INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/src/pcre)
-ADD_LIBRARY(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES})
+include_directories(${PROJECT_BINARY_DIR}/src/pcre)
+add_library(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES})
# end CMakeLists.txt
diff --git a/deps/winhttp/CMakeLists.txt b/deps/winhttp/CMakeLists.txt
index 148ac3e..0ad2ac5 100644
--- a/deps/winhttp/CMakeLists.txt
+++ b/deps/winhttp/CMakeLists.txt
@@ -1,26 +1,26 @@
-FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
-IF (NOT DLLTOOL)
- MESSAGE(FATAL_ERROR "Could not find dlltool command")
-ENDIF ()
+find_program(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
+if(NOT DLLTOOL)
+ message(FATAL_ERROR "Could not find dlltool command")
+endif()
-SET(LIBWINHTTP_PATH "${libgit2_BINARY_DIR}/deps/winhttp")
-SET(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE)
-FILE(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
+set(LIBWINHTTP_PATH "${libgit2_BINARY_DIR}/deps/winhttp")
+set(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE)
+file(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
-IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(WINHTTP_DEF "winhttp64.def")
-ELSE()
+else()
set(WINHTTP_DEF "winhttp.def")
-ENDIF()
+endif()
-ADD_CUSTOM_COMMAND(
+add_custom_command(
OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a
COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a
DEPENDS ${WINHTTP_DEF}
WORKING_DIRECTORY ${LIBWINHTTP_PATH}
)
-SET_SOURCE_FILES_PROPERTIES(
+set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c
PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a
)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 8cc72b3..a7970a6 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,15 +1,15 @@
-INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
-INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
+include_directories(${LIBGIT2_INCLUDES})
+include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
-FILE(GLOB LG2_SOURCES *.c *.h)
-ADD_EXECUTABLE(lg2 ${LG2_SOURCES})
-SET_TARGET_PROPERTIES(lg2 PROPERTIES C_STANDARD 90)
+file(GLOB LG2_SOURCES *.c *.h)
+add_executable(lg2 ${LG2_SOURCES})
+set_target_properties(lg2 PROPERTIES C_STANDARD 90)
# Ensure that we do not use deprecated functions internally
-ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
+add_definitions(-DGIT_DEPRECATE_HARD)
-IF(WIN32 OR ANDROID)
- TARGET_LINK_LIBRARIES(lg2 git2)
-ELSE()
- TARGET_LINK_LIBRARIES(lg2 git2 pthread)
-ENDIF()
+if(WIN32 OR ANDROID)
+ target_link_libraries(lg2 git2)
+else()
+ target_link_libraries(lg2 git2 pthread)
+endif()
diff --git a/fuzzers/CMakeLists.txt b/fuzzers/CMakeLists.txt
index 59eca24..8cc61b7 100644
--- a/fuzzers/CMakeLists.txt
+++ b/fuzzers/CMakeLists.txt
@@ -1,23 +1,23 @@
-LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
-INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
-INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
+link_directories(${LIBGIT2_LIBDIRS})
+include_directories(${LIBGIT2_INCLUDES})
+include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
-IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
- ADD_C_FLAG(-fsanitize=fuzzer)
-ENDIF ()
+if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
+ add_c_flag(-fsanitize=fuzzer)
+endif()
-FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
-FOREACH(fuzz_target_src ${SRC_FUZZ})
- STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
- STRING(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
+file(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
+foreach(fuzz_target_src ${SRC_FUZZ})
+ string(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
+ string(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
- SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
- IF(USE_STANDALONE_FUZZERS)
- LIST(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
- ENDIF()
- ADD_EXECUTABLE(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
- SET_TARGET_PROPERTIES(${fuzz_target_name} PROPERTIES C_STANDARD 90)
- TARGET_LINK_LIBRARIES(${fuzz_target_name} ${LIBGIT2_LIBS})
+ set(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
+ if(USE_STANDALONE_FUZZERS)
+ list(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
+ endif()
+ add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
+ set_target_properties(${fuzz_target_name} PROPERTIES C_STANDARD 90)
+ target_link_libraries(${fuzz_target_name} ${LIBGIT2_LIBS})
- ADD_TEST(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
-ENDFOREACH()
+ add_test(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
+endforeach()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fdb3673..9812fc0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,95 +1,91 @@
add_library(git2internal OBJECT)
set_target_properties(git2internal PROPERTIES C_STANDARD 90)
-IF(DEBUG_POOL)
- SET(GIT_DEBUG_POOL 1)
-ENDIF()
-ADD_FEATURE_INFO(debugpool GIT_DEBUG_POOL "debug pool allocator")
-IF(DEBUG_STRICT_ALLOC)
- SET(GIT_DEBUG_STRICT_ALLOC 1)
-ENDIF()
-ADD_FEATURE_INFO(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators")
+if(DEBUG_POOL)
+ set(GIT_DEBUG_POOL 1)
+endif()
+add_feature_info(debugpool GIT_DEBUG_POOL "debug pool allocator")
+
+if(DEBUG_STRICT_ALLOC)
+ set(GIT_DEBUG_STRICT_ALLOC 1)
+endif()
+add_feature_info(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators")
+
+if(DEBUG_STRICT_OPEN)
+ set(GIT_DEBUG_STRICT_OPEN 1)
+endif()
+add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
-IF(DEBUG_STRICT_OPEN)
- SET(GIT_DEBUG_STRICT_OPEN 1)
-ENDIF()
-ADD_FEATURE_INFO(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
-INCLUDE(PkgBuildConfig)
-INCLUDE(SanitizeBool)
+include(PkgBuildConfig)
+include(SanitizeBool)
# This variable will contain the libraries we need to put into
# libgit2.pc's Requires.private. That is, what we're linking to or
# what someone who's statically linking us needs to link to.
-SET(LIBGIT2_PC_REQUIRES "")
+set(LIBGIT2_PC_REQUIRES "")
# This will be set later if we use the system's http-parser library or
# use iconv (OSX) and will be written to the Libs.private field in the
# pc file.
-SET(LIBGIT2_PC_LIBS "")
+set(LIBGIT2_PC_LIBS "")
-SET(LIBGIT2_INCLUDES
+set(LIBGIT2_INCLUDES
"${CMAKE_CURRENT_BINARY_DIR}"
"${libgit2_SOURCE_DIR}/src"
"${libgit2_SOURCE_DIR}/include")
-SET(LIBGIT2_SYSTEM_INCLUDES "")
-SET(LIBGIT2_LIBS "")
+set(LIBGIT2_SYSTEM_INCLUDES "")
+set(LIBGIT2_LIBS "")
enable_warnings(missing-declarations)
-# Enable tracing
-IF(ENABLE_TRACE)
- SET(GIT_TRACE 1)
-ENDIF()
-ADD_FEATURE_INFO(tracing GIT_TRACE "tracing support")
+if(HAVE_FUTIMENS)
+ set(GIT_USE_FUTIMENS 1)
+endif ()
+add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
-IF (HAVE_FUTIMENS)
- SET(GIT_USE_FUTIMENS 1)
-ENDIF ()
-ADD_FEATURE_INFO(futimens GIT_USE_FUTIMENS "futimens support")
-
-CHECK_PROTOTYPE_DEFINITION(qsort_r
+check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
"" "stdlib.h" HAVE_QSORT_R_BSD)
-IF (HAVE_QSORT_R_BSD)
+if(HAVE_QSORT_R_BSD)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
-ENDIF()
+endif()
-CHECK_PROTOTYPE_DEFINITION(qsort_r
+check_prototype_definition(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
"" "stdlib.h" HAVE_QSORT_R_GNU)
-IF (HAVE_QSORT_R_GNU)
+if(HAVE_QSORT_R_GNU)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
-ENDIF()
+endif()
-CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S)
-IF (HAVE_QSORT_S)
+check_function_exists(qsort_s HAVE_QSORT_S)
+if(HAVE_QSORT_S)
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
-ENDIF ()
+endif()
# Find required dependencies
-IF(WIN32)
- LIST(APPEND LIBGIT2_LIBS ws2_32)
-ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
- LIST(APPEND LIBGIT2_LIBS socket nsl)
- LIST(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
-ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Haiku")
- LIST(APPEND LIBGIT2_LIBS network)
- LIST(APPEND LIBGIT2_PC_LIBS "-lnetwork")
-ENDIF()
-
-CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
-IF(NEED_LIBRT)
- LIST(APPEND LIBGIT2_LIBS rt)
- LIST(APPEND LIBGIT2_PC_LIBS "-lrt")
-ENDIF()
-
-IF(THREADSAFE)
- LIST(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
- LIST(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
-ENDIF()
-ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
+if(WIN32)
+ list(APPEND LIBGIT2_LIBS ws2_32)
+elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ list(APPEND LIBGIT2_LIBS socket nsl)
+ list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
+elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
+ list(APPEND LIBGIT2_LIBS network)
+ list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
+endif()
+
+check_library_exists(rt clock_gettime "time.h" NEED_LIBRT)
+if(NEED_LIBRT)
+ list(APPEND LIBGIT2_LIBS rt)
+ list(APPEND LIBGIT2_PC_LIBS "-lrt")
+endif()
+
+if(THREADSAFE)
+ list(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
+add_feature_info(threadsafe THREADSAFE "threadsafe support")
if(WIN32 AND EMBED_SSH_PATH)
@@ -102,204 +98,204 @@ if(WIN32 AND EMBED_SSH_PATH)
set(GIT_SSH 1)
endif()
-IF (WIN32 AND WINHTTP)
- SET(GIT_WINHTTP 1)
+if(WIN32 AND WINHTTP)
+ set(GIT_WINHTTP 1)
# Since MinGW does not come with headers or an import library for winhttp,
# we have to include a private header and generate our own import library
- IF (MINGW)
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
- LIST(APPEND LIBGIT2_LIBS winhttp)
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
- ELSE()
- LIST(APPEND LIBGIT2_LIBS "winhttp")
- LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
- ENDIF ()
-
- LIST(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
- LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
-ENDIF()
+ if(MINGW)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
+ list(APPEND LIBGIT2_LIBS winhttp)
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
+ else()
+ list(APPEND LIBGIT2_LIBS "winhttp")
+ list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
+ endif()
+
+ list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
+ list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
+endif()
include(SelectHTTPSBackend)
include(SelectHashes)
target_sources(git2internal PRIVATE ${SRC_SHA1})
# Specify regular expression implementation
-FIND_PACKAGE(PCRE)
-
-IF(REGEX_BACKEND STREQUAL "")
- CHECK_SYMBOL_EXISTS(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
-
- IF(HAVE_REGCOMP_L)
- SET(REGEX_BACKEND "regcomp_l")
- ELSEIF(PCRE_FOUND)
- SET(REGEX_BACKEND "pcre")
- ELSE()
- SET(REGEX_BACKEND "builtin")
- ENDIF()
-ENDIF()
-
-IF(REGEX_BACKEND STREQUAL "regcomp_l")
- ADD_FEATURE_INFO(regex ON "using system regcomp_l")
- SET(GIT_REGEX_REGCOMP_L 1)
-ELSEIF(REGEX_BACKEND STREQUAL "pcre2")
- FIND_PACKAGE(PCRE2)
-
- IF(NOT PCRE2_FOUND)
+find_package(PCRE)
+
+if(REGEX_BACKEND STREQUAL "")
+ check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
+
+ if(HAVE_REGCOMP_L)
+ set(REGEX_BACKEND "regcomp_l")
+ elseif(PCRE_FOUND)
+ set(REGEX_BACKEND "pcre")
+ else()
+ set(REGEX_BACKEND "builtin")
+ endif()
+endif()
+
+if(REGEX_BACKEND STREQUAL "regcomp_l")
+ add_feature_info(regex ON "using system regcomp_l")
+ set(GIT_REGEX_REGCOMP_L 1)
+elseif(REGEX_BACKEND STREQUAL "pcre2")
+ find_package(PCRE2)
+
+ if(NOT PCRE2_FOUND)
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
- ENDIF()
-
- ADD_FEATURE_INFO(regex ON "using system PCRE2")
- SET(GIT_REGEX_PCRE2 1)
-
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
-ELSEIF(REGEX_BACKEND STREQUAL "pcre")
- ADD_FEATURE_INFO(regex ON "using system PCRE")
- SET(GIT_REGEX_PCRE 1)
-
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_REQUIRES "libpcre")
-ELSEIF(REGEX_BACKEND STREQUAL "regcomp")
- ADD_FEATURE_INFO(regex ON "using system regcomp")
- SET(GIT_REGEX_REGCOMP 1)
-ELSEIF(REGEX_BACKEND STREQUAL "builtin")
- ADD_FEATURE_INFO(regex ON "using bundled PCRE")
- SET(GIT_REGEX_BUILTIN 1)
-
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
-ELSE()
- MESSAGE(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
-ENDIF()
+ endif()
+
+ add_feature_info(regex ON "using system PCRE2")
+ set(GIT_REGEX_PCRE2 1)
+
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES})
+ list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
+elseif(REGEX_BACKEND STREQUAL "pcre")
+ add_feature_info(regex ON "using system PCRE")
+ set(GIT_REGEX_PCRE 1)
+
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES})
+ list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
+elseif(REGEX_BACKEND STREQUAL "regcomp")
+ add_feature_info(regex ON "using system regcomp")
+ set(GIT_REGEX_REGCOMP 1)
+elseif(REGEX_BACKEND STREQUAL "builtin")
+ add_feature_info(regex ON "using bundled PCRE")
+ set(GIT_REGEX_BUILTIN 1)
+
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
+else()
+ message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
+endif()
# Optional external dependency: http-parser
-IF(USE_HTTP_PARSER STREQUAL "system")
- FIND_PACKAGE(HTTP_Parser)
-
- IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
- ADD_FEATURE_INFO(http-parser ON "http-parser support (system)")
- ELSE()
- MESSAGE(FATAL_ERROR "http-parser support was requested but not found")
- ENDIF()
-ELSE()
- MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
- LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
- ADD_FEATURE_INFO(http-parser ON "http-parser support (bundled)")
-ENDIF()
+if(USE_HTTP_PARSER STREQUAL "system")
+ find_package(HTTP_Parser)
+
+ if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
+ list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
+ add_feature_info(http-parser ON "http-parser support (system)")
+ else()
+ message(FATAL_ERROR "http-parser support was requested but not found")
+ endif()
+else()
+ message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
+ list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
+ add_feature_info(http-parser ON "http-parser support (bundled)")
+endif()
# Optional external dependency: zlib
SanitizeBool(USE_BUNDLED_ZLIB)
-IF(USE_BUNDLED_ZLIB STREQUAL ON)
- SET(USE_BUNDLED_ZLIB "Bundled")
-ENDIF()
-
-IF(USE_BUNDLED_ZLIB STREQUAL "OFF")
- FIND_PACKAGE(ZLIB)
- IF(ZLIB_FOUND)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
- IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- LIST(APPEND LIBGIT2_PC_LIBS "-lz")
- ELSE()
- LIST(APPEND LIBGIT2_PC_REQUIRES "zlib")
- ENDIF()
- ADD_FEATURE_INFO(zlib ON "using system zlib")
- ELSE()
- MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
- ENDIF()
-ENDIF()
-IF(USE_BUNDLED_ZLIB STREQUAL "Chromium")
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
- ADD_FEATURE_INFO(zlib ON "using (Chromium) bundled zlib")
-ELSEIF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
- LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
- ADD_FEATURE_INFO(zlib ON "using bundled zlib")
-ENDIF()
+if(USE_BUNDLED_ZLIB STREQUAL ON)
+ set(USE_BUNDLED_ZLIB "Bundled")
+endif()
+
+if(USE_BUNDLED_ZLIB STREQUAL "OFF")
+ find_package(ZLIB)
+ if(ZLIB_FOUND)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
+ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ list(APPEND LIBGIT2_PC_LIBS "-lz")
+ else()
+ list(APPEND LIBGIT2_PC_REQUIRES "zlib")
+ endif()
+ add_feature_info(zlib ON "using system zlib")
+ else()
+ message(STATUS "zlib was not found; using bundled 3rd-party sources." )
+ endif()
+endif()
+if(USE_BUNDLED_ZLIB STREQUAL "Chromium")
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
+ add_feature_info(zlib ON "using (Chromium) bundled zlib")
+elseif(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
+ add_feature_info(zlib ON "using bundled zlib")
+endif()
# Optional external dependency: libssh2
-IF (USE_SSH)
- FIND_PKGLIBRARIES(LIBSSH2 libssh2)
- IF (NOT LIBSSH2_FOUND)
- FIND_PACKAGE(LibSSH2)
- SET(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
- GET_FILENAME_COMPONENT(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
- SET(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
- SET(LIBSSH2_LDFLAGS "-lssh2")
- ENDIF()
-ENDIF()
-IF (LIBSSH2_FOUND)
- SET(GIT_SSH 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
-
- CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- SET(GIT_SSH_MEMORY_CREDENTIALS 1)
- ENDIF()
-ELSE()
- MESSAGE(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
-ENDIF()
-ADD_FEATURE_INFO(SSH GIT_SSH "SSH transport support")
+if(USE_SSH)
+ find_pkglibraries(LIBSSH2 libssh2)
+ if(NOT LIBSSH2_FOUND)
+ find_package(LibSSH2)
+ set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
+ get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
+ set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
+ set(LIBSSH2_LDFLAGS "-lssh2")
+ endif()
+endif()
+if(LIBSSH2_FOUND)
+ set(GIT_SSH 1)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
+ list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
+
+ check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
+ if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
+ set(GIT_SSH_MEMORY_CREDENTIALS 1)
+ endif()
+else()
+ message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
+endif()
+add_feature_info(SSH GIT_SSH "SSH transport support")
# Optional external dependency: ntlmclient
-IF (USE_NTLMCLIENT)
- SET(GIT_NTLM 1)
- ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
- LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
-ENDIF()
-ADD_FEATURE_INFO(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
+if(USE_NTLMCLIENT)
+ set(GIT_NTLM 1)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
+ list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
+endif()
+add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
# Optional external dependency: GSSAPI
-INCLUDE(SelectGSSAPI)
+include(SelectGSSAPI)
# Optional external dependency: iconv
-IF (USE_ICONV)
- FIND_PACKAGE(Iconv)
-ENDIF()
-IF (ICONV_FOUND)
- SET(GIT_USE_ICONV 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES})
-ENDIF()
-ADD_FEATURE_INFO(iconv GIT_USE_ICONV "iconv encoding conversion support")
-
-
-IF (THREADSAFE)
- IF (NOT WIN32)
- FIND_PACKAGE(Threads REQUIRED)
- ENDIF()
-
- SET(GIT_THREADS 1)
-ENDIF()
-
-IF (USE_NSEC)
- SET(GIT_USE_NSEC 1)
-ENDIF()
-
-IF (HAVE_STRUCT_STAT_ST_MTIM)
- SET(GIT_USE_STAT_MTIM 1)
-ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
- SET(GIT_USE_STAT_MTIMESPEC 1)
-ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
- SET(GIT_USE_STAT_MTIME_NSEC 1)
-ENDIF()
+if(USE_ICONV)
+ find_package(Iconv)
+endif()
+if(ICONV_FOUND)
+ set(GIT_USE_ICONV 1)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR})
+ list(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES})
+ list(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES})
+endif()
+add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support")
+
+
+if(THREADSAFE)
+ if(NOT WIN32)
+ find_package(Threads REQUIRED)
+ endif()
+
+ set(GIT_THREADS 1)
+endif()
+
+if(USE_NSEC)
+ set(GIT_USE_NSEC 1)
+endif()
+
+if(HAVE_STRUCT_STAT_ST_MTIM)
+ set(GIT_USE_STAT_MTIM 1)
+elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ set(GIT_USE_STAT_MTIMESPEC 1)
+elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC)
+ set(GIT_USE_STAT_MTIME_NSEC 1)
+endif()
target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
@@ -313,7 +309,7 @@ target_sources(git2internal PRIVATE ${SRC_H})
# On Windows use specific platform sources
if(WIN32 AND NOT CYGWIN)
- SET(WIN_RC "win32/git2.rc")
+ set(WIN_RC "win32/git2.rc")
file(GLOB SRC_OS win32/*.c win32/*.h)
list(SORT SRC_OS)
@@ -326,9 +322,9 @@ else()
target_sources(git2internal PRIVATE ${SRC_OS})
endif()
-IF (USE_LEAK_CHECKER STREQUAL "valgrind")
+if(USE_LEAK_CHECKER STREQUAL "valgrind")
target_compile_definitions(git2internal PRIVATE VALGRIND)
-ENDIF()
+endif()
file(GLOB SRC_GIT2 *.c *.h
allocators/*.c allocators/*.h
@@ -338,65 +334,65 @@ file(GLOB SRC_GIT2 *.c *.h
list(SORT SRC_GIT2)
target_sources(git2internal PRIVATE ${SRC_GIT2})
-IF(APPLE)
+if(APPLE)
# The old Secure Transport API has been deprecated in macOS 10.15.
- SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
-ENDIF()
+ set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
+endif()
# the xdiff dependency is not (yet) warning-free, disable warnings as
# errors for the xdiff sources until we've sorted them out
-IF(MSVC)
- SET_SOURCE_FILES_PROPERTIES(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
- SET_SOURCE_FILES_PROPERTIES(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
-ENDIF()
+if(MSVC)
+ set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
+endif()
# Determine architecture of the machine
-IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
- SET(GIT_ARCH_64 1)
-ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
- SET(GIT_ARCH_32 1)
-ELSEIF (CMAKE_SIZEOF_VOID_P)
- MESSAGE(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
-ELSE()
- MESSAGE(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
-ENDIF()
-
-CONFIGURE_FILE(features.h.in git2/sys/features.h)
-
-IDE_SPLIT_SOURCES(git2internal)
-LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
-
-TARGET_INCLUDE_DIRECTORIES(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
-TARGET_INCLUDE_DIRECTORIES(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
-
-SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
-SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
-SET(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
-SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
-
-IF(XCODE_VERSION)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(GIT_ARCH_64 1)
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(GIT_ARCH_32 1)
+elseif(CMAKE_SIZEOF_VOID_P)
+ message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
+else()
+ message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
+endif()
+
+configure_file(features.h.in git2/sys/features.h)
+
+ide_split_sources(git2internal)
+list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
+
+target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
+target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+
+set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
+set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
+
+if(XCODE_VERSION)
# This is required for Xcode to actually link the libgit2 library
# when using only object libraries.
- FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
- LIST(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
-ENDIF()
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
+ list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
+endif()
# Compile and link libgit2
-ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
-TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
+add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
+target_link_libraries(git2 ${LIBGIT2_LIBS})
-SET_TARGET_PROPERTIES(git2 PROPERTIES C_STANDARD 90)
-SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES C_STANDARD 90)
+set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
# Win64+MSVC+static libs = linker error
-IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
- SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
-ENDIF()
+if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
+ set_target_properties(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
+endif()
-IDE_SPLIT_SOURCES(git2)
+ide_split_sources(git2)
if(SONAME)
set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
@@ -409,7 +405,7 @@ if(SONAME)
endif()
endif()
-PKG_BUILD_CONFIG(NAME libgit2
+pkg_build_config(NAME libgit2
VERSION ${libgit2_VERSION}
DESCRIPTION "The git library, take 2"
LIBS_SELF git2
@@ -417,17 +413,17 @@ PKG_BUILD_CONFIG(NAME libgit2
REQUIRES ${LIBGIT2_PC_REQUIRES}
)
-IF (MSVC_IDE)
- # Precompiled headers
- SET_TARGET_PROPERTIES(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
- SET_SOURCE_FILES_PROPERTIES(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
-ENDIF ()
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
# Install
-INSTALL(TARGETS git2
+install(TARGETS git2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-INSTALL(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-INSTALL(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
diff --git a/src/features.h.in b/src/features.h.in
index 202cef4..a40b608 100644
--- a/src/features.h.in
+++ b/src/features.h.in
@@ -5,7 +5,6 @@
#cmakedefine GIT_DEBUG_STRICT_ALLOC 1
#cmakedefine GIT_DEBUG_STRICT_OPEN 1
-#cmakedefine GIT_TRACE 1
#cmakedefine GIT_THREADS 1
#cmakedefine GIT_WIN32_LEAKCHECK 1
diff --git a/src/trace.c b/src/trace.c
index c316bca..b0c56c4 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -11,15 +11,10 @@
#include "runtime.h"
#include "git2/trace.h"
-#ifdef GIT_TRACE
-
struct git_trace_data git_trace__data = {0};
-#endif
-
int git_trace_set(git_trace_level_t level, git_trace_cb callback)
{
-#ifdef GIT_TRACE
GIT_ASSERT_ARG(level == 0 || callback != NULL);
git_trace__data.level = level;
@@ -27,12 +22,4 @@ int git_trace_set(git_trace_level_t level, git_trace_cb callback)
GIT_MEMORY_BARRIER;
return 0;
-#else
- GIT_UNUSED(level);
- GIT_UNUSED(callback);
-
- git_error_set(GIT_ERROR_INVALID,
- "this version of libgit2 was not built with tracing.");
- return -1;
-#endif
}
diff --git a/src/trace.h b/src/trace.h
index eb20ec5..239928d 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -12,8 +12,6 @@
#include <git2/trace.h>
#include "str.h"
-#ifdef GIT_TRACE
-
struct git_trace_data {
git_trace_level_t level;
git_trace_cb callback;
@@ -50,19 +48,4 @@ GIT_INLINE(void) git_trace(git_trace_level_t level, const char *fmt, ...)
}
}
-#else
-
-GIT_INLINE(void) git_trace__null(
- git_trace_level_t level,
- const char *fmt, ...)
-{
- GIT_UNUSED(level);
- GIT_UNUSED(fmt);
-}
-
-#define git_trace_level() ((git_trace_level_t)0)
-#define git_trace git_trace__null
-
-#endif
-
#endif
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 74423fb..b85cd6e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,73 +1,73 @@
-SET(Python_ADDITIONAL_VERSIONS 3 2.7)
-FIND_PACKAGE(PythonInterp)
+set(Python_ADDITIONAL_VERSIONS 3 2.7)
+find_package(PythonInterp)
-IF(NOT PYTHONINTERP_FOUND)
- MESSAGE(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. "
- "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
+if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. "
+ "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
ENDIF()
-SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/")
-SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
-ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
-ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\")
-ADD_DEFINITIONS(-DCLAR_WIN32_LONGPATHS)
-ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
+set(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/")
+set(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
+add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
+add_definitions(-DCLAR_WIN32_LONGPATHS)
+add_definitions(-D_FILE_OFFSET_BITS=64)
# Ensure that we do not use deprecated functions internally
-ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
+add_definitions(-DGIT_DEPRECATE_HARD)
-INCLUDE_DIRECTORIES(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
-FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
-SET(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c")
+include_directories(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
+file(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
+set(SRC_CLAR "main.c" "clar_libgit2.c" "clar_libgit2_trace.c" "clar_libgit2_timer.c" "clar.c")
-IF(MSVC_IDE)
- LIST(APPEND SRC_CLAR "precompiled.c")
-ENDIF()
+if(MSVC_IDE)
+ list(APPEND SRC_CLAR "precompiled.c")
+endif()
-ADD_CUSTOM_COMMAND(
+add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
DEPENDS ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH}
)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
-SET_SOURCE_FILES_PROPERTIES(
+set_source_files_properties(
${CLAR_PATH}/clar.c
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
-INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
-INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
+include_directories(${LIBGIT2_INCLUDES})
+include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
-ADD_EXECUTABLE(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
+add_executable(libgit2_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
-SET_TARGET_PROPERTIES(libgit2_tests PROPERTIES C_STANDARD 90)
-SET_TARGET_PROPERTIES(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
+set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-TARGET_INCLUDE_DIRECTORIES(libgit2_tests PRIVATE ../src PUBLIC ../include)
-TARGET_LINK_LIBRARIES(libgit2_tests ${LIBGIT2_LIBS})
-IDE_SPLIT_SOURCES(libgit2_tests)
+target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
+target_link_libraries(libgit2_tests ${LIBGIT2_LIBS})
+ide_split_sources(libgit2_tests)
-IF (MSVC_IDE)
+if(MSVC_IDE)
# Precompiled headers
- SET_TARGET_PROPERTIES(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
- SET_SOURCE_FILES_PROPERTIES("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
-ENDIF ()
+ set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
-FUNCTION(ADD_CLAR_TEST name)
- IF (NOT USE_LEAK_CHECKER STREQUAL "OFF")
- ADD_TEST(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN})
- ELSE()
- ADD_TEST(${name} "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN})
- ENDIF()
-ENDFUNCTION(ADD_CLAR_TEST)
+function(ADD_CLAR_TEST name)
+ if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
+ add_test(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN})
+ else()
+ add_test(${name} "${libgit2_BINARY_DIR}/libgit2_tests" ${ARGN})
+ endif()
+endfunction(ADD_CLAR_TEST)
-ADD_CLAR_TEST(offline -v -xonline)
-ADD_CLAR_TEST(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
-ADD_CLAR_TEST(online -v -sonline -xonline::customcert)
-ADD_CLAR_TEST(online_customcert -v -sonline::customcert)
-ADD_CLAR_TEST(gitdaemon -v -sonline::push)
-ADD_CLAR_TEST(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
-ADD_CLAR_TEST(proxy -v -sonline::clone::proxy)
-ADD_CLAR_TEST(auth_clone -v -sonline::clone::cred)
-ADD_CLAR_TEST(auth_clone_and_push -v -sonline::clone::push -sonline::push)
+add_clar_test(offline -v -xonline)
+add_clar_test(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root)
+add_clar_test(online -v -sonline -xonline::customcert)
+add_clar_test(online_customcert -v -sonline::customcert)
+add_clar_test(gitdaemon -v -sonline::push)
+add_clar_test(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths -sonline::clone::path_whitespace_ssh)
+add_clar_test(proxy -v -sonline::clone::proxy)
+add_clar_test(auth_clone -v -sonline::clone::cred)
+add_clar_test(auth_clone_and_push -v -sonline::clone::push -sonline::push)