View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015354CMakeCMakepublic2015-01-14 18:092015-06-01 08:38
ReporterTom Hughes 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformMacOSOSXOS Version10.10.1
Product VersionCMake 3.1 
Target VersionFixed in Version 
Summary0015354: regression: ccache no longer works with cmake 3.1.0
DescriptionBetween cmake 3.0.2 and 3.1.0, ccache (v3.2.1) stopped working (I'm using the ninja generator). I had been using ccache by setting CMAKE_C_COMPILER to ccache and CMAKE_C_COMPILER_ARG1 to clang.

In the original project where I hit this, the error occurs during the first run of cmake when it decides that it needs to re-run configure:

-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/local/bin/ccache
CMAKE_CXX_COMPILER= /usr/local/bin/ccache
CMAKE_C_COMPILER= /usr/local/bin/ccache
CMAKE_CXX_COMPILER= /usr/local/bin/ccache

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- broken

However, in the simple test case that I created, it doesn't occur until you touch the CMakeLists.txt and re-run ninja (see attachments).
Steps To ReproduceI have a simple test case that reproduces the problem and a script that you can use with "git bisect run" (attached as find-cmake-bug.sh).

That points to the following commit:

commit 6120fca8e229da08fae1d58017962491fb6e03f3
Author: Sylvain Joubert <joubert.sy@gmail.com>
Date: Sat Sep 20 22:37:52 2014 +0200

    Ninja: Prevent compilers to be silently modified

    Unlike with Unix Makefiles generator modifying compiler paths was not
    protected with Ninja generator. It was possible to modify them in the
    cache without the expected effect on the generated solution. Also
    activate corresponding tests with Ninja.
TagsNo tags attached.
Attached Filesgz file icon cmake-ccache-bug.tar.gz [^] (859 bytes) 2015-01-14 18:09

 Relationships

  Notes
(0037696)
Brad King (manager)
2015-01-15 08:32

From the example:

 $ cat CMakeLists.txt
 set(CMAKE_C_COMPILER_ARG1 "/usr/bin/clang" CACHE INTERNAL "")
 set(CMAKE_C_COMPILER "/usr/local/bin/ccache" CACHE INTERNAL "")
 ...

Setting the compiler like this in CMakeLists.txt is not supported. It should be done on the command-line:

 CC='/usr/local/bin/ccache /usr/bin/clang' cmake .. -GNinja

or:

 cmake .. -GNinja -DCMAKE_C_COMPILER=/usr/local/bin/ccache -DCMAKE_C_COMPILER_ARG1=/usr/bin/clang

Although not officially supported, one can also set it in the CMakeLists.txt file before an explicit project command call:

 $ cat CMakeLists.txt
 cmake_minimum_required(VERSION 3.0)
 set(CMAKE_C_COMPILER_ARG1 "/usr/bin/clang" CACHE INTERNAL "")
 set(CMAKE_C_COMPILER "/usr/local/bin/ccache" CACHE INTERNAL "")
 project(Issue15354 C)
 ...
(0037702)
Tom Hughes (reporter)
2015-01-15 13:49

Thanks. The reason I'm setting those variables in cmake (as opposed to commandline) is that I want to use find_program to find the path for ccache (varies by platform I'm using) and also be able to conditionally enable ccache based on a cmake variable. My project is very complicated (lots of add_subdirectory and includes), so it's hard to ensure that the compiler variable is set before any explicit project command is called (specifically there are platform-specific check_cxx_compiler_flags that don't seem to work without calling project) and it's hard to cleanly refactor those to all be after the compiler setting.

Any plans for somehow officially supporting ccache (i.e., enable/disable it via a cmake variable and have it find it on the platform)? The current method has always seemed like a hack.
(0037703)
Brad King (manager)
2015-01-15 13:58

Re 0015354:0037702:

> Any plans for somehow officially supporting ccache

I'm not aware of any work or plans for this, but if you want to work on it please join the dev list:

 http://www.cmake.org/mailman/listinfo/cmake-developers [^]

and post there. Likely it will be some optional feature of the Makefile and Ninja generators to insert ccache at the beginning of compilation command lines.
(0038853)
Robert Maynard (manager)
2015-06-01 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-01-14 18:09 Tom Hughes New Issue
2015-01-14 18:09 Tom Hughes File Added: cmake-ccache-bug.tar.gz
2015-01-15 08:25 Brad King Summary regression: ccache no longer works with cmake 3.1.2 => regression: ccache no longer works with cmake 3.1.0
2015-01-15 08:25 Brad King Description Updated
2015-01-15 08:32 Brad King Note Added: 0037696
2015-01-15 08:32 Brad King Status new => resolved
2015-01-15 08:32 Brad King Resolution open => no change required
2015-01-15 13:49 Tom Hughes Note Added: 0037702
2015-01-15 13:58 Brad King Note Added: 0037703
2015-06-01 08:38 Robert Maynard Note Added: 0038853
2015-06-01 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team