Re: [CMake] infinite loop when trying to change the compiler in CMakeLists.txt

2009-11-05 Thread Eric Noulard
2009/11/5  btho...@nexus.hu:
 Dear All,

 I am managing a CFD code where wish to set the CMAKE_C_COMPILER and 
 CMAKE_CXX_COMPILER to openmpi
 wrappers.

 So far i was using cmake 2.4.7 and in the CMakeLists.txt the following lines 
 were working perfectly:
 SET(CMAKE_C_COMPILER ${MPI_INSTALL_ROOT}/bin/mpicc )
 SET(CMAKE_CXX_COMPILER ${MPI_INSTALL_ROOT}/bin/mpic++ )

You usually should not do it that way but let CMake discover them, from
a typical command line:

CC=/path/to/mpicc CXX=/path/to/mpic++ cmake /to/build/tree

see:
http://www.cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools
-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] infinite loop when trying to change the compiler in CMakeLists.txt

2009-11-05 Thread Marcel Loose
Another way to deal with this is to set CMAKE_C_COMPILER and
CMAKE_CXX_COMPILER *before* the first project() command. You could do
this in the main CMakeLists.txt file or in a separate CMake script file
that you include before the project() command.

In fact, this is what also happens when you do cross-compilation using a
tool-chain file. The tool-chain file is being read as the very first
file, before any CMakeLists.txt file is processed.

I don't know if doing things this way is considered good practice, but
I'm using it for our project to build with different compilers depending
on the name of the build directory.

Hope this helps,
Marcel Loose.

On Thu, 2009-11-05 at 11:36 -0700, Will Dicharry wrote:
 I think the best way to do that is with an initial cache via the -C
 flag to cmake.  Then you can set the initial CMAKE_LANG_COMPILER
 option in a CMake file and start with that file.
 
 I currently don't do this, but I should.  At the moment I am doing
 this wrong by using the CMAKE_TOOLCHAIN_FILE variable and setting up
 the MPI wrapper compilers in there.  This is currently working for me,
 but it is the wrong way of doing it since the toolchain files should
 really only be used for cross compiling.
 
 -- Will
 
 On 11/05/2009 11:07 AM, btho...@nexus.hu wrote: 
  Dear All,
  
  I am managing a CFD code where wish to set the CMAKE_C_COMPILER and 
  CMAKE_CXX_COMPILER to openmpi 
  wrappers.
  
  So far i was using cmake 2.4.7 and in the CMakeLists.txt the following 
  lines were working perfectly:
  SET(CMAKE_C_COMPILER ${MPI_INSTALL_ROOT}/bin/mpicc )
  SET(CMAKE_CXX_COMPILER ${MPI_INSTALL_ROOT}/bin/mpic++ )
  
  Now that I changed to CMake 2.8.0 there is an infinite loop when trying to 
  configure:
  
  n...@machine: ./deps/bin/cmake ../
  -- The C compiler identification is GNU
  -- The CXX compiler identification is GNU
  -- 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
  -- 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
  -- 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/gcc
  CMAKE_CXX_COMPILER= /usr/bin/c++
  
  -- The C compiler identification is GNU
  -- The CXX compiler identification is GNU
  -- 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
  -- 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
  -- 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/gcc
  CMAKE_CXX_COMPILER= /usr/bin/c++
  
  ... and enters an infinite loop.
  
  If I set the compilers via command line arguments, its fine.
  But for easy-to-compile-by-the-users reason, I would like to set them in 
  the CMakeLists.txt if
  possible.
  Can somebody help me out how to do this right?
  
  The machine: Ubuntu, openmpi 1.3.3 with system gcc 4.4.1 behind
  
  Thx:
  Th
  
  P.S.: I noted a bugfix in CMake 2.6.2 RC 2, may be connected:
  Fix infinite recursion bug with try-compile and change of compilers
  
  
  
  

  
  ___
  Powered by www.kitware.com
  
  Visit other Kitware open-source projects at 
  http://www.kitware.com/opensource/opensource.html
  
  Please keep messages on-topic and check the CMake FAQ at: 
  http://www.cmake.org/Wiki/CMake_FAQ
  
  Follow this link to subscribe/unsubscribe:
  http://www.cmake.org/mailman/listinfo/cmake
 
 ___
 Powered by www.kitware.com
 
 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html
 
 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake


___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake