> -----Original Message-----
> From: Josef Karthauser
> Sent: 23 October 2007 10:29
> To: Josef Karthauser; [EMAIL PROTECTED]; [email protected]
> Subject: RE: [CMake] Selecting compiler on Windows platform
> 
> > This seems overly restrictive, a tree might contain a number of sub-
> > trees which use different compilers.  Whilst I understand the need to
> > keep things consistent by default, if a user wants to shoot
> themselves
> > in the foot it ought to be allowed.  (Tools not policy! :)
> >
> > I guess I'm going to have to run CMakeDetermineCXXCompiler again
> > myself. :/.
> 
> For the record, I've solved the problem by setting the environment
> variables that I require and then running the the determine and test
> modules again, like so:
> 
>    SET(ENV{CC} gcc)
>    SET(ENV{CXX} g++)
>    INCLUDE(CMakeDetermineCCompiler)
>    INCLUDE(CMakeDetermineCXXCompiler)
>    INCLUDE(CMakeTestCCompiler)
>    INCLUDE(CMakeTestCXXCompiler)
> 
> This appears to work, although it of course doesn't disable the initial
> automatic compiler test.

Actually, this doesn't work. :/  By this time CMake has automatically noticed 
that I have a working CL.exe in the path, and setup for it.  When I then change 
to gcc, and rerun the Determine and Test scripts it still has a number of 
variables set which it got by running the Visual C configuration stuff - this 
causes the later stages of configuration to fail. :/

So I tried another thing, basically setting the correct environment variables 
from within CMake, and then shelling out to a new CMake to do the correct 
configuration, like so:

        # Set correct environment variables, depending upon platform and 
configuration type, etc.
        CONFIGURE_COMPILER()

        # Re-invoke cmake with the correct compiler set populate the build tree
        IF(NOT GEO_INNER_CMAKE AND NOT GEO_CONFIGURED)
                EXEC_PROGRAM(${CMAKE_COMMAND}
                    ARGS "-DGEO_INNER_CMAKE=1" 
"-DCMAKE_BUILD_TYPE=\"${CMAKE_BUILD_TYPE}\""
                    "-G \"${CMAKE_GENERATOR}\"" "${CMAKE_HOME_DIRECTORY}"
                )
                SET(GEO_CONFIGURED 1 CACHE INTERNAL "" FORCE)
                MESSAGE(FATAL_ERROR "CMake configure internal loop and exited.")
        ENDIF(NOT GEO_INNER_CMAKE AND NOT GEO_CONFIGURED)
        MESSAGE("Inner loop got here.")

        ADD_SUBDIRECTORIES(...) etc.

However now this doesn't work, because although the inner cname does configure 
correctly and run, the outer one blats the cache file when it exists with the 
"FATAL_ERROR" and unconfigures all the projects. :/.

Is there a way of causing CMake to exit without touching the cache, so that I 
can use it to drive an internal cmake?

Either that, or what is the correct sequence of modules to run internally, once 
I've set the correct environment variables, to get it to reconfigure the 
compiler.

I'd really appreciate some help with this. 

The problem I'm trying to solve is how to set up a number of 
configurations/build trees, each configured for a different compiler, from a 
single source tree.  I want to describe the compilers from within CMake; 
obviously I could create an external batch file, but then I'd have some 
compiler stuff (like library paths, include paths, etc) in the CMakeLists.txt 
file, and some info like ENV{PATH}, ENV{CC}, ENV{CXX} in the batch file. I 
really want it all in a single place.

Thanks,

Joe
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to