[cmake-developers] Adding Swift support to CMake for Linux/Makefiles

Brad King brad.king at kitware.com
Mon Feb 29 10:23:27 EST 2016


On 02/29/2016 06:59 AM, Eric Wing wrote:
> I see in the CMakeSwiftInformation.cmake, there is a
> <CMAKE_Swift_LINK_FLAGS>. However, I do not see a <CMAKE_Swift_FLAGS>,
> just <FLAGS>.

That <FLAGS> is implicitly the flags for the corresponding language
since it appears in the compilation rule specific to the language.

> Additionally, in regular CMake script, I was trying to set/use
> ${CMAKE_Swift_FLAGS} hoping it would just work, but it doesn't seem to
> have any effect. Is this something I'm going to have to implement in
> the C++ core?

For the Makefile generator take a look at

 cmMakefileTargetGenerator::WriteTargetLanguageFlags
 cmMakefileTargetGenerator::WriteObjectBuildFile

methods.  They generate a <LANG>_FLAGS variable in the makefile and
reference it.  Make sure those code paths are executed for Swift.
There should be similar code for the Ninja generator too.

-Brad



More information about the cmake-developers mailing list