[Buildroot] Make C and CXX compiler cache in toolchainfile.cmake.in

Samuel Martin s.martin49 at gmail.com
Sun Apr 8 19:53:14 UTC 2018


Hi all,

Apologies for the late response.

On Mon, Apr 2, 2018 at 9:12 AM, Luca Ceresoli <luca at lucaceresoli.net> wrote:
> Hi,
>
> On 30/03/2018 21:57, Arnout Vandecappelle wrote:
>>
>>
>> On 25-03-18 12:36, Michael Dick wrote:
>>> Hello,
>>>
>>> I am using buildroot to create my custom gcc toolchain and sysroot for a
>>> raspberry pi.
>>>
>>>
>>>
>>> Therefore, I call cmake with a script to configure my project. After that, I
>>> import the project into qtcreator.
>>>
>>> The problem is, that C and CXX compiler variables are not cached into cmake
>>> cache, so when importing the project, qtcreator calling cmake is not aware oft
>>> he configured compiler.
>>>
>>>
>>>
>>> My suggestion ist o use this patch. Is there any reason why the compilers are
>>> not cached?
>>
>>  Sounds to me like a good idea.
>>
>>  Let's add Yann, Samuel and Luca in Cc as CMake experts :-P For their
>> convenience, here is the patch inline:
>>
>>> --- /tmp/toolchainfile.cmake.in.orig    2018-03-25 12:32:03.353000419 +0200
>>> +++ /tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200
>>> @@ -58,8 +58,8 @@
>>>  set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
>>>
>>>  # This toolchain file can be used both inside and outside Buildroot.
>>> -set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
>>> -set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
>>> +set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@" CACHE STRING "C Compiler")
>>> +set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@" CACHE STRING "CXX Compiler")
>
> Although my cmake wisdom is definitely overrated here, I *do* have a
> kind of clue of what this means! :-)
>
> I think this change makes sense, and this is confirmed by the fact that
> CMake does it as well by default. I tested with a minimal project:

I second, I even wonder why I did not add it for the complers paths in
the first place whereas I did add it to the various compiler flags
variables... :-/

>
> $ cat CMakeLists.txt
> cmake_minimum_required(VERSION 2.6)
> project(hello)
> add_executable(hello hello.c utils.c)
> $ cmake .
> [...]
> $ grep COMPILER CMakeCache.txt
> CMAKE_CXX_COMPILER:FILEPATH=/usr/lib/ccache/c++
> CMAKE_C_COMPILER:FILEPATH=/usr/lib/ccache/cc
> [...]
> $
>
>>>  if(@@TOOLCHAIN_HAS_FORTRAN@@)
>>>    set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
>>>    set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")
>>
>>
>>  Michael, could you resubmit as a proper patch with commit log and
>> Signed-off-by? See [1].
>
> And keep me Cc:.
>
> Bye,
> --
> Luca
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

Regards,

-- 
Samuel



More information about the buildroot mailing list