Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Ceresoli <list@lucaceresoli.net>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 4/5] Enable ccache for cmake packages
Date: Fri, 22 Mar 2013 23:41:34 +0100	[thread overview]
Message-ID: <514CDE1E.8040107@lucaceresoli.net> (raw)
In-Reply-To: <CAHXCMMJcUDVKP38GZ_-roGCfuTrCLyxUJRqGh1HC-Fe5yRakkQ@mail.gmail.com>

Samuel Martin wrote:
> Lucas,
>
> 2013/3/22 Luca Ceresoli <luca@lucaceresoli.net>:
>> Samuel Martin wrote:
>>> Hi Lucas,
>>>
>>> 2013/3/21 Luca Ceresoli <luca@lucaceresoli.net>:
> [...]
>>> AFAIK, ccache only supports C, C++, Objective-C and Objective-C++.
>>> So, I think, it is useless to set it for anything else.
>>
>> Ouch, right!
>> The fix is as easy as:
>>>      set(CMAKE_ASM_COMPILER $(TARGET_CC_NOCCACHE))\n\
>> Now when ccache is enabled it all works OK.
>>
>>
>>> BTW, I also use to set most of the binutils/gcc binaries in my CMake
>>> toolchain files,
>>> this includes setting the following variables:
>>> CMAKE_{LINKER,AR,RANDLIB,NM,OBJCOPY,OBJDUMP,STRIP}.
>>>
>>> So, IMHO, it is not stupid to set CMAKE_ASM_COMPILER as well, though I
>>> never need it so far.
>>>
>>> [...]
>>>> Now it compiles correctly but with two bad side effects.
>>>>
>>>> First, when building without ccache, CMake detects /usr/bin/cc as the
>>>> (supposedly cross-) compiler, leading to an obvious link failure.
>>>> Ok, this can be worked around by generating a different
>>>> toolchainfile.cmake for the ccache and non-ccache cases, although it
>>>> is annoying.
>>> Well, here I use to conditionnaly enable ccache if found using
>>> something like this:
>>>
>>> --
>>> find_program(CCACHE "ccache")
>>> if (CCACHE)
>>>     message( STATUS "Using ccache")
>>> endif(CCACHE)
>>>
>>> if (CCACHE AND NOT FORCE_NO_CCACHE)
>>>     set(CMAKE_C_COMPILER "${CCACHE}" CACHE FILEPATH "" FORCE)
>>>     set(CMAKE_CXX_COMPILER "${CCACHE}" CACHE FILEPATH "" FORCE)
>>>     set(CMAKE_C_COMPILER_ARG1 "${HOST_DIR}/usr/bin/${TARGET_TUPLE}-gcc")
>>>     set(CMAKE_CXX_COMPILER_ARG1 "${HOST_DIR}/usr/bin/${TARGET_TUPLE}-g++")
>>> else(CCACHE AND NOT FORCE_NO_CCACHE)
>>>     set(CMAKE_C_COMPILER "${HOST_DIR}/usr/bin/${TARGET_TUPLE}-gcc")
>>>     set(CMAKE_CXX_COMPILER "${HOST_DIR}/usr/bin/${TARGET_TUPLE}-g++")
>>> endif(CCACHE AND NOT FORCE_NO_CCACHE)
>>> --
>>
>> I'm not following you here. This would require patching the
>> CMakeLists.txt file for every CMake package, right?
> Nope, just the toolchainfile.cmake.
> And when ccache is disabled, we can just force it by setting
> FORCE_NO_CCACHE in the CMake infra.

Ahh, now I got you idea! Thanks!

I worked on it, and although it was a bit tricky (probably because of my
limited experience with CMake) it seems to be working.
Even if it is not yet fully tested, I'm submitting a v2 patch now to let you
have a preliminary look at this work.

Luca

  reply	other threads:[~2013-03-22 22:41 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 17:14 [Buildroot] [PATCH 0/5] CMake packages improvements Luca Ceresoli
2013-03-06 17:14 ` [Buildroot] [PATCH 1/5] cmake: convert spaces to tabs in make rules Luca Ceresoli
2013-03-06 17:53   ` Thomas Petazzoni
2013-03-10 20:27   ` Peter Korsgaard
2013-03-06 17:14 ` [Buildroot] [PATCH 2/5] cmake: remove target package macro (not really implemented) Luca Ceresoli
2013-03-06 17:56   ` Thomas Petazzoni
2013-03-07 16:57     ` [Buildroot] [PATCH v2 2/5] cmake: remove target package macro Luca Ceresoli
2013-03-10 20:28       ` Peter Korsgaard
2013-03-06 17:14 ` [Buildroot] [PATCH 3/5] cmake: bump to 2.8.10.2 Luca Ceresoli
2013-03-10 20:28   ` Peter Korsgaard
2013-03-06 17:14 ` [Buildroot] [PATCH 4/5] Enable ccache for cmake packages Luca Ceresoli
2013-03-06 18:59   ` Thomas Petazzoni
2013-03-12 21:40     ` Arnout Vandecappelle
2013-03-06 19:02   ` Samuel Martin
2013-03-06 19:52     ` Peter Korsgaard
2013-03-10 20:29     ` Peter Korsgaard
2013-03-12  7:38       ` Luca Ceresoli
2013-03-20 17:15     ` Luca Ceresoli
2013-03-21 22:29       ` Luca Ceresoli
2013-03-22  8:33         ` Samuel Martin
2013-03-22  9:40           ` Luca Ceresoli
2013-03-22 10:08             ` Samuel Martin
2013-03-22 22:41               ` Luca Ceresoli [this message]
2013-03-22 22:55                 ` [Buildroot] [PATCH v2] " Luca Ceresoli
2013-03-23  0:03                   ` Samuel Martin
2013-03-23 15:29                     ` Thomas Petazzoni
2013-03-23 17:32                       ` Samuel Martin
2013-03-28 22:21                         ` Luca Ceresoli
2013-03-29 13:08                           ` Samuel Martin
2013-03-06 17:14 ` [Buildroot] [PATCH 5/5] CMake packages: remove .cmake files from target directory Luca Ceresoli
2013-03-10 20:30   ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=514CDE1E.8040107@lucaceresoli.net \
    --to=list@lucaceresoli.net \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox