diff --git a/Generator/Sources/SwiftWinRT/CMakeOptions.swift b/Generator/Sources/SwiftWinRT/CMakeOptions.swift new file mode 100644 index 0000000..7c2e0ec --- /dev/null +++ b/Generator/Sources/SwiftWinRT/CMakeOptions.swift @@ -0,0 +1,21 @@ +struct CMakeOptions { + public var dynamicLibraries: Bool + public var moduleTargetNameOverrides: [String: String] + + public func getTargetName(moduleName: String) -> String { + moduleTargetNameOverrides[moduleName] ?? moduleName + } + + public init?(commandLineArguments: CommandLineArguments, projectionConfig: ProjectionConfig) { + guard commandLineArguments.generateCMakeLists else { return nil } + + self.dynamicLibraries = commandLineArguments.dynamicLibraries + + self.moduleTargetNameOverrides = .init() + for (moduleName, moduleConfig) in projectionConfig.modules { + if let targetName = moduleConfig.cmakeTargetName { + self.moduleTargetNameOverrides[moduleName] = targetName + } + } + } +} \ No newline at end of file diff --git a/Generator/Sources/SwiftWinRT/BuildSystemOptions.swift b/Generator/Sources/SwiftWinRT/SPMOptions.swift similarity index 57% rename from Generator/Sources/SwiftWinRT/BuildSystemOptions.swift rename to Generator/Sources/SwiftWinRT/SPMOptions.swift index 17e371b..8d343de 100644 --- a/Generator/Sources/SwiftWinRT/BuildSystemOptions.swift +++ b/Generator/Sources/SwiftWinRT/SPMOptions.swift @@ -1,47 +1,25 @@ -struct SPMOptions { - public var supportPackageReference: String - public var dynamicLibraries: Bool - public var excludeCMakeLists: Bool - public var moduleLibraryNameOverrides: [String: String] - - public func getLibraryName(moduleName: String) -> String { - moduleLibraryNameOverrides[moduleName] ?? moduleName - } - - public init?(commandLineArguments: CommandLineArguments, projectionConfig: ProjectionConfig) { - guard commandLineArguments.generatePackageDotSwift else { return nil } - - self.supportPackageReference = commandLineArguments.spmSupportPackageReference - self.dynamicLibraries = commandLineArguments.dynamicLibraries - self.excludeCMakeLists = !commandLineArguments.generateCMakeLists - - self.moduleLibraryNameOverrides = .init() - for (moduleName, moduleConfig) in projectionConfig.modules { - if let libraryName = moduleConfig.spmLibraryName { - self.moduleLibraryNameOverrides[moduleName] = libraryName - } - } - } -} - -struct CMakeOptions { - public var dynamicLibraries: Bool - public var moduleTargetNameOverrides: [String: String] - - public func getTargetName(moduleName: String) -> String { - moduleTargetNameOverrides[moduleName] ?? moduleName - } - - public init?(commandLineArguments: CommandLineArguments, projectionConfig: ProjectionConfig) { - guard commandLineArguments.generateCMakeLists else { return nil } - - self.dynamicLibraries = commandLineArguments.dynamicLibraries - - self.moduleTargetNameOverrides = .init() - for (moduleName, moduleConfig) in projectionConfig.modules { - if let targetName = moduleConfig.cmakeTargetName { - self.moduleTargetNameOverrides[moduleName] = targetName - } - } - } -} \ No newline at end of file +struct SPMOptions { + public var supportPackageReference: String + public var dynamicLibraries: Bool + public var excludeCMakeLists: Bool + public var moduleLibraryNameOverrides: [String: String] + + public func getLibraryName(moduleName: String) -> String { + moduleLibraryNameOverrides[moduleName] ?? moduleName + } + + public init?(commandLineArguments: CommandLineArguments, projectionConfig: ProjectionConfig) { + guard commandLineArguments.generatePackageDotSwift else { return nil } + + self.supportPackageReference = commandLineArguments.spmSupportPackageReference + self.dynamicLibraries = commandLineArguments.dynamicLibraries + self.excludeCMakeLists = !commandLineArguments.generateCMakeLists + + self.moduleLibraryNameOverrides = .init() + for (moduleName, moduleConfig) in projectionConfig.modules { + if let libraryName = moduleConfig.spmLibraryName { + self.moduleLibraryNameOverrides[moduleName] = libraryName + } + } + } +} diff --git a/Generator/Sources/SwiftWinRT/Writing/ABIModule.swift b/Generator/Sources/SwiftWinRT/Writing/ABIModule.swift index 174407d..f3229f9 100644 --- a/Generator/Sources/SwiftWinRT/Writing/ABIModule.swift +++ b/Generator/Sources/SwiftWinRT/Writing/ABIModule.swift @@ -19,12 +19,6 @@ internal func writeABIModule(_ module: Module, cmakeOptions: CMakeOptions?, dire cmakeListsWriter.writeAddLibrary(targetName, .interface) cmakeListsWriter.writeTargetIncludeDirectories(targetName, .interface, ["include"]) - if targetName != module.abiModuleName { - cmakeListsWriter.writeSingleLineCommand( - "set_target_properties", .autoquote(targetName), - "PROPERTIES", "Swift_MODULE_NAME", .autoquote(module.abiModuleName)) - } - var linkLibraries = [ SupportModules.WinRT.abiModuleName ] for reference in module.references { guard !reference.isEmpty else { continue }