Skip to content

Commit 9627018

Browse files
committed
build: obtain zigcpp library prefix/suffix from cmake
1 parent eb4337f commit 9627018

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

build.zig

+17-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,11 @@ fn addCmakeCfgOptionsToExe(
537537
exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
538538
cfg.cmake_binary_dir,
539539
"zigcpp",
540-
b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }),
540+
b.fmt("{s}{s}{s}", .{
541+
cfg.cmake_static_library_prefix,
542+
"zigcpp",
543+
cfg.cmake_static_library_suffix,
544+
}),
541545
}) catch unreachable);
542546
assert(cfg.lld_include_dir.len != 0);
543547
exe.addIncludePath(cfg.lld_include_dir);
@@ -669,6 +673,8 @@ const CMakeConfig = struct {
669673
llvm_linkage: std.build.LibExeObjStep.Linkage,
670674
cmake_binary_dir: []const u8,
671675
cmake_prefix_path: []const u8,
676+
cmake_static_library_prefix: []const u8,
677+
cmake_static_library_suffix: []const u8,
672678
cxx_compiler: []const u8,
673679
lld_include_dir: []const u8,
674680
lld_libraries: []const u8,
@@ -732,6 +738,8 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
732738
.llvm_linkage = undefined,
733739
.cmake_binary_dir = undefined,
734740
.cmake_prefix_path = undefined,
741+
.cmake_static_library_prefix = undefined,
742+
.cmake_static_library_suffix = undefined,
735743
.cxx_compiler = undefined,
736744
.lld_include_dir = undefined,
737745
.lld_libraries = undefined,
@@ -751,6 +759,14 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
751759
.prefix = "#define ZIG_CMAKE_PREFIX_PATH ",
752760
.field = "cmake_prefix_path",
753761
},
762+
.{
763+
.prefix = "#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX ",
764+
.field = "cmake_static_library_prefix",
765+
},
766+
.{
767+
.prefix = "#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX ",
768+
.field = "cmake_static_library_suffix",
769+
},
754770
.{
755771
.prefix = "#define ZIG_CXX_COMPILER ",
756772
.field = "cxx_compiler",

stage1/config.h.in

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
#define ZIG_VERSION_STRING "@ZIG_VERSION@"
1616

1717
// Used by build.zig for communicating build information to self hosted build.
18+
#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
1819
#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"
19-
#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"
2020
#define ZIG_CMAKE_PREFIX_PATH "@ZIG_CMAKE_PREFIX_PATH@"
21+
#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX "@CMAKE_STATIC_LIBRARY_PREFIX@"
22+
#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX "@CMAKE_STATIC_LIBRARY_SUFFIX@"
2123
#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
24+
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
2225
#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
2326
#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
24-
#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
2527
#define ZIG_LLVM_INCLUDE_PATH "@LLVM_INCLUDE_DIRS@"
26-
#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
2728
#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"
28-
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
29+
#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
30+
#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"
2931

3032
#endif

0 commit comments

Comments
 (0)