MantisBT - CMake
View Issue Details
0014841CMakeCMakepublic2014-03-26 09:572014-10-06 10:33
wim van loocke 
 
highmajoralways
closedno change required 
mint 16 linuxLinux-3.11.0-12-
CMake 2.8.12.2 
 
0014841: setting CMAKE_C_COMPILER to gcc creates endless loops
Create 2 projects

cmake_minimum_required(VERSION 2.8.11)
project(pro1 )

#adding crosscompiler stuff
SET( CMAKE_C_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}gcc )
message("CMAKE_C_COMPILER ${CMAKE_C_COMPILER} " )
SET( CMAKE_CXX_COMPILER ${COMPILER_PATH}${CROSS_COMPILE}g++ )
message("CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} " )

add_subdirectory(pro2)


cmake_minimum_required(VERSION 2.8.4)
project(pro2 )

message( STATUS "CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}" )
message( STATUS "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}" )
just run cmake . and you will see endless loop

CMAKE_C_COMPILER gcc
CMAKE_CXX_COMPILER g++
-- CMAKE_C_COMPILER = /usr/bin/gcc
-- CMAKE_CXX_COMPILER = /usr/bin/g++
-- 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/bin/cc

-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMAKE_C_COMPILER gcc
CMAKE_CXX_COMPILER g++
-- CMAKE_C_COMPILER = /usr/bin/gcc
-- CMAKE_CXX_COMPILER = /usr/bin/g++
-- 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/bin/cc
CMAKE_CXX_COMPILER= /usr/bin/c++

-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
I suppose that at the top level project you can define the compiler for all subprojects.


I also found out that when SET( CMAKE_C_COMPILER .. ) is done after the add_subdirectory(pro2), there is no endless loop, but i have to redefine CMAKE_C_COMPILER in the CMakeLists.txt of the pro2


No tags attached.
txt CMakeLists.txt (7,475) 2014-03-26 09:57
https://public.kitware.com/Bug/file/5105/CMakeLists.txt
Issue History
2014-03-26 09:57wim van loockeNew Issue
2014-03-26 09:57wim van loockeFile Added: CMakeLists.txt
2014-03-26 10:17Rolf Eike BeerNote Added: 0035526
2014-03-26 10:45Brad KingNote Added: 0035527
2014-03-26 10:45Brad KingStatusnew => resolved
2014-03-26 10:45Brad KingResolutionopen => no change required
2014-10-06 10:33Robert MaynardNote Added: 0036956
2014-10-06 10:33Robert MaynardStatusresolved => closed

Notes
(0035526)
Rolf Eike Beer   
2014-03-26 10:17   
Do not fiddle with CMakes knowledge about the compiler once it was set, use a proper toolchain file: http://www.cmake.org/Wiki/CMake_Cross_Compiling [^]
(0035527)
Brad King   
2014-03-26 10:45   
CMAKE_<LANG>_COMPILER should not be set after a language is enabled by the project() or enable_language() command. Normally it should not be set in your CMakeLists.txt code at all. The link in 0014841:0035526 explains the proper way to configure cross-compiling.

If you need further help please ask on the mailing list:

 http://www.cmake.org/mailman/listinfo/cmake [^]
(0036956)
Robert Maynard   
2014-10-06 10:33   
Closing resolved issues that have not been updated in more than 4 months.