| ... | @@ -552,6 +552,7 @@ fn addCmakeCfgOptionsToExe( | ... | @@ -552,6 +552,7 @@ fn addCmakeCfgOptionsToExe( |
| 552 | addCMakeLibraryList(exe, cfg.clang_libraries); | 552 | addCMakeLibraryList(exe, cfg.clang_libraries); |
| 553 | addCMakeLibraryList(exe, cfg.lld_libraries); | 553 | addCMakeLibraryList(exe, cfg.lld_libraries); |
| 554 | addCMakeLibraryList(exe, cfg.llvm_libraries); | 554 | addCMakeLibraryList(exe, cfg.llvm_libraries); |
| | 555 | addCMakeSystemLibraryList(exe, cfg.llvm_system_libraries); |
| 555 | | 556 | |
| 556 | if (use_zig_libcxx) { | 557 | if (use_zig_libcxx) { |
| 557 | exe.linkLibCpp(); | 558 | exe.linkLibCpp(); |
| ... | @@ -679,6 +680,23 @@ fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void { | ... | @@ -679,6 +680,23 @@ fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void { |
| 679 | } | 680 | } |
| 680 | } | 681 | } |
| 681 | | 682 | |
| | 683 | fn addCMakeSystemLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void { |
| | 684 | var it = mem.tokenize(u8, list, ";"); |
| | 685 | while (it.next()) |lib| { |
| | 686 | var start_offset: usize = 0; |
| | 687 | var end_offset: usize = 0; |
| | 688 | if (mem.startsWith(u8, lib, "-l")) { |
| | 689 | start_offset = "-l".len; |
| | 690 | } |
| | 691 | |
| | 692 | if (exe.target.isWindows() and mem.endsWith(u8, lib, ".lib")) { |
| | 693 | end_offset = ".lib".len; |
| | 694 | } |
| | 695 | |
| | 696 | exe.linkSystemLibrary(lib[start_offset..lib.len - end_offset]); |
| | 697 | } |
| | 698 | } |
| | 699 | |
| 682 | const CMakeConfig = struct { | 700 | const CMakeConfig = struct { |
| 683 | llvm_linkage: std.build.LibExeObjStep.Linkage, | 701 | llvm_linkage: std.build.LibExeObjStep.Linkage, |
| 684 | cmake_binary_dir: []const u8, | 702 | cmake_binary_dir: []const u8, |
| ... | @@ -692,6 +710,7 @@ const CMakeConfig = struct { | ... | @@ -692,6 +710,7 @@ const CMakeConfig = struct { |
| 692 | llvm_lib_dir: []const u8, | 710 | llvm_lib_dir: []const u8, |
| 693 | llvm_include_dir: []const u8, | 711 | llvm_include_dir: []const u8, |
| 694 | llvm_libraries: []const u8, | 712 | llvm_libraries: []const u8, |
| | 713 | llvm_system_libraries: []const u8, |
| 695 | dia_guids_lib: []const u8, | 714 | dia_guids_lib: []const u8, |
| 696 | }; | 715 | }; |
| 697 | | 716 | |
| ... | @@ -757,6 +776,7 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig { | ... | @@ -757,6 +776,7 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig { |
| 757 | .llvm_lib_dir = undefined, | 776 | .llvm_lib_dir = undefined, |
| 758 | .llvm_include_dir = undefined, | 777 | .llvm_include_dir = undefined, |
| 759 | .llvm_libraries = undefined, | 778 | .llvm_libraries = undefined, |
| | 779 | .llvm_system_libraries = undefined, |
| 760 | .dia_guids_lib = undefined, | 780 | .dia_guids_lib = undefined, |
| 761 | }; | 781 | }; |
| 762 | | 782 | |
| ... | @@ -797,6 +817,10 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig { | ... | @@ -797,6 +817,10 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig { |
| 797 | .prefix = "#define ZIG_LLVM_LIBRARIES ", | 817 | .prefix = "#define ZIG_LLVM_LIBRARIES ", |
| 798 | .field = "llvm_libraries", | 818 | .field = "llvm_libraries", |
| 799 | }, | 819 | }, |
| | 820 | .{ |
| | 821 | .prefix = "#define ZIG_LLVM_SYSTEM_LIBRARIES ", |
| | 822 | .field = "llvm_system_libraries", |
| | 823 | }, |
| 800 | .{ | 824 | .{ |
| 801 | .prefix = "#define ZIG_DIA_GUIDS_LIB ", | 825 | .prefix = "#define ZIG_DIA_GUIDS_LIB ", |
| 802 | .field = "dia_guids_lib", | 826 | .field = "dia_guids_lib", |