[CMake] cache behaviour
pellegrini
pellegrini at ill.fr
Wed Jun 27 08:52:32 EDT 2012
Hello CMakers,
I saw this question turning around several times but I do not really
understand why
the explanations do not suit with my problem. Sorry in advance for the
redundancy.
Here is my 'problem':
I have a CMakeLists.txt file that starts with:
##########################################################
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
option(GUI "Build the GUI on top of the console programs." ON)
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE)
else()
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
message(STATUS "Setting build type to ${CMAKE_BUILD_TYPE}")
if(DEFINED CMAKE_Fortran_COMPILER)
set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE
STRING "" FORCE)
else()
set(CMAKE_Fortran_COMPILER ifort CACHE STRING "" FORCE)
endif()
message(STATUS "Setting compiler to ${CMAKE_Fortran_COMPILER}")
project(sxtalsoft Fortran RC)
bla bla bla ...
##########################################################
When I run it a first time in an empty directory with
cmake -G"NMake Makefiles" -DCMAKE_Fortran_COMPILER=ifort
-DCMAKE_BUILD_TYPE=Release ..\..\.
I get:
-- Setting build type to Release
-- Setting compiler to ifort
-- The Fortran compiler identification is Intel
-- Check for working Fortran compiler: C:/Intel/Composer
XE/bin/ia32/ifort.exe
-- Check for working Fortran compiler: C:/Intel/Composer
XE/bin/ia32/ifort.exe -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether C:/Intel/Composer XE/bin/ia32/ifort.exe supports
Fortran 90
-- Checking whether C:/Intel/Composer XE/bin/ia32/ifort.exe supports
Fortran 90 -- yes
-- Configuring done
-- Generating done
-- Build files have been written to:
C:/Users/pellegrini/work/diffraction/sxtalsoft/build/ifort
If a run it a second time WITHOUT deleting the CMakeCache.txt file with
cmake -G"NMake Makefiles" -DCMAKE_Fortran_COMPILER=ifort
-DCMAKE_BUILD_TYPE=Debug ..\..\.
I get this time:
-- Setting build type to Debug
-- Setting compiler to ifort
-- 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_Fortran_COMPILER= ifort
-- Setting build type to Release
-- Setting compiler to ifort
-- The Fortran compiler identification is Intel
-- Check for working Fortran compiler: C:/Intel/Composer
XE/bin/ia32/ifort.exe
-- Check for working Fortran compiler: C:/Intel/Composer
XE/bin/ia32/ifort.exe -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether C:/Intel/Composer XE/bin/ia32/ifort.exe supports
Fortran 90
-- Checking whether C:/Intel/Composer XE/bin/ia32/ifort.exe supports
Fortran 90 -- yes
-- Configuring done
-- Generating done
-- Build files have been written to:
C:/Users/pellegrini/work/diffraction/sxtalsoft/build/ifort
There are two things that puzzle me here. The first is: why cmake detect
a change in the compiler
type as it did not change its value in the command line between the two
calls ? The second is why
during the rerun the CMAKE_BUILD_TYPE is set back to Release and not to
the value set in the command
line i.e. Debug ?
Is my implementation not correct or is this some cache behaviour that I
still do not get ?
thanks a lot
Eric
More information about the CMake
mailing list