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

Brad King brad.king at kitware.com
Wed Jan 20 10:15:39 EST 2016


On 01/20/2016 08:48 AM, Eric Wing wrote:
> I thought maybe setting the internal
> CMAKE_${lang}_COMPILER_ID_FLAGS_LIST or
> CMAKE_${lang}_COMPILER_ID_FLAGS
> to "-version" would fix this.
> 
> But this did nothing.

Those are internal details of the CMAKE_DETERMINE_COMPILER_ID
function and are not meant to be set anywhere else.  I think you
may be looking for something like this:

 https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeDetermineFortranCompiler.cmake;hb=v3.4.2#l122

It is used by the CMAKE_DETERMINE_COMPILER_ID_VENDOR fallback when
the compiler id cannot be extracted from the basic compiler output.
More work may be needed to also extract a version number through
the CMAKE_DETERMINE_COMPILER_ID_VENDOR infrastructure.

> it looks like somehow I already have $ENV{SWIFTFLAGS} set to
> CMAKE_Swift_FLAGS_INIT in CMakeSwiftInformation.cmake. (Either you did
> it, or it was copy/paste/substitute from C.)

It looks like it came from your port from CMakeCInformation.  The

 set(CMAKE_Swift_FLAGS_INIT "$ENV{SWIFTFLAGS} ${CMAKE_Swift_FLAGS_INIT}")

line looks correct.

> So I can do this in my shell:
> export SWIFTFLAGS='-target armv7-unknown-linux-gnueabihf'
> 
> And CMake picks it up. Is this the correct expected behavior for CMake?

Yes.  One remaining question is if there is an established convention
already out there for the name of the SWIFTFLAGS environment variable.

-Brad



More information about the cmake-developers mailing list