Skip to content

Commit

Permalink
Fix incorrect CMakeLists.txt codegen (#282)
Browse files Browse the repository at this point in the history
Some keywords must be UPPERCASE.
  • Loading branch information
tristanlabelle authored Sep 13, 2024
1 parent ddb074c commit a927507
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Generator/Sources/CodeWriters/CMake/CMakeListsWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public final class CMakeListsWriter {
}

public func writeAddLibrary(_ name: String, _ type: CMakeLibraryType? = nil, _ sources: [String] = []) {
let typeSuffix = type.map { " \($0)" } ?? ""
let typeSuffix = type.map { " \($0.rawValue)" } ?? ""
output.writeIndentedBlock(grouping: .never, header: "add_library(\(name)\(typeSuffix)", footer: ")") {
for source in sources {
output.writeFullLine(source)
Expand All @@ -16,7 +16,7 @@ public final class CMakeListsWriter {

public func writeTargetIncludeDirectories(_ target: String, _ visibility: CMakeVisibility, _ directories: [String]) {
guard !directories.isEmpty else { return }
output.writeIndentedBlock(grouping: .never, header: "target_include_directories(\(target) \(visibility)", footer: ")") {
output.writeIndentedBlock(grouping: .never, header: "target_include_directories(\(target) \(visibility.rawValue)", footer: ")") {
for directory in directories {
output.writeFullLine(directory)
}
Expand All @@ -25,14 +25,14 @@ public final class CMakeListsWriter {

public func writeTargetLinkLibraries(_ target: String, _ visibility: CMakeVisibility, _ libraries: [String]) {
guard !libraries.isEmpty else { return }
output.writeIndentedBlock(grouping: .never, header: "target_link_libraries(\(target) \(visibility)", footer: ")") {
output.writeIndentedBlock(grouping: .never, header: "target_link_libraries(\(target) \(visibility.rawValue)", footer: ")") {
for library in libraries {
output.writeFullLine(library)
}
}
}

public func writeAddSubdirectory(_ subdirectory: String) {
output.writeFullLine(grouping: .withName("add_subdirectory"), "add_subdirectory(\(subdirectory))")
public func writeAddSubdirectory(_ sources: String) {
output.writeFullLine(grouping: .withName("add_subdirectory"), "add_subdirectory(\(sources))")
}
}
4 changes: 2 additions & 2 deletions Generator/Sources/SwiftWinRT/Writing/ABIModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ internal func writeABIModule(_ module: SwiftProjection.Module, directoryPath: St
let cmakeListsWriter = CMakeListsWriter(output: FileTextOutputStream(
path: "\(directoryPath)\\CMakeLists.txt", directoryCreation: .ancestors))
cmakeListsWriter.writeAddLibrary(module.abiModuleName, .interface)
cmakeListsWriter.writeTargetIncludeDirectories(module.abiModuleName, .public, ["include"])
cmakeListsWriter.writeTargetLinkLibraries(module.abiModuleName, .public,
cmakeListsWriter.writeTargetIncludeDirectories(module.abiModuleName, .interface, ["include"])
cmakeListsWriter.writeTargetLinkLibraries(module.abiModuleName, .interface,
[ SupportModules.WinRT.abiModuleName ] + module.references.map { $0.abiModuleName })
}
}
Expand Down

0 comments on commit a927507

Please sign in to comment.