mirror of
https://github.com/GayPizzaSpecifications/cxx-swift-interop.git
synced 2025-08-03 21:21:32 +00:00
initial commit
This commit is contained in:
2
Sources/CMakeLists.txt
Normal file
2
Sources/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_subdirectory(SwiftFrontend)
|
||||
add_subdirectory(CppBackend)
|
4
Sources/CppBackend/CMakeLists.txt
Normal file
4
Sources/CppBackend/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
add_library(CppBackend STATIC backend.h backend.cpp)
|
||||
|
||||
set_target_properties(CppBackend PROPERTIES Swift_MODULE_NAME "CppBackend")
|
||||
target_compile_options(CppBackend PUBLIC "$<$<COMPILE_LANGUAGE:Swift>:-cxx-interoperability-mode=default>")
|
7
Sources/CppBackend/backend.cpp
Normal file
7
Sources/CppBackend/backend.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "backend.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void backend_init() {
|
||||
std::cout << "Hello World" << std::endl;
|
||||
}
|
3
Sources/CppBackend/backend.h
Normal file
3
Sources/CppBackend/backend.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void backend_init();
|
3
Sources/CppBackend/module.modulemap
Normal file
3
Sources/CppBackend/module.modulemap
Normal file
@ -0,0 +1,3 @@
|
||||
module CppBackend {
|
||||
header "backend.h"
|
||||
}
|
2
Sources/SwiftFrontend/CMakeLists.txt
Normal file
2
Sources/SwiftFrontend/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_executable(SwiftFrontend main.swift)
|
||||
target_link_libraries(SwiftFrontend PRIVATE CppBackend)
|
4
Sources/SwiftFrontend/main.swift
Normal file
4
Sources/SwiftFrontend/main.swift
Normal file
@ -0,0 +1,4 @@
|
||||
import CppBackend
|
||||
|
||||
backend_init()
|
||||
print("Hello World")
|
Reference in New Issue
Block a user