Comments (8)
In what sense? Do you mean using a C library with a Swift binary? If so, yes, there is an example in this repository for that. https://github.com/compnerd/swift-build-examples/tree/master/HelloWorld-CMake
The inverse is a bit trickier. If you want to integrate a swift library into a C binary, you will need to do the additional work to link in the swift runtime and the startup object as well. In general, treating the binary as a Swift binary is going to be way easier.
from swift-cmake-examples.
Pardon me if I missed something, but going through that I couldn't find anywhere the CCore library was used within swift... it seemed to just demonstrate that both swift and C could be used within the same CMake project, without demonstrating actual bridging.
from swift-cmake-examples.
This seems like what #9 was looking for... the repo doesn't currently demonstrate linking between languages. That's fine, I'm just wondering if it is possible, i.e. with target_link_libraries
from swift-cmake-examples.
Ah, I see. That should be easy to rectify and improve. Feel free to put up a PR for that. Yes, it is possible in both directions, however, if you want to use target_link_libraries
to do it easily, the target binary must be Swift.
from swift-cmake-examples.
#19 should be the example that you are looking for.
from swift-cmake-examples.
Thank you for implementing that example! I also saw some code that makes use of module maps, if I can get that working I might submit a PR for that as an alternate solution
from swift-cmake-examples.
You're welcome @atyshka. Sorry, I didn't realize that it was missing in the first place. Improvements to the examples would be fantastic!
from swift-cmake-examples.
Hm... Looks like your latest commits for this broke the tests for me. Rewinding before them, the test passes just fine.
`[0/1] Running tests...
Test project /home/alex/source-software/swift-build-examples/HelloWorld-CMake/build
Start 1: TestHelloWorldCore
1/1 Test #1: TestHelloWorldCore ...............***Failed 0.00 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.00 sec
The following tests FAILED:
1 - TestHelloWorldCore (Failed)
Errors while running CTest
FAILED: CMakeFiles/test.util
cd /home/alex/source-software/swift-build-examples/HelloWorld-CMake/build && /usr/bin/ctest --force-new-ctest-process
ninja: build stopped: subcommand failed.`
from swift-cmake-examples.
Related Issues (15)
- Build failure using Ninja generator HOT 4
- CMAKE_Swift_COMPILER HOT 7
- Cmake with packages HOT 3
- Build failure: unknown argument: '-static' HOT 2
- Failing to build on Windows HOT 6
- Support for use with XCode? HOT 1
- Cmake and Ninja Error on Windows HOT 10
- Build HelloWorld and HelloMini failed HOT 6
- CMake problem when building HelloWorld project HOT 9
- Failed to compile HelloWorld HOT 7
- `aux_source_directory ` can't find *.swift sources HOT 2
- Test fails HOT 2
- Problems while using on macOS HOT 1
- CCore is useless HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-cmake-examples.