CMake enters an infinite loop when used with specific config

Discussion about CodeLite development process and patches
qdii
CodeLite Enthusiast
Posts: 13
Joined: Sun Nov 13, 2011 10:34 pm
Genuine User: Yes
IDE Question: C++
Contact:

CMake enters an infinite loop when used with specific config

Post by qdii »

CMake version 2.8.10.2

When used with environment variable CXX unset, clang support, and a gentoo-specific cmake rule file that reads:

Code: Select all

SET (CMAKE_AR /usr/bin/x86_64-pc-linux-gnu-ar CACHE FILEPATH "Archive manager" FORCE)
SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> -O2 -pipe -march=corei7 <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
SET (CMAKE_C_COMPILER /usr/lib64/ccache/bin/x86_64-pc-linux-gnu-gcc CACHE FILEPATH "C compiler" FORCE)
SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES>  <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
SET (CMAKE_CXX_COMPILER /usr/bin/g++-4.7.1 CACHE FILEPATH "C++ compiler" FORCE)
SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES>  <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
SET (CMAKE_RANLIB /usr/bin/x86_64-pc-linux-gnu-ranlib CACHE FILEPATH "Archive index generator" FORCE)
SET (PKG_CONFIG_EXECUTABLE /usr/bin/x86_64-pc-linux-gnu-pkg-config CACHE FILEPATH "pkg-config executable" FORCE)
The configure process enters an infinite loop.
The culprit is here: that CMakeLists.txt

Code: Select all

if(DEFINED ENV{CXX})
    message("-- Using CXX $ENV{CXX}")
    set(CMAKE_CXX_COMPILER $ENV{CXX} )
endif()

if(DEFINED ENV{CC})
    message("-- Using CC $ENV{CC}")
    set(CMAKE_CC_COMPILER $ENV{CC} )
endif()
This is unnecessary because it already is CMake default behaviour. (this is documented here: http://www.cmake.org/pipermail/cmake/20 ... 35815.html).

It is also dangerous, because in my particular case, where CXX environment variable is different from the CMAKE_CXX_COMPILER that I set in the rule file, it causes configure to be run over and over again. Compilation never occurs.

Patch here: http://qdii.dodges.it/codelite-honor-CXX.patch
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CMake enters an infinite loop when used with specific co

Post by eranif »

This is actually a bug in cmake and not in codelite's cmake file.
These lines were added on purpose since CMake did not honor the CXX/CC environment variables

I will try and remove these lines again and see what happens
Eran
Make sure you have read the HOW TO POST thread
Post Reply