I am working on a mixed-language C++/Swift Project and I want to use a package (Vapor) from SPM. Since this is a mixed-language project, I am currently using cmake for the build process. Thus my question: How can I include Vapor inside the cmake project so that it is a dependeny for the swift target there?
Thanks in advance
PS: I tried switching just using a Package.swift to build my project with SPM, but that does not really work for the C++ part. Would love it, though.
Package.swift with local binary target for the c++ part, cmake builds the binary then calls swift build.
Or if separate people will be working on the c++ and swift parts then separate repos and then the swift part can just use spm and download the prebuilt binary.
If your project is similar to the one I worked on, as in 50MB lib and 1.5GB dsym per platform for the c++ part, you might want an option to only download the lib for development. (Assuming multiple releases of the C++ lib per week)
find_program(SWIFT NAMES "swift")
find_program(CLANG NAMES "clang") # I am using GCC, which does not work for some swift packages
find_program(CLANGXX NAMES "clang++")
COMMAND
"CC=${CLANG}" "CXX=${CLANGXX}"
${SWIFT} "build"
--package-path ${CMAKE_CURRENT_SOURCE_DIR}
-I${CMAKE_CURRENT_BINARY_DIR}/<name>
-L${CMAKE_CURRENT_BINARY_DIR}/<name>
--configuration debug
)
add_dependencies(SwiftPackage ${TARGETS})
which results in an error saying that cmake does not find config? error: Missing value for '-c <configuration>'
(This seems strange, since I've added the configuration flag alright)
So that the it is clear that which option is for which compiler/linker.
-Xcc Pass flag through to all C compiler invocations
-Xswiftc Pass flag through to all Swift compiler invocations
-Xlinker Pass flag through to all linker invocations
-Xcxx Pass flag through to all C++ compiler invocations