[CMake] wrapper around real compiler

Tomasz Majchrowski usenet at majchrowski.de
Wed Mar 12 05:06:21 EDT 2014


Thank you Jakub for reply. The build environment is used by group of
colleges distributed across the glob. Therefore I would like to avoid new
rules
like enter new shell before build as this will change the way how they are
doing the daily job (means: cmake .. ; make ).  Since build with cmake
is two stage process, first cmake and second make, any shell variables set
in cmake call via:   set( ENV{PATH} ... will be lost in the context of make
process.

The working solution is to use wrapper which will get options without
quotation and pass to scl with using of quota. I will go with this option
if can't provide
quotation with using of CMAKE_C_COMPILE_OBJECT. The issue that i see right
now is that rule defined by CMAKE_C_COMPILE_OBJECT is lost in try_compile
call

Best regards, Tomasz Majchrowski.


2014-03-12 8:26 GMT+01:00 Jakub Zakrzewski <jzakrzewski at e2e.ch>:

> Hi.
> What scl enable devtoolset-2 does, is basically change the environment for
> the command. I use one of two techniques to make it working. When doing
> manual builds, I simply:
> scl enable devtoolset-2 bash
> And do everything from the new shell. On our CI, I put the following in
> build script (before calling cmake):
> . /opt/rh/devtoolset-2/enable
> As there is no magic but only environment variables involved, you can
> probably set them all using -DCMAKE_... options. Just look at the script
> and set, what you need.
> Remember, that devtoolset-2 is really just GNU Toolset in 4.8 version
> installed in non-standard location.
>
> --
> Gruesse,
> Jakub
>
>
>
>
>
> From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Tomasz
> Majchrowski
> Sent: Dienstag, 11. März 2014 19:44
> To: cmake at cmake.org
> Subject: [CMake] wrapper around real compiler
>
> Dear All,
> I found cmake provides many techniques to integrate tools like distcc,
> ccache into the build system. In particular variables like the following
> could be used:
>
> -D CMAKE_C_COMPILER="ccache" -D CMAKE_C_COMPILER_ARG1="gcc"
> The picture becomes more complicated when the tools around the real
> compiler requires "special" syntax. As an example the RedHat's scl is such
> a one as it's requires quotation of the complete compiler line:
>
>  scl enable devtoolset-2 'g++ -o output_file source_file...'
> Details:
> https://access.redhat.com/site/documentation/en-US/Red_Hat_Developer_Toolset/2/html/User_Guide/sect-GCC-CPP.html
>
> I was playing with build rules, however didn't success on try_compile
> which seems to ignore them.
>
> set ( CMAKE_C_COMPILE_OBJECT    "<CMAKE_C_COMPILER> enable devtoolset-2 '
> gcc <DEFINES> <FLAGS> -frandom-seed=<SOURCE>/ -o <OBJECT> -c <SOURCE>' ")
> The only working one that I found is to use small bash script which will
> act as yet another wrapper.
> Anyway this solution do not looks "elegant" and I would like to avoid.
>
>
> Can anyone suggest a good method how to cope with this issue ?
> --
> Pozdrawiam/Best regards/Mit freundlichen Grüßen, Tomasz Majchrowski,
> Information Technology and Services Consultant and Contractor
>
> --
> Pozdrawiam/Best regards/Mit freundlichen Grüßen, Tomasz Majchrowski,
> Information Technology and Services Consultant and Contractor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140312/9ef9060f/attachment.html>


More information about the CMake mailing list