[CMake] How can I programmatically configure compiler for CMake via Python on Windows?

Mark Roden mmroden at gmail.com
Thu Apr 4 13:17:08 EDT 2013


Hi all,

I've posted this question here:

http://stackoverflow.com/questions/15804525/how-can-i-programmatically-configure-compiler-for-cmake-via-python-on-windows/15815937

The question is:

I have a python build script I'm using to build a number of projects that
are configured via CMake on windows. Previously, we used MSVC to build
these projects, and everything was fine. I want to try to incorporate ICC
into the build now, via these python scripts. I can choose the native
compiler directly in the UI if necessary, but I'd rather do everything
programmatically.

Problem is, it's failing with either syntax errors, or just not paying
attention to the cmake options.

I can set:

"CMAKE_CXX_COMPILER:PATH":"C:/Program Files (x86)/Intel/Composer XE
2013/bin/intel64/icl.exe",
"CMAKE_C_COMPILER:PATH":"C:/Program Files (x86)/Intel/Composer XE
2013/bin/intel64/icl.exe"

And that's part of a cmakeItems array that's then fed into the generation:

generate(x86Generator, cmakeItems, osName, buildTarget)

where the other options are set via command line switches (for x86generator
 and buildTarget) or by default (ie, osName is detected in the script
itself).

Before trying anything, I'm running this from a command line prompt where
I've run

iclvars intel64

in the icc bin directory to ensure that all of the icc variables are
properly configured, and I can type icl on the command line and confirm
that it's in the path.

Running the above means that the C compiler remains the default msvc
compiler.

I've also tried running:

set(CMAKE_C_COMPILER_INIT icl)
set(CMAKE_CXX_COMPILER_INIT icl)

but that's giving me a syntax error on the icl portion. I thought that
maybe it's a path issue, but doing:

set(CMAKE_C_COMPILER_INIT "C:\Program Files (x86)\Intel\Composer XE
2013\bin\intel64\icl")
set(CMAKE_CXX_COMPILER_INIT "C:\Program Files (x86)\Intel\Composer XE
2013\bin\intel64\icl")

is also giving me a syntax error.

So how can I programmatically set the C/CXX compiler from a python script
calling cmake?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130404/a16ea2d7/attachment.htm>


More information about the CMake mailing list