[cmake-developers] [CMake 0015893]: If cmake needs to restart due to changed compiler, it loses all command line variable assignments
Mantis Bug Tracker
mantis at public.kitware.com
Tue Dec 22 20:00:21 EST 2015
The following issue has been SUBMITTED.
======================================================================
https://public.kitware.com/Bug/view.php?id=15893
======================================================================
Reported By: Paul Smith
Assigned To:
======================================================================
Project: CMake
Issue ID: 15893
Category: CMake
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 2015-12-22 20:00 EST
Last Modified: 2015-12-22 20:00 EST
======================================================================
Summary: If cmake needs to restart due to changed compiler,
it loses all command line variable assignments
Description:
If I invoke "cmake -DFOO=bar ." and cmake discovers that the compiler is changed
and needs to re-invoke itself it does so automatically but in the process it
loses all the -D options from the command line, so they're not set in the
restart making it inaccurate.
Steps to Reproduce:
Given this CMakeLists.txt:
cmake_minimum_required(VERSION 3.4.1)
project(Restart NONE)
set(BUILDNUM "0" CACHE STRING "Build Number")
if(EXISTS "my/gcc")
set(CMAKE_C_COMPILER "${CMAKE_CURRENT_BINARY_DIR}/my/gcc"
CACHE FILEPATH "C compiler" FORCE)
else()
set(CMAKE_C_COMPILER "/usr/bin/gcc"
CACHE FILEPATH "C compiler" FORCE)
endif()
message(STATUS "Build Number: ${BUILDNUM}")
enable_language(C)
Now run it once without the local "my" link, overridding BUILDNUM:
$ cmake -DBUILDNUM=99 .
-- Build Number: 99
-- The C compiler identification is GNU 5.2.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/psmith/src/cmake/restart
Now create the symlink and run it again: it will change the compiler and
restart:
$ ln -s /usr/bin my
$ cmake -DBUILDNUM=99 .
-- Build Number: 99
-- 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= /home/psmith/src/cmake/restart/my/gcc
-- Build Number: 0
-- The C compiler identification is GNU 5.2.1
-- Check for working C compiler: /home/psmith/src/cmake/restart/my/gcc
-- Check for working C compiler: /home/psmith/src/cmake/restart/my/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/psmith/src/cmake/restart
Note how initially the value of BUILDNUM is 99, but then cmake decides to
re-execute itself and afterwards that override is lost and we get the default
value of "0".
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2015-12-22 20:00 Paul Smith New Issue
======================================================================
More information about the cmake-developers
mailing list